Send request broadcast userinfo#846
Conversation
--broadcast-userinfo Broadcasts to ALL nodes One-way (no response expected) Ignores --dest parameter --request-userinfo Sends to specific node (requires --dest) Two-way (expects response back) Request-response communication --send-userinfo Sends to specific node (requires --dest) One-way (no response expected) Point-to-point communication So if you want to: Send to everyone: use --broadcast-userinfo Get info back from someone: use --request-userinfo --dest <nodeid> Send to someone without reply: use --send-userinfo --dest <nodeid>
ianmcorvidae
left a comment
There was a problem hiding this comment.
Got a few requested changes, but appreciate you doing the work here. Been wanting to add this for a while and had basically no time to devote to it.
| def request_user_info( | ||
| self, | ||
| destinationId: Union[int, str], | ||
| wantResponse: bool = True, | ||
| channelIndex: int = 0, | ||
| ) -> mesh_pb2.MeshPacket: |
There was a problem hiding this comment.
This function should match the others here in MeshInterface. In particular, it should probably be called sendUser.
| group.add_argument( | ||
| "--broadcast-userinfo", | ||
| help="Broadcast your user information to all nodes in the mesh network.", | ||
| action="store_true", | ||
| ) | ||
|
|
||
| group.add_argument( | ||
| "--send-userinfo", | ||
| help="Send your user information to a specific node without requesting a response. " | ||
| "Must be used with --dest to specify the destination node.", | ||
| action="store_true", | ||
| ) |
There was a problem hiding this comment.
I don't see a reason to have these two as separate flags; I think they can both be under --send-userinfo, and simply broadcast when a --dest is not provided.
| ) | ||
|
|
||
| group.add_argument( | ||
| "--send-userinfo", |
There was a problem hiding this comment.
Let's have this be available as --send-user as well, to match the protobuf name more closely.
| "--send-userinfo", | |
| "--send-userinfo", "--send-user", |
| ) | ||
|
|
||
| group.add_argument( | ||
| "--request-userinfo", |
There was a problem hiding this comment.
Let's have this as --request-user too, to match the protobuf name.
| "--request-userinfo", | |
| "--request-userinfo", "--request-user", |
| # Handle public key - firmware strips it if node is licensed | ||
| if "public_key" in node_user and not user.is_licensed: | ||
| user.public_key = node_user["public_key"] | ||
|
|
There was a problem hiding this comment.
The is_unmessagable flag should be included here.
| if "isUnmessagable" in node_user: | |
| user.is_unmessagable = node_user["isUnmessagable"] |
|
|
||
| # Track if this is a response to our user info request | ||
| node_num = asDict["nodeInfo"]["num"] | ||
| if "user" in asDict["nodeInfo"]: | ||
| node_id = asDict["nodeInfo"]["user"].get("id", "") | ||
| logger.debug(f"Received node info from node {node_id} (num: {node_num})") | ||
|
|
||
| node = self._getOrCreateByNum(node_num) |
There was a problem hiding this comment.
This doesn't belong here. The FromRadio field node_info is for nodeinfo sent from the nodedb to the client on startup; you won't get this for responses to requests over the air.
| # Track if this is a response to our user info request | |
| node_num = asDict["nodeInfo"]["num"] | |
| if "user" in asDict["nodeInfo"]: | |
| node_id = asDict["nodeInfo"]["user"].get("id", "") | |
| logger.debug(f"Received node info from node {node_id} (num: {node_num})") | |
| node = self._getOrCreateByNum(node_num) | |
| node = self._getOrCreateByNum(asDict["nodeInfo"]["num"]) |
Summary
Added new actions/arguments to send nodedb.
This should be exactly what the android app does when using exchanging user info option on node details
Motivation
I wanted a way to help troubleshoot new nodes on seeing my node in the mesh, as well as a way to quickly populate / add my node to new nodes nodedb.
Example Usage
Send to everyone: meshtastic --broadcast-userinfo
Send to someone and expect reply back: meshtastic --request-userinfo --dest
Send to someone without reply: meshtastic --send-userinfo --dest
Impact
I am not aware of any issues that adding this would cause but may need further testing on other devices.