-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/at86rf215: implement battery monitor, add power bus #14973
Conversation
I don't like msg_bus for these much. IIUC, under the hood, they msg_try_send each bus message. And then return the number of successful deliveries. If delivery is of any importance, the sender would need to actually check this number, and compare it to the number of subscribers, (which there's no API that gets it), then handle the result somehow. This is a recipe for disaster (unreliable software), as messages will just get lost, should the receiver msg queue be full (or not available and the receiver not waiting). "Yeah man this is just for the battery low led" -> well... This is a fundamental issue with asynchronous messages and statically allocated message queues, as the messages are receiver allocated, but the events are created at the sender side and might, depending on what else is going on in the system, pile up. There are better (but less intuitive) alternatives. IMO catching the events is important, but passing them via msg_bus is not ideal. For lack of (working) alternative code, I'm ok to go forward with this, if we add big warnings on the messages-are-not-guaranteed-to-arrive issue. |
:-'D |
99c9353
to
a9e03fa
Compare
I wonder if this |
Good question, the 'power bus' provides a mechanism to get notified about such evens, but no means to configure them. But this could be hidden behind a generic API where the user does not need to care what provides the battery monitor. SAUL could indeed be a good fit here. Afaik it has no concept of generating events yet, but #14182 was set to address that. |
Can you rebase @benpicco ? |
a9e03fa
to
ffc3101
Compare
Rebased & changed it to use |
Many radios have a built-in battery monitor. Add a netopt to configure it.
ffc3101
to
dbdd9d7
Compare
Doesn't this bloat even more the |
@benpicco can you provide some fresh test output? |
I understand in the mentioned comment it is mentioned that |
|
Thanks, this one is good to go IMO once the NETOPT things get's OK'ed |
I can guard the NETOPS for the 802.15.4 modes / LoRa etc with I think the batmon netopt makes sense since a couple of radios have it. |
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.
ACK, there have been no complaints on the NETOPT
usage, and it was suggested by @jia200x who is quite active as a network maintainer, so I'll take that as the usage being OK.
I can guard the NETOPS for the 802.15.4 modes / LoRa etc with #ifdefs as a follow up.
That should save a good amount of space already.
+1 for this as a follow up.
Contribution description
The at86rf215 can generate an interrupt if the supply voltage falls below a certain level.
Since such an event can have multiple consumers, a new system power bus is introduced.
Threads interested in power events can subscribe to it and will all be notified in case of an event.
New bus types for different event categories can be added in the future.
Testing procedure
Run
tests/driver_at86rf215
on a board with the radio connected.You can configure a battery monitor threshold (in mV) with
If you configure a threshold that is above the supply voltage, a battery monitor event should be triggered immediatly.
Issues/PRs references
split off #12128