-
Notifications
You must be signed in to change notification settings - Fork 239
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
[rest] Add REST JSON:API for commissioner and diagnostics #2514
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2514 +/- ##
===========================================
- Coverage 55.77% 37.13% -18.65%
===========================================
Files 87 135 +48
Lines 6890 15993 +9103
Branches 0 1316 +1316
===========================================
+ Hits 3843 5939 +2096
- Misses 3047 9707 +6660
- Partials 0 347 +347 ☔ View full report in Codecov by Sentry. |
Happy to discuss thoughts and improvements. Note: we will add a commit fixing the broken topology browser in otbr-web service asap. |
It looks #2515 is also adding the REST commissioner API. |
@martinzi Thanks for this contribution! But this PR is about 12K lines of change that it's too hard to review. Could you help split this PR by creating a separate smaller PR for each feature? For example, one PR for commissioner API and another PR for network diagnostic. |
Agree, it became quite large. See a first part split into PR2517. More to follow ... |
6c1622b
to
d2f1ef1
Compare
…by indirect 'addThreadDeviceTask' processing This commit implements - POST `addThreadDeviceTask` on api/actions/ - GET api/actions/<actionId> - DELETE api/actions The commit also provides integration tests, see tests/restjsonapi. Please follow the following steps to install/build OTBR. 1. Checkout this PR 2. Build and Install OTBR as usual, e.g. on a Raspberry Pi 3. Restart the OTBR. `sudo systemctl restart otbr-agent` 4. To monitor the log [Errors|Warnings|Info] please open a different terminal instance and use following command: ``` tail -f /var/log/syslog | grep otbr ``` 5. Send POST request using BRUNO or CURL, e.g. to join a new device into your network. ``` curl -X POST -H 'Content-Type: application/vnd.api+json' http://localhost:8081/api/actions -d '{"data": [{"type": "addThreadDeviceTask", "attributes": {"eui": "6234567890AACDEA", "pskd": "J01NME", "timeout": 3600}}]}' | jq ``` should return ``` { "data": [ { "id": "2d5a8844-b1bc-4f02-93f0-d87b8c3b4e92", "type": "addThreadDeviceTask", "attributes": { "eui": "6234567890AACDEB", "pskd": "J01NME", "timeout": 3600, "status": "pending" }, } ] } ``` 6. You may check the status and get the full collection of actions. ``` curl -X GET -H 'Accept: application/vnd.api+json' http://localhost:8081/api/actions | jq ``` should return ``` { "data": [ { "id": "2d5a8844-b1bc-4f02-93f0-d87b8c3b4e92", "type": "addThreadDeviceTask", "attributes": { "eui": "6234567890AACDEB", "pskd": "J01NME", "timeout": 3600, "status": "pending" } } ], "meta": { "collection": { "offset": 0, "limit": 100, "total": 1 } } } ``` 7. View the entry added to the commissioner's table `sudo ot-ctl commissioner joiner table` and expect ``` | ID | PSKd | Expiration | +-----------------------+----------------------------------+------------+ | 6234567890aacdea | J01NME | 3459027 | Done ``` 8. Start your joiner and after a few seconds repeat above steps 6. and 7. 9. For running the included test script install Bruno-Cli and run the bash script on your border router ``` cd tests/restjsonapi source ./install_bruno_cli ./test-restjsonapi-server ```
- Adapt test_rest.py for moving to camelCase naming convention following https://jsonapi.org/recommendations/. - limit README.md to api/actions and add_thread_device action
4406313
to
5627bd7
Compare
…very providing api/devices, and diagnostic results api/diagnostics This commit implements following parts: - api/node - api/devices . GET; POST for discovery and update of collection - api/actions . getNetworkDiagnosticsTask . resetNetworkDiagCounterTask . getEnergyScanTask - api/diagnostics . networkDiagnostic . energyScanReport The commit also provides integration tests, see tests/restjsonapi. For more details see Readme in src/rest.
5627bd7
to
1d140d7
Compare
In this PR, we propose an extended
REST
API functionality providing capabilities for commissioning and on-mesh diagnostics to generic off-mesh http clients. The implementation is guided by the JSON:API specification and provides following partsapi/node
- pointing to api/devices/thisdeviceapi/devices
- a collection of discovered devicesapi/actions
- indirect processing of tasks, in particular for those that may need more timeaddThreadDeviceTask
- starts the on-mesh commissioner and adds the joiner candidate into the joiner tablegetNetworkDiagnosticTask
- sends diagnostic requests and diagnostic queries to the destinationresetNetworkDiagCounterTask
- resets the network diagnostic mle and/or mac countergetEnergyScanTask
- starts the commissioner and sends energy scan requests to the destinationapi/diagnostics
The PR provides integration tests for local validation, see tests/restjsonapi.
The Readme provides more details and descriptions in src/rest/README.md.