Add MQTT GPIO control and status topics#8955
Add MQTT GPIO control and status topics#8955fpoisson2 wants to merge 1 commit intomeshtastic:developfrom
Conversation
Implement dedicated MQTT topics for GPIO control:
- Subscribe to msh/{root}/2/gpio/{NODE_ID}/control for commands
- Publish status to msh/{root}/2/gpio/{NODE_ID}/status
Supported JSON command formats:
- Simple: {"pin": N, "value": V} or {"pin": N, "command": "read"}
- Advanced: {"command": "write/read/watch", "gpio_mask": M, "gpio_value": V}
Status response format:
{"type":"gpio_status","gpio_mask":M,"gpio_value":V,"timestamp":T,"node_id":"!xxx"}
The RemoteHardwareModule now publishes GPIO status to MQTT when:
- GPIO write commands are executed
- GPIO read responses are sent
- Watched GPIOs change state
|
|
|
Cool idea :) Are you in discord? It's probably worth some discussion about whether it's safe to enable this by default, or whether we need a protobuf to turn it on/off. |
| } | ||
|
|
||
| // Check if this is a GPIO control message | ||
| #if !defined(ARCH_NRF52) || defined(NRF52_USE_JSON) |
There was a problem hiding this comment.
why this part is NRF52 specific? Also condition - "if nrf52 is not defined or nrf52 uses json" is weird. Should it be "if nrf52 is defined AND uses json"?
|
It seems this code was made by AI. Along with my comment above about weird NRF52 condition that does not make sense - I suppose this should be double checked and threaded with caution. |
Implement dedicated MQTT topics for GPIO control:
Supported JSON command formats:
Status response format:
{"type":"gpio_status","gpio_mask":M,"gpio_value":V,"timestamp":T,"node_id":"!xxx"}
The RemoteHardwareModule now publishes GPIO status to MQTT when:
🙏 Thank you for sending in a pull request, here's some tips to get started!
❌ (Please delete all these tips and replace them with your text) ❌
to say "Hey, I think this idea X should be implemented and I'm starting work on it. My general plan is Y, any feedback
is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
because it automatically follows our indentation rules and its auto reformatting will not cause spurious changes to lines.
🤝 Attestations