¿ªÔÆÌåÓý

Locked Re: MQTT Connection in JMRI


 

Hi Nathan,
I also desire having the same sketch apply to all nodes of the same type and config updates via MQTT seems to be the way to go. Big tick from me.

As you know,? there is still config to be done before a node can connect to MQTT -
? ¡°Flopper", ? ? ?// ssid
? ¡°Flipper", ? ? ? ? ? ?// password
? "192.168.20.78", ? ? ? ? // MQTT ip
? 1883, ? ? ? ? ? ? ? ? ? ?// MQTT broker port
? "", ? ? ? ? ? ? ? ? ? ? ?// MQTT username
? "", ? ? ? ? ? ? ? ? ? ? ?// MQTT password
Until someone comes up with a better idea, I think the best way to do this initial config is via USB connection, conversing with the user through the Arduino IDE or perhaps some other host program (python script perhaps?) for people not wanting to use the IDE. Later updates of these will likely need to be done the same way.

Of course, JMRI does not have to be used to configure these devices, any MQTT client can be use to publish the required config updates. Config through JMRI is perhaps a nice-to-have method, like configuring command stations, etc but can be considered later down the track.

To expand on and retain compatibility with the existing MQTT code in JMRI, unless we deliberately want to break this compatibility,? I suggest your topics be:
?? /trains/ESP/sensors/MACADDRESS???? instead of ? ? trains/sensors/ESP/MACADDRESS??
? (note that trains is very different to /trains, the latter pushing everything down one level of / separators and has a null top level.)
While it's true that there is no existing MQTT code for sensors, keeping the same structure as turnouts seems the logical way to go.

The one thing I don't like (and I mean really don't like) is using the MAC address for the device name. Whilst it may get the job done, I find it cumbersome and awkward to use. I'd rather supply a more meaningful and friendlier name of my own. This could be set during the USB config stage or have a default set in the code, changeable via MQTT config update.? You can still put the mac address in there if that's what you want to use.

Kind regards, Dave Mc.

Join [email protected] to automatically receive all group messages.