-
Notifications
You must be signed in to change notification settings - Fork 18
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
LQI and RSSI sensors for some devices #153
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #153 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 758 779 +21
=========================================
+ Hits 758 779 +21
☔ View full report in Codecov by Sentry. |
Rebased and added tests |
puddly
requested changes
Oct 9, 2023
Co-authored-by: puddly <32534428+puddly@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds LQI and RSSI sensors to certain devices.
Problem:
The XBee API does not provide an API to directly measure LQI of a zigbee packet. There is
DB
(Last Packet RSSI) AT command that measures the RSSI of a last received packet, but0x91 Explicit Receive Indicator
API frame is missing the address of the last hop node, so it is not clear to which device the RSSI is related. It also lacks the LQI or RSSI info. There isND
(Network Discovery) AT command which can provide the RSSI of a node, but this only works for other XBee devices and not any Zigbee device. There is alsoAS
(Active Scan) AT command which provides both LQI and RSSI information, but the active scan ignores the network topology and thus useless, it does not also work on end devices because they are sleeping nodes an don't respond to the scan.But not all hope is lost.
Solution:
Instead o relying on the API, we will use ZDO. In fact, we already do all the needed ZDO requests for the topology scan. All e need is to listen and interpret the results. The sensor values will be updated as often as the topology scan is run (every hours by default and min 20 minutes).
LQI: As part of topology scanning we do a neighbors scan from all routers by sending
Mgmt_Lqi_req
. The response is a table of neighbors, including their relationship and LQI. If a neighbor is a parent, then we save the LQI for the device that responded, and if a neighbor is a child, then we save the LQI for the child. Siblings and other devices are ignored.Limitation: Because the XBee devices don't handle well self-addressed ZDO requests, this does not work for end devices that are immediate children of the coordinator.
RSSI: For the topology scan we also request the route information from the routers, by sending
Mgmt_Rtg_req
ZDO request. The response is a list of routes from the node. If that response contains a direct route to the coordinator, we realize it is the last hop, so we immediately execute theDB
AT command and save the RSSI value.Limitation: This technique only works for routers that are direct children of the coordinator.