Repository navigation
fix: accept pure decimal node IDs in CLI #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -991,20 +991,44 @@ def _sendPacket( | |
| nodeNum = self.myInfo.my_node_num | ||
| else: | ||
| our_exit("Warning: No myInfo found.") | ||
| # A simple hex style nodeid - we can parse this without needing the DB | ||
| elif isinstance(destinationId, str) and len(destinationId) >= 8: | ||
| # assuming some form of node id string such as !1234578 or 0x12345678 | ||
| # always grab the last 8 items of the hexadecimal id str and parse to integer | ||
| nodeNum = int(destinationId[-8:], 16) | ||
| else: | ||
| if self.nodes: | ||
| node = self.nodes.get(destinationId) | ||
| if node is None: | ||
| our_exit(f"Warning: NodeId {destinationId} not found in DB") | ||
| elif isinstance(destinationId, str): | ||
| parsed = False | ||
| if destinationId.startswith("!") or destinationId.lower().startswith("0x"): | ||
| try: | ||
| val_str = destinationId.lstrip("!").lower() | ||
| if val_str.startswith("0x"): | ||
| val_str = val_str[2:] | ||
| if len(val_str) > 8: | ||
| val_str = val_str[-8:] | ||
| nodeNum = int(val_str, 16) | ||
| parsed = True | ||
| except ValueError: | ||
| pass | ||
| elif destinationId.isdigit(): | ||
| try: | ||
| if len(destinationId) == 8: | ||
| nodeNum = int(destinationId, 16) | ||
| else: | ||
| nodeNum = int(destinationId) | ||
| parsed = True | ||
| except ValueError: | ||
| pass | ||
| elif len(destinationId) >= 8: | ||
| try: | ||
| nodeNum = int(destinationId[-8:], 16) | ||
| parsed = True | ||
| except ValueError: | ||
| pass | ||
|
|
||
| if not parsed: | ||
| if self.nodes: | ||
| node = self.nodes.get(destinationId) | ||
| if node is None: | ||
| our_exit(f"Warning: NodeId {destinationId} not found in DB") | ||
| else: | ||
| nodeNum = node["num"] | ||
| else: | ||
| nodeNum = node["num"] | ||
| else: | ||
| logger.warning("Warning: There were no self.nodes.") | ||
| logger.warning("Warning: There were no self.nodes.") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Stop sending when the node database is unavailable. If parsing fails while 🤖 Prompt for AI Agents |
||
|
|
||
| meshPacket.to = nodeNum | ||
| meshPacket.want_ack = wantAck | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Parse eight-digit decimal destinations as decimal.
If a user supplies
12345678, this branch sends to0x12345678instead of node12345678. The numeric path does not check the node database, so it can send to the wrong node. Parse every prefix-less digit-only destination as decimal. Require!or0xfor hexadecimal digits, and update the assertion at Line 467 inmeshtastic/tests/test_mesh_interface.py. The PR objective specifies decimal parsing for prefix-less decimal inputs.🤖 Prompt for AI Agents