meshtastic / python

The Python CLI and API for talking to Meshtastic devices
https://meshtastic.org
379 stars 160 forks source link

Unable to read gpio from local device, not found in DB #501

Closed Kralg closed 6 months ago

Kralg commented 6 months ago

Hello, I try to read GPIO from python CLI but with command I get warning and no output: $ ./meshtastic --gpio-rd 0x2000 --dest 2860018834 Connected to radio Reading GPIO mask 0x2000 from 2860018834 Warning: NodeId 2860018834 not found in DB

With ./meshtastic --info Owner: Meshtastic 6c92 (6c92) My info: { "myNodeNum": 2860018834, "minAppVersion": 30200 }

Can you advice what can be wrong here?

GUVWAF commented 6 months ago

Can you try with the NodeID format with "!", so "!aa786c92" in your case? Or else --dest "^local"?

Kralg commented 6 months ago

Thanks both work. Do you know how can I trigger the remoteHardware module handling commands sent over textMessages?

GUVWAF commented 6 months ago

Unfortunately that's not possible.

Kralg commented 6 months ago

I saw you are involved in firmware. I am pretty new to this. Can you please write why the remoteHardwareModule is not added to modules vector the same as textMessageModule?

I am thinking that also I might be able to write a custom parser of message in _ProcessMessage TextMessageModule::handleReceived(const meshtasticMeshPacket &mp) and handle custom way the GPIOs. Do you think that could break any other logic?

One more thing do you know how could I create a response from _ProcessMessage TextMessageModule::handleReceived(const meshtasticMeshPacket &mp) in case I would like to respond to parsed message?

GUVWAF commented 6 months ago

Can you please write why the remoteHardwareModule is not added to modules vector the same as textMessageModule?

Hmm, I think it is, each class derived from MeshModule is added to it, because this happens in the constructor: https://github.com/meshtastic/firmware/blob/a085c3ddb334fb4977f68980ebd2ef79e625c861/src/mesh/MeshModule.cpp#L25

I am thinking that also I might be able to write a custom parser of message in ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp) and handle custom way the GPIOs.

Yes, that might work. It would be dangerous to add this in the default firmware as you don't necessarily want anyone (accidentally) controlling your GPIOs.

One more thing do you know how could I create a response from ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp) in case I would like to respond to parsed message?

You would need to create the allocReply() method, similar to the ReplyModule: https://github.com/meshtastic/firmware/blob/a085c3ddb334fb4977f68980ebd2ef79e625c861/src/modules/ReplyModule.cpp#L8