Mobile RCP Rocmouse

Post Reply
Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Mobile RCP Rocmouse

Post by Dagnall » 05.03.2018, 20:42

Rob,
I am trying to code a WiFi MQTT Rocmouse for Rocnet.
My code sends MQTT message "fieldcmd" to the Rocrail server (add 01) from the Node address of the ESP8266. (after sending the loco for dispatch), with base address ==0 and to "rocnet/lc" as per the Rocnet protocol data:

Code: Select all

5	fieldcmd	base address	V_raw	dirf	fg 0+1	fg 2+3	fg 4+5	fg 6+7
But I get no actions, nothing happens.
What MQTT topic should I be using?
What else do I need to do /or what have I not set correctly?
Should the mouse be doing something to "bind"??

Thanks
Dagnall

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 05.03.2018, 21:18

Hi Dagnall,

your throttle should send RCP commands, no RocNet.
RocNet does not support a mouse in this form; It scans it on I2C.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 06.03.2018, 12:47

Rob, thanks..(I think!)
First, thanks for the DokuWiki username etc. (but was there a reason for spelling my name with a "e" and not "a" ?) I will wait for a reply before logging in in case you can change my wiki doku username to dagnall53 (thanks..)

RCP. I assume you mean "RCP" = Rocrail Client Protocol.
I have not managed to understand RCP. and thought it was more for web based things. but from your RCP lists, I see Command 30.9.1 lc "fieldcmd" is for rocmouse and saw the same command in the Rocnet lists, so assumed I could send the Rocmouse fieldcmd command over MQQT and rocnet.

Just for clarity, I want to build a throttle that uses MQQT, not the web. Are you saying this is impossible??

I see you have the following definitions in rocnet-const.h

Code: Select all

/* mobile group actions */
#define RN_MOBILE_SETUP          1
#define RN_MOBILE_VELOCITY       2
#define RN_MOBILE_FUNCTIONS      3
#define RN_MOBILE_QUERY          4
#define RN_MOBILE_ROCMOUSE       5
#define RN_MOBILE_ROCMOUSE_BIND  6
#define RN_MOBILE_ACK            7

Are the actions "Mobile_Rocmouse" and "mobile romouse bind" not implemented?
(I see 5 = fieldcmd in the Rocnet descriptions, same as in the RCP descriptions.. so presumably this message can be sent over Rocnet and something is expected to happen..

Code: Select all

Mobile
Actions
request	reply
code	description	data 1	data 2	data 3	data 4	data 5	data 6	data 7	data 1	data 2	data 3	data 4
0	NOP					0			
1	setup	protocol	number of functions								
2	velocity	0…127	direction	lights	mass	steps						
3	function	F1-F8	F9-F16	F17-F24	changed function	F25-F32						
4	query	code	sub-code						code	sub-code	response depends on code
5	fieldcmd	base address	V_raw	dirf	fg 0+1	fg 2+3	fg 4+5	fg 6+7
Thanks for your patience!.
Dagnall

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 06.03.2018, 14:13

Dagnall,

RCP is the normal Client/Server communication way.
http://wiki.rocrail.net/doku.php?id=roc ... tt_service

Trying to use RocNet with a WiFi Throttle is not the way to go and not supported.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 06.03.2018, 15:31

Trying to use RocNet with a WiFi Throttle is not the way to go and not supported.
Can you expand on that please, Presumably you have an alternate wireless throttle concept you think we should use?

I could use the RocWeb throttle, + Phone or tablet, but liked the idea of a simple, inexpensive, dedicated, handheld.

Thanks

Dagnall

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 06.03.2018, 15:34

Hi Dagnall,

1) Connect your throttle with the MQTT Client connection or directly with port 8051 of the Rocrail server.
2) Send XML like: <lc id="myloco" V_raw="100" V_rawmax="127" dir="true" fn="true"/>
3) Or without ID: <lc addr="4711" V_raw="100" V_rawmax="127" dir="true" fn="true"/>
ready.
You throttle is CS independent.

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 06.03.2018, 15:42

Maybe a cheaper alternative is
http://wiki.rocrail.net/doku.php?id=roco:roco-wmz21-en
instead building one your own.

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 06.03.2018, 15:44

But in case you do not want to build in a loco selection display, the LocoNet supports this kind of throttle:
http://wiki.rocrail.net/doku.php?id=mgv_fredi-en
A throttle in RocNet is bind to I2C.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 08.03.2018, 21:10

Rob Thank you for all this information.
There is a lot here to explore!!

Thanks again
Dagnall

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 02.04.2018, 17:20

rjversluis wrote:1) Connect your throttle with the MQTT Client connection or directly with port 8051 of the Rocrail server.
2) Send XML like: <lc id="myloco" V_raw="100" V_rawmax="127" dir="true" fn="true"/>
3) Or without ID: <lc addr="4711" V_raw="100" V_rawmax="127" dir="true" fn="true"/>
ready.
You throttle is CS independent.
Rob, thanks, using mosquitto_pub and with my MQQt host and port, I have found that

Code: Select all

mosquitto_pub -h 192.168.0.18 -p 1883 -t rocrail/service/client -m "<lc addr=\"36\" lc v=\"0\"  lc dir=\"false\" fn=\"false\" lc spcnt=\"128\" />" -q 1 -d
works to send my commanded speed, direction, lights and "spcnt" to my locomotive "36". The '\"' are quite difficult to get correct, but this example works....
(although I am not sure why I might want to change 'spcnt', but this allows it to be changed...)

As usual, there is a question :oops: ....
using this technique, how do I send function commands (Whistles etc)..... ?

Is there a list of these commands somewhere?


As usual, MANY THANKS
Dagnall

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 02.04.2018, 17:32


Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 03.04.2018, 13:22

Great,
To sound f3 on loco 2636 I can send two CMD messages: (turn it on, then turn it off..)
I will paste them here so anyone else following the same idea can make use of them..

Code: Select all

mosquitto_pub -h 192.168.0.18 -p 1883 -t rocrail/service/client -m "<fn addr=\"2636\" f3=\"true\" />" -q  l -d
mosquitto_pub -h 192.168.0.18 -p 1883 -t rocrail/service/client -m "<fn addr=\"2636\" f3=\"false\" />" -q  l -d
I think this gives me enough so I can program a very simple wireless handheld controller to add to the layout.

Cheers
Dagnall

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 03.04.2018, 13:49

Do not forget to include the changed function attribute.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: Mobile Rocmouse

Post by Dagnall » 04.04.2018, 13:39

rjversluis wrote:Do not forget to include the changed function attribute.
Do you mean I need to add

Code: Select all

fnchanged=\"3\"

..?? I see it needs an Integer (presumably the "f" number, (f3 in my test case))
Does this update Rocview?.. I note that my commands make the loco move and sound, but do not seem to update my Rocview/rocrail display.
I have tried

Code: Select all

mosquitto_pub -h 192.168.0.18 -p 1883 -t rocrail/service/client -m "<fn addr=\"2636\" f3=\"true\" fnchanged=\"3\" />" -q  l -d
mosquitto_pub -h 192.168.0.18 -p 1883 -t rocrail/service/client -m "<fn addr=\"2636\" f3=\"false\" fnchanged=\"3\"  />" -q  l -d
But this seems to be exactly the same as without the fnchanged

rjversluis
Site Admin
Posts: 42363
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Mobile Rocmouse

Post by rjversluis » 04.04.2018, 13:53

Just check the Server trace if your mqtt publish has been received.

Post Reply

Return to “DIY Hardware”