@supczinskib Sorry for the delay, been working on another project. I managed to get ssl to work with the device and tested out a lot of the configuration options. I had an issue with the example and posted it along with a solution in another thread -> Setting up ssl/tls with mosquitto = "A TLS error occured" solution. Hope this answers your question.
Posts made by Carey Capaldi
-
RE: Onion Omega Dash, ESP8266 and umqtt
-
RE: Onion Omega Dash, ESP8266 and umqtt
@Lazar-Demin Submitted, checked and now officially posted.
-
RE: Onion Omega Dash, ESP8266 and umqtt
Just a quick update, The code has been running for a few months and seems to be stable. Today I added the code that automatically switches back to the first tab. I posted the demo code in another project just in case anyone is interested here is the link.
https://community.onion.io/topic/4300/using-a-counter-within-a-running-thread-to-change-the-display-when-there-is-no-actions-on-the-touch-screen-for-omegadash-module -
Using a counter within a running thread to change the display when there is no actions on the touch screen for OmegaDash module
In my Dash projects I want to have a main display screen for basic monitoring then use tabs to get to specific screens for controlling with the tab grouping the controls. However after I am finished making control changes, I want the Dash to automatically go back to the monitor display.
So the goal was to have some count down timer start then trigger the screen change but only after there is no more control activity.
The flow is to start the count down when I change tabs to make a control change. Then upon the completion of a count down, automatically change the display back. One issue is that every control change needs to reset the timer so upon the last change it runs its full cycle and triggers the change.
I decided to use a Micropython thread as the countdown and a global variable as the start count. This way I can update the value every time I make a control change thus resetting the count down to start from the top. Then when I am done making changes it will naturally finish the count down and trigger the screen change.Notes about the code:
I annotated the example it creates three tabs with text in them.
When initially started it will display tab 3 and start a 30 second count down.
If you change tabs before it reaches 0, the count will reset to 35
When you let it count down, it will switch the display to tab 1 and if you change tabs after that, it will start the countdown for 35 seconds.
Consider it a small example, the code isn't particularly clean but it is posted as an example.Here is the link to the git repository for the code: https://github.com/ccapaldi/DashTabCountdown
-
RE: Setting up ssl/tls with mosquitto - "A TLS error occurred" solution
@Carey-Capaldi
Just modified one of my scripts for publishing a button press on the OmegaDash. It works fine, just substitute the MQTTClient call using the same string as above.Have fun.
-
RE: Setting up ssl/tls with mosquitto - "A TLS error occurred" solution
So with some further testing I had to do the following. ( the conf info is from the setup link, I haven't played with those settings much but these worked)
The mosquitto conf :port 1883
allow_anonymous false
password_file /etc/mosquitto/passwords.txt
log_type informationlistener 8883
protocol mqtt
cafile /root/py/mqSecurity/certs/mosq-ca.crt
certfile /root/py/mqSecurity/certs/mosq-serv.crt
keyfile /root/py/mqSecurity/certs/mosq-serv.keyUsing Wireshark to capture the conversation, when we use port 8883 I cannot see the username and password in the message like I did when I used port 1883 so encryption seems to be working.
What I had to do in the micropython client is summarized below:
I set the following variables - remember the server name had to be in the hosts file when I created the ssl keys and certs.
SERVER = "mos_broker"
PORT=8883
USER = "Thing01"
PASSWORD = "Thing01"
SSL_PARAMS = {"ca_certs":"./certs/mosq-ca.crt"}
TOPIC = "data"For the client connection I used the following:
c = MQTTClient("OmegaDashD2E2", user=USER, password=PASSWORD, server=SERVER, ssl_params=SSL_PARAMS)(if anyone is interested in the full code, contact me and I can send it however I got it from the MQTT.simple example on the git page)
So this seems to work fine, and can handle the encrypted data sent/received from my mac however I found the following behavior.
NOTE:
I could not remove port 1883 from the config file and when a client sends an unencrypted post to port 1883, the subscriber also sees that and prints it. I see the same behavior in mqtt.fx subscriber so it may be mosquitto broker behavior.What his means is that any connection to that port (1883) may expose usernames, passwords and topics.
I couldn't force the micropython subscriber to use only port 8883, I keep getting errors about too many parameters being sent to the MQTTClient() back end code.
So for security, do not use port 1883 and your username/password along with the topic should be hidden from any general snooping.I will test out publishing from the Omega in the future.
-
RE: Setting up ssl/tls with mosquitto - "A TLS error occurred" solution
@Carey-Capaldi So after getting mqtt.fx on the mac working with my onion omega broker running ssl/tls I ran into a slight snag. I can't find any good micropython examples on how to set up the MQTTClient() call properly. I am still looking and when I find it and get it to work, I will post to this thread.
-
Setting up ssl/tls with mosquitto - "A TLS error occurred" solution
After a comment in one of my other project threads, I decided to look into setting up a secure transport layer with my MQTT communication for IoT projects.
I ran into an initial problem that I wanted to post the solution so any others who may want to try this won't have to spend a lot of time like I did troubleshooting.
First I followed the guide on this link for setting up all the encrypted files.https://dzone.com/articles/mqtt-security-securing-a-mosquitto-server
If you follow all the commands you will have the required files.
I also have wireshark on my Mac so I also installed mqtt.fx so I could monitor the communication and look at the unencrypted verses encrypted communication.
So I added a password file to the mqtt broker then sent a connection request from mqtt.fx. Sure enough when you examine the packet, you can see the username, password, topic and message data in plain text.
So out of the box mqtt is fine for testing but not secure over the long haul, especially if you want to connect to your network from the outside.
Next I followed the guide and set up the mqtt broker to use ssl/tls on port 8883 as suggested.
Then I hit a wall, I got an error when trying to just pub/sub on the local host "A TLS error occurred" is the error I got when running both mosquitto_pub and mosquitto_sub to test the connection.
I was able to both pub/sub from mqtt.fx and see that the broker was working but it has to work locally or my micropython code won't work.
The solution was in an answer when setting up the .crt file, there are a bunch of quesitons that you answer and for one of them I should have used a known host in my host file, the CN or Common Name question requires a valid entry so I added the local IP address and a host name that I created for it. A TLS error occurred.
Below is what it looks like with one of the mosquitto commands.
mosquitto_pub -p 8883 --cafile ./certs/mosq-ca.crt -t data -m "this is a test" -u Thing01 -P Thing01 -d -h mos_brokerAs you can see from the entry above, I have a username, password and the host is listed in my /etc/hosts file. This was not explained in the example setup but when you look at his answers he uses a valid host name.
The answer I found in another link on how to set up ssl/tls and at the bottom the author explained what the error was.
This is the link to that one if you are interested.
https://openest.io/en/2020/01/03/mqtts-how-to-use-mqtt-with-tls/ -
RE: Onion Omega Dash, ESP8266 and umqtt
@crispyoz I do that as part of the initial setup.
-
RE: Onion Omega Dash, ESP8266 and umqtt
@crispyoz Now that you have me thinking about this, I did write up a public/private key system for rabbitMQ messages a couple years ago. I think it might be nice to port it over. Do you think this might be of interest? Each key is created individually by the user who sets it up and if you run over a secure transport protocol, it might be enough to secure a home IoT system.
-
RE: Onion Omega Dash, ESP8266 and umqtt
@crispyoz Hack into what? As far as ANPR this is on my list but for another reason.
Cool that you can track your dog disposition. -
RE: Onion Omega Dash, ESP8266 and umqtt
@Carey-Capaldi
As I mentioned in a post, I created something substantial using the Dash and repurposing/updating two of my ESP8266 projects.- ESP8266 temperature probe for garage refrigerator, this was something I originally built to monitor the temperature in my spa. I built a gauge with the temp displayed as text and stuck it in the first tab on a Dash module.
- ESP8266 to control three relays. Using a 5 volt 4 relay module that I purchased on Amazon I connected three of the 8266 GPIO ports to open/close both of my garage doors and gate at the end of the drive.
- They are controlled using MQTT and I have an Onion Omega Pro as the MQTT Broker along with a graphic display on a Dash display that has a monitor tab and control tab. In the monitor tab I display the state, for phase 1 just the temp for the garage fridge appears today. On the control tab, I have three buttons one each for garage doors and gate.
Here are a couple pictures. I am still mulling around how to mount the Dash and where to put it but this all runs great. IN the next phase, I will monitor the states of the doors and gate and add that to the monitor tab.
-
RE: Onion Omega Dash, ESP8266 and umqtt
@crispyoz I'll get around to something more substantial in the future, for now I am just cutting my teeth with the technologies. I had a few 8266 modules and Arduinos connected to NodeRed but I really like the idea of using the Dash as a wall or desktop mounted display/controller.
-
Onion Omega Dash, ESP8266 and umqtt
I finally got around to installing micropython-lib and using the umqtt.simple client.
I took my basic three needle gauge demo code and integrated the umqtt.simple library into it. Next I took some ESP8266 code that I had been using and modified it to randomly generate values for the red and purple needles then publish them to the mqtt broker I have running on an Omegapro. The Dash picks up the changes and moves the red/purple needles to the generated values. Next I added a button to the gauge and when pressed it toggles the LED on the ESP8266 by publishing either 0/1 to another topic that the 8266 is subscribed to. What we have is a bi-directional communication between an OmegaDash and ESP8266 using mqtt.
This is a link to the video. https://youtu.be/lDISos59tocMy first projects are designed to learn and demonstrate some basic capabilities while learning but I will soon post something complete for setting up a small touch panel to display and control automation in my home.
-
RE: lvgl and micropython examples for Onion Omega Dash
Ok I finally got around to installing the micropython-lib on one of my Dash modules. I went to the Git hub site and used the example code there for the umqtt.simple client, to my disappointment it does not return a clean string for the message so for my projects where I convert the string into Json, this simply won't work as is. After searching I found that I had to create a routine to convert the binary text to a proper string I posted it below. I really don't understand why people don't go the extra distance to make things clean when they write code when did "good enough" become the norm?
def make_string(s):
return("".join(map(chr,s))) -
RE: lvgl and micropython examples for Onion Omega Dash
@Lazar-Demin
Thanks, I'll take a look at micropython-lib. I just got one of my MQTT test programs on an ESP8266 running with the Omega setup. Will make it a point to reshoot my mqtt video when I get the micropython-lib version running. -
RE: lvgl and micropython examples for Onion Omega Dash
@crispyoz
Thanks but I am past that. My question is about MQTT, due to the lack of storage space, I installed python3-light then pip3 and finally paho-mqtt. So I have to run a python3 program in the background to catch mqtt messages then transfer them to the micropython routine running the display. A bit cumbersome but workable. -
RE: lvgl and micropython examples for Onion Omega Dash
@crispyoz Lol, so can my hair, it's my covid look.
-
RE: Micropython Build with LVGL for Omega2?
Thanks, so far I am having good success with micropython and lvgl. I have been working through the lvgl widget examples on the document site and posting videos of my progress. Is there any plan to add a version of MQTT to micropython? I was able to install python-light and use it as the subscriber then handling the information exchange through a file, primitive but workable. It would be more elegant if I could just subscribe/publish from within the micropython code.