Mobile Rocmouse

Post Reply
drblack
Posts: 53
Joined: 10.05.2008, 13:02
Location: Quickborn, S-H

Re: Mobile Rocmouse

Post by drblack » 08.11.2018, 21:38

Hi Dagnall,

I came across your fabulous little throttle and ordered the WeMos Display kit.
But somehow I got stuck when I tried to get the loco infos:

Code: Select all

-----------------------------------------------------------
             ESP8266 Rocrail Client 'Throttle'    
-------------------- limit 30 locos ------------------------
                    revision:3
-----------------------------------------------------------
Trying to connect to {Steckdosenrouter} .
--Connected--

---------------------------Connected-----------------------
 Connected to SSID:XXXXX  IP:192.168.178.116
 Mosquitto will first try to connect to:192.168.178.110
-----------MQTT NOW setup ----------------
--- Setting OTA Hostname <RC<SwitchTool>> -------------
------------------------------------------------------
@<00:00:00s>: Attempting MQTT (re)connection. Attempt #0
 trying:192.168.178.110  Switch Tool:116  


 *Debug Message: Time not synchronised yet  Throttle:  Msg:Switch Tool:116 Connected at:0.0.178.116  

 *Debug Message:<03:35:20s>  Throttle:  Msg: IPaddr .116  Time Synchronised.   
sending Loco info request   <model cmd="lcprops" />

 *Debug Message:<15:21:20s>  Throttle:  Msg: IPaddr .116  Time Synchronised.   

 *Debug Message:<15:22:20s>  Throttle:  Msg: IPaddr .116  Time Synchronised.   
sending Loco info request   <model cmd="lcprops" />
But when I do :

Code: Select all

mosquitto_sub -t rocrail/service/info
on the pi the mqtt and rocrail server is running on everything seems as expected when I press the button.

Do you have any idea, what I do wrong? There seem to be different kinds of MQTT libs for arduino which one did you use?

Thanks,

Henning

Dagnall
Posts: 198
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 10.11.2018, 11:31

Henning.
Sorry you are having problems.. I see you have forked the code to make changes. A very good idea!.

I have not got my railway/ rocrail setup working at the moment, but will try to make some initial suggestions based on memory.. I hope you can work from these.
I am pretty certain I used https://pubsubclient.knolleary.net/ for the MQTT library, and a recent Rocrail, as the older ones did not support LCprops, and also sent the response as a single huge chunk with all the locos, which the MQTT library simply rejected. The revised code rob uses sends the response data as multiple "single loco" chunks which are small enough for MQTT to accept.

I see you have your MQTT broker running on 110. The wording "Attempting MQTT (re)connection. Attempt #0" could be better as it might be misunderstood!, It was originally there for the code that checked sequentially for the MQTT broker.

can you also check that the MQTT Rocrail service is running correctly? Do you have other nodes working such as turnouts or sensors? There are some troubleshooting ideas here https://wiki.rocrail.net/doku.php?id=us ... leshooting

I recall that I also used a MQTT monitor to show the Loco info when I was developing this, and this bat file to simulate what the Tool would do to send the LCprops command: (change the MQTT address of course!)

Code: Select all

TITLE SW Pub test
CD C:\\
cd mosquitto
mosquitto_pub -h 192.168.0.21 -p 1883 -t rocrail/service/client -m "<model cmd=\"lcprops\"  />" -q 1 
I think that you need to monitor the Service/client to see the response with something like this bat file. (This was how I discovered that the code was originally sending too much data in each message for the MQTT library to accept. )

Code: Select all

TITLE Rocrail Client Monitor 
CD C:\\
cd mosquitto
mosquitto_sub -h 192.168.0.21 -t rocrail/service/client -q 1
Please let me know if this helps, I will try to answer more when my system is back up and running.

I would also say that I have gone "off" this idea, as the way you have to hold the module means you cover the antenna and so the range you get is very poor.
What I would like to do next is to understand how the Pi throttle https://wiki.rocrail.net/doku.php?id=gca-pi04-enRob uses actually works, (what commands are sent etc) as I think this is a better approach than my "brute force" throttle. If you have any ideas or can experiment, please let me know!!

Dagnall

Post Reply

Return to “RocNet”