MQTT Client Gateway / Node Controller / OTA
-
Type 18 is the heartbeat message type, I think this is the last element in your MQTT topic so it looks fine I think. Can you monitor the MQTT broker and see what messages are passing through it? (e.g if you can see something being sent by the sensors)
@maghac - I know the sensors are sending messages, the gateway is responding as it should to them, i was just concerned about the gateway keep connecting itself to the MQTT server, i was a little worried in case there is a feature in Mosquitto broker that declines the connection if it detects any sort of brute force or anything like that.
-
Type 18 is the heartbeat message type, I think this is the last element in your MQTT topic so it looks fine I think. Can you monitor the MQTT broker and see what messages are passing through it? (e.g if you can see something being sent by the sensors)
On my MQTT server i'm sure enough receiving a message from the gateway every time it says its reconnected in the serial monitor, sending its version number to the server. By the looks of the serial monitor, its actually reconnecting and not just sending a new message to the MQTT topic. I'm confused to why this is doing this, I had just assumed that the heartbeat message is just a re-sending on a message on that topic. Would like to know if this is the normal behaviour of the gateway to keep constantly reconnecting.
-
Mine doesn't reconnect. Here's the serial monitor on startup:
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGE--,VER=2.1.1 0;255;3;0;9;TSF:LRT:OK 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSF:WUR:MS=0 scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 14 cnt connected with hacker, channel 9 dhcp client start... 0;255;3;0;9;TSM:INIT:TSP OK 0;255;3;0;9;TSM:INIT:GW MODE 0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0 0;255;3;0;9;MCO:REG:NOT NEEDED f r0, scandone ....ip:192.168.1.215,mask:255.255.255.0,gw:192.168.1.1 .IP: 192.168.1.215 0;255;3;0;9;MCO:BGN:STP OTA init Ready IP address: 192.168.1.215 0;255;3;0;9;MCO:BGN:INIT OK,TSP=1 IP: 192.168.1.215 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mysensors-out/0/255/0/0/18 0;255;3;0;9;Message arrived on topic: mysensors-in/200/255/3/0/6 0;255;3;0;9;!TSF:RTE:200 UNKNOWN 0;255;3;0;9;!TSF:MSG:SEND,0-0-200-200,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/254/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/222/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-222-222,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/222/255/3/0/1 0;255;3;0;9;!TSF:MSG:SEND,0-0-222-222,s=255,c=3,t=1,pt=0,l=10,sg=0,ft=0,st=NACK:1485810579 0;255;3;0;9;Message arrived on topic: mysensors-in/123/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-123-123,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/255/255/3/0/4 0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=4,pt=0,l=3,sg=0,ft=0,st=OK:234 0;255;3;0;9;Message arrived on topic: mysensors-in/227/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-227-227,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/227/1/1/0/24 0;255;3;0;9;!TSF:MSG:SEND,0-0-227-227,s=1,c=1,t=24,pt=0,l=3,sg=0,ft=0,st=NACK:102 0;255;3;0;9;Message arrived on topic: mysensors-in/233/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-233-233,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/234/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-234-234,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=17,pt=5,l=4,sg=0:7160 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/17 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=24,pt=5,l=4,sg=0:530 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/24 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=18,pt=7,l=5,sg=0:0.5300 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/18 pm open,type:2 0 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=17,pt=5,l=4,sg=0:7175 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/17 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=24,pt=5,l=4,sg=0:570 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/24 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=18,pt=7,l=5,sg=0:0.5700After this, it's just continously getting data from sensor 227 (my power meter). My mosquitto broker is getting this:
mysensors-out/0/255/0/0/18 2.1.1 mysensors-out/227/1/1/0/17 7160 mysensors-out/227/1/1/0/24 530 mysensors-out/227/1/1/0/18 0.5300 mysensors-out/227/1/1/0/17 7175 mysensors-out/227/1/1/0/24 570 mysensors-out/227/1/1/0/18 0.5700 mysensors-out/227/1/1/0/17 7195etc etc - it's just the one message on startup.
-
Mine doesn't reconnect. Here's the serial monitor on startup:
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGE--,VER=2.1.1 0;255;3;0;9;TSF:LRT:OK 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSF:WUR:MS=0 scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 14 cnt connected with hacker, channel 9 dhcp client start... 0;255;3;0;9;TSM:INIT:TSP OK 0;255;3;0;9;TSM:INIT:GW MODE 0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0 0;255;3;0;9;MCO:REG:NOT NEEDED f r0, scandone ....ip:192.168.1.215,mask:255.255.255.0,gw:192.168.1.1 .IP: 192.168.1.215 0;255;3;0;9;MCO:BGN:STP OTA init Ready IP address: 192.168.1.215 0;255;3;0;9;MCO:BGN:INIT OK,TSP=1 IP: 192.168.1.215 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: mysensors-out/0/255/0/0/18 0;255;3;0;9;Message arrived on topic: mysensors-in/200/255/3/0/6 0;255;3;0;9;!TSF:RTE:200 UNKNOWN 0;255;3;0;9;!TSF:MSG:SEND,0-0-200-200,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/254/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-254-254,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/222/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-222-222,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/222/255/3/0/1 0;255;3;0;9;!TSF:MSG:SEND,0-0-222-222,s=255,c=3,t=1,pt=0,l=10,sg=0,ft=0,st=NACK:1485810579 0;255;3;0;9;Message arrived on topic: mysensors-in/123/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-123-123,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/255/255/3/0/4 0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=4,pt=0,l=3,sg=0,ft=0,st=OK:234 0;255;3;0;9;Message arrived on topic: mysensors-in/227/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-227-227,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/227/1/1/0/24 0;255;3;0;9;!TSF:MSG:SEND,0-0-227-227,s=1,c=1,t=24,pt=0,l=3,sg=0,ft=0,st=NACK:102 0;255;3;0;9;Message arrived on topic: mysensors-in/233/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-233-233,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;Message arrived on topic: mysensors-in/234/255/3/0/6 0;255;3;0;9;!TSF:MSG:SEND,0-0-234-234,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=17,pt=5,l=4,sg=0:7160 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/17 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=24,pt=5,l=4,sg=0:530 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/24 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=18,pt=7,l=5,sg=0:0.5300 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/18 pm open,type:2 0 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=17,pt=5,l=4,sg=0:7175 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/17 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=24,pt=5,l=4,sg=0:570 0;255;3;0;9;Sending message on topic: mysensors-out/227/1/1/0/24 0;255;3;0;9;TSF:MSG:READ,227-227-0,s=1,c=1,t=18,pt=7,l=5,sg=0:0.5700After this, it's just continously getting data from sensor 227 (my power meter). My mosquitto broker is getting this:
mysensors-out/0/255/0/0/18 2.1.1 mysensors-out/227/1/1/0/17 7160 mysensors-out/227/1/1/0/24 530 mysensors-out/227/1/1/0/18 0.5300 mysensors-out/227/1/1/0/17 7175 mysensors-out/227/1/1/0/24 570 mysensors-out/227/1/1/0/18 0.5700 mysensors-out/227/1/1/0/17 7195etc etc - it's just the one message on startup.
@maghac - Right okay. Atleast i now have someone else's to compare too. So, something is pushing it off the network OR it can't hold its connection.
My start up sequence:
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1 0;255;3;0;9;TSM:INIT 0;255;3;0;9;TSF:WUR:MS=0 0;255;3;0;9;TSM:INIT:TSP OK 0;255;3;0;9;TSM:INIT:GW MODE 0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0 0;255;3;0;9;MCO:REG:NOT NEEDED IP: 192.168.0.22 0;255;3;0;9;MCO:BGN:STP 0;255;3;0;9;MCO:BGN:INIT OK,TSP=1 IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... IP: 192.168.0.22 0;255;3;0;9;Attempting MQTT connection... 0;255;3;0;9;MQTT connected 0;255;3;0;9;Sending message on topic: Gateway1-out/0/255/0/0/18 0;255;3;0;9;Message arrived on topic: Gateway1-in/4/1/1/0/2 0;255;3;0;9;!TSF:MSG:SEND,0-0-4-4,s=1,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0The start is different to mine, that is probably because you're running that on a ESP8266, right?
I have connected to the MQTT server with MQTTFX, which is a MQTT monitoring tool. Not too familiar with it right now but i can't see the server dropping any connections or anything, it almost seems like the gateway is stuck in a loop.
-
Did you try to swap the mega for an arduino uno? Or swap the w5100 shield? Just to see if there is any difference, so we can exclude any hw issues
@gohan - The only thing that be causing this is software as the 1.6 branch works perfectly on this setup with the same sketch but back when it was 1.6 development.
So, if i'm thinking correctly, even if there is a issue between software and hardware, it should be fixable through software, hope this makes sense to anyone other than myself. I don't have an UNO, the only other thing i have is a nano. I'm currently using a W5100 shield, not module, but i do have some modules here, but they were a pain to get working before and hence why i made the switch to the shield.
EDIT: I can confirm that the shield is working properly as i have ran a http test sketch and i'm able to communicate from my web browser to the arduino. So it must be a software issue.
-
Update: I have tried MySensors versions V2.0, V2.1.1 and even the development branch. From what I can work out, V1.6 when it was a development branch got released as V2.0. But that isn't working either, not sure what state it was in before I changed to V2.1.1 as i never monitored the gateway before i reinstalled the new version.
Either way, none are working, they're all giving me the same result. Therefor i'm attempting to find an issue else where on the network other than MySensors. I'm going to try a new MQTT broker, on a different machine. If this gives the same result then its time to troubleshoot my network. Then if that doesn't show anything i think its safe to revert back to looking through my Gateway software.
-
I can confirm that the issues is not MySensors, I've just created a virtual machine running Ubuntu and installed Mosquitto there. Connected the gateway and perfect functionality. Everything is working as intended with a nice silent serial output until a message is sent to the gateway.
-
I suppose this is on your own LAN, so there are no firewalls or anything that could block the MQTT traffic? Can you see anything in the mosquitto log?
@maghac - It is on the LAN, no firewalls that are stopping it unless they're on the ubuntu box themselves but i had a quick look at that at the start of my issues and the two ports were open for MQTT. So unless something is up with the allowance settings, then its not that. I'm about to find the location of the MQTT logs to check that now. I'm connected to the MQTT server with MQTT.fx and the log is filling with commands, can't see anything obvious right now. Will check the logs on the machine to see any issues recorded.
Would you expect to see anything in any of the logs specifically or just check them all? Do you happen to know where they're located?
-
UPDATE: The issue has been resolved.
I have no clue why it has only just became and issue because my OpenHAB hasn't been upgraded or modified since day one. But the issue was that the OpenHAB install was attempting to join the MQTT broker (on the same system) with the same ID as the MySensors Gateway. Once i changed my config of OpenHAB MQTT connection, its all working perfect now.
Please, if you see anyone having this issue, point them to this message. I may add it to the controller section or ask a MOD/ADMIN to add it to the OpenHAB controller page if they feel its something that maybe worth pointing out.
Thank you all for your continued help with this. Now, time to get back to the issue at heart. I will be testing the use of MyController today without having to disconnect OpenHAB at all.
-
UPDATE: The issue has been resolved.
I have no clue why it has only just became and issue because my OpenHAB hasn't been upgraded or modified since day one. But the issue was that the OpenHAB install was attempting to join the MQTT broker (on the same system) with the same ID as the MySensors Gateway. Once i changed my config of OpenHAB MQTT connection, its all working perfect now.
Please, if you see anyone having this issue, point them to this message. I may add it to the controller section or ask a MOD/ADMIN to add it to the OpenHAB controller page if they feel its something that maybe worth pointing out.
Thank you all for your continued help with this. Now, time to get back to the issue at heart. I will be testing the use of MyController today without having to disconnect OpenHAB at all.
-
@Samuel235 great that you found the problem, and thanks for reporting back.
@mfalkvidd - In the process of monitoring the network now to check everything is still normal behaviour. I may be getting a random message published, keeping an eye on this. I would say if I do have an issue, it has nothing to do with software though :)
I'm looking into MyController as we speak just for the OTA updates alone then returning to normal controller.
-
Update: I've got a MQTT/persistence error on MyController, so i'm waiting on a software developer for them to advise me on a solution.
-
Update: I've got a MQTT/persistence error on MyController, so i'm waiting on a software developer for them to advise me on a solution.
@Samuel235 What is the error are you facing? Did you report anywhere?
-
@Samuel235 What is the error are you facing? Did you report anywhere?
-
Still applying configuration on my OpenHAB and MyController setup. At the moment, it looks like its a very possible pairing to work for our needs. But I'm not completely installed together yet. In theory, it is working. Just applying that now :)
- Got them both installed.
- Got OpenHAB2 configured.
- Need to change my MyController port.
- Need to sort out the bootloader issue i'm having with MyBootloader not going to sketch properly in boot-up.
-
Everything working except for the node is not automatically rebooting on new firmware command. Will update on manual reboot.
-
@Samuel235 Great news! How does your final setup look like - how did you configure MyController? And what is the steps to follow when publishing an OTA update to the nodes?
Maybe the reboot issue can be solved by manually sending a message to the node to reboot it? Assuming there is such a functionality in the protocol of course.
-
@Samuel235 Great news! How does your final setup look like - how did you configure MyController? And what is the steps to follow when publishing an OTA update to the nodes?
Maybe the reboot issue can be solved by manually sending a message to the node to reboot it? Assuming there is such a functionality in the protocol of course.
@maghac - I have been speaking to a couple of people, one of which is Jkandasa himself, to my understanding, using MYSBootloader does not enable us to issue a firmware update and then to automatically reboot itself. However, as you suggested, there is a reboot option in MyController. As far as I understand (I may be slightly wrong here, but i don't think i am) every time a MYSBootloader enabled node boots up, it asks MyController if there is a firmware update for it (is there a linked firmware to me that i do not have?) and if so, it goes ahead and downloads it.
I'm happy to confirm i have this all working now.
A vague outline of what we have to do:
- Install MyController.
- Edit the conf files (On linux its: <MYCONTROLLER INSTALL LOCATION>/conf/mycontroller.properties) to change the port that it uses from 8443 to anything you wish, i have set mine to 9443 and save the changes to that conf file.
issue the start command inside of the /bin folder and then use your browser to go to https://<IPOFMYCONTROLLERMACHINE>:<PORTNUMBER> then you should be greeted with the login page for your mycontroller install. - log in with admin and admin (change these).
- Navigate to the Settings>MQTT Broker page and disable the MQTT broker functionality.
- Navigate to Resources>Gateway and then click Add gateway. This is where you enter the MQTT settings to enable MyController to find your gateway and nodes.
- Give the gateway a name, then select the MySensors type and MQTT. Add your details here for the MQTT server.
- Once added, you can select your gateway and in the drop down menu (top right above the list of gateways) you can select discovery, this should automatically discover your nodes.
To send a new firmware to the node, follow the guide on MySensors to create the hex file. then follow the section related to firmware on the user guide of MyController. Once you have saved a new firmware, you then go into the nodes list and associate that node with the new firmware by editing the settings on that node and there should be a firmware box that your able to drop down and select an uploaded firmware. Then you can select the node and issue a reboot from the drop down at the top right of the list of nodes. The version control of the firmware files that you upload is really awesome! I must thank @jkandasa for that!
If you have any issues at all, please ask more questions here, i'm willing to help. I may even write a little more in-depth guide for others to use. That way we can always link people to this thread for the information to do such.
I have a few little bits of config left to do in terms of security of the server and then i'm all set.