[script] Credential QR Code and Node Diagram#345
[script] Credential QR Code and Node Diagram#345rochaferraz wants to merge 7 commits intoopenthread:mainfrom
Conversation
|
/gemini review |
Summary of ChangesHello @rochaferraz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances Thread network management by introducing two new Python utility scripts. One script streamlines the provisioning process by enabling the conversion of Thread operational datasets into a QR code format, facilitating quick device setup and credential sharing. The other script provides a powerful visualization tool, allowing users to graphically inspect the topology of a Thread mesh network, which is crucial for understanding network structure, identifying relationships between nodes, and assessing link quality. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two new utility scripts: qrcreds for converting Thread Operational Datasets to and from QR code strings and generating PNGs, and node_diagram for visualizing Thread mesh networks. The qrcreds script provides useful functionality for provisioning, while node_diagram offers a clear visual representation of network topology. The test_qrcreds.py file adds unit tests for the qrcreds script, which is a good practice. Overall, the new scripts add valuable tools for Thread network management and visualization.
There was a problem hiding this comment.
Code Review
This pull request introduces two useful utility scripts: qrcreds for handling Thread credential QR codes and node_diagram for visualizing the mesh network. The code is well-structured and includes tests for qrcreds.
My review focuses on improving the command-line interface behavior of these scripts. I've suggested changes to ensure error messages are consistently sent to stderr, which is a standard practice that improves usability in shell pipelines. I also recommended adding a warning for malformed input in qrcreds to make it more robust and user-friendly.
- Align TLV type codes with MeshCoP standard: - Channel: 0x01 -> 0x00 - PAN ID: 0x02 -> 0x01 - Ext PAN ID: 0x03 -> 0x02 - Network Name: 0x04 -> 0x03 - PSKc: Added as Type 0x04 - Network Key: 0x05 (Unchanged) - Add optional fields to QR format: - Border Agent ID (B) - e-PSKc (R) - e-PSKc Expiry (X) - Make PAN ID or Ext PAN ID mandatory in QR code. - Canonicalize Channel TLV to compact 1-byte format where possible. - Update unit tests to reflect new TLV mappings and verify PSKc round trip.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- Replace sys.exit(1) with ValueError/RuntimeError in core functions: - tlv_to_qr: Raises ValueError on invalid hex. - qr_to_tlv: Raises ValueError on invalid start prefix. - generate_png: Raises RuntimeError if qrcode lib is missing. - qr_to_tlv: Prints stderr warning for malformed tokens instead of silent continue. - Centralize exception handling in main(). - Update unit tests: - Verify ValueError is raised instead of SystemExit. - Add test_channel_consistency for compact/standard TLV canonicalization. - Add test_malformed_token_warning coverage.
| args = parser.parse_args() | ||
|
|
||
| # Pass the filepath argument into the function | ||
| generate_mesh_visualization(args.filepath) No newline at end of file |
There was a problem hiding this comment.
nit: add a newline at the end of the file
| Wi-Fi network credentials ("WIFI:"). | ||
|
|
||
| Format Structure: | ||
| THREAD:S:<Network Name>;P:<Network Key>;I:<PAN ID>;E:<Ext PAN ID>;C:<Channel>;B:<Border Agent ID>;K:<PSKc>;R:<e-PSKc>;X:<e-PSKc Expiry>;; |
There was a problem hiding this comment.
This format is a bit complicated and not easy to extend in the future.
What about having just the operational dataset TLV hex string? E.g. THREAD:0e08000000000001000000030000104a0300000e35060004001fffe0020815aacecfc1bb71e90708fdb6944646f04bcd0510d81a7de488e95f599c9705122961431b030f4f70656e5468726561642d3064396501020d9e0410c0c06aff5e80f06acbc6054a6201d3410c0402a0f7f8
This PR introduces two new utility scripts to assist with Thread network provisioning and visualization.
script/qrcreds: A tool for converting Thread Operational Datasets between TLV hex strings and a custom QR code string format (similar to WiFi QR codes). It also supports generating PNG QR code images for easy device provisioning.script/node_diagram: A visualization tool that parses network traversal JSON data to generate a visual graph of the Thread mesh topology using networkx and matplotlib.Key Features:
QR Code Generation: Create
THREAD:S:...MeCard-like QR Strings and PNGs from a dataset TLV.Credential Parsing: Decode scanned QR strings back into raw TLV hex for use with the commissioner.
Network Visualization: Visualize the parent-child and router-neighbor relationships within the Thread mesh.
Usage Examples:
Generate a QR code from a TLV dataset:
Parse a QR payload string:
Visualize a mesh from traverse_output.json: