Skip to content

Conversation

@Littleaton
Copy link

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.

--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>
Copy link
Contributor

@ianmcorvidae ianmcorvidae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +486 to +491
def request_user_info(
self,
destinationId: Union[int, str],
wantResponse: bool = True,
channelIndex: int = 0,
) -> mesh_pb2.MeshPacket:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should match the others here in MeshInterface. In particular, it should probably be called sendUser.

Comment on lines +1917 to +1928
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",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have this be available as --send-user as well, to match the protobuf name more closely.

Suggested change
"--send-userinfo",
"--send-userinfo", "--send-user",

)

group.add_argument(
"--request-userinfo",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have this as --request-user too, to match the protobuf name.

Suggested change
"--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"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_unmessagable flag should be included here.

Suggested change
if "isUnmessagable" in node_user:
user.is_unmessagable = node_user["isUnmessagable"]

Comment on lines +1372 to +1379

# 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants