-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add Link Loss Service #14
Conversation
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.
Good work, please fill out the doxy.
We need to decide on some common folder structure for the service files. @pan- @AGlass0fMilk ? |
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.
Thanks for the submission @noonfom .
One thing: as a general rule of thumb consider doing in class initialization for class variables that do not depend on the constructor, in this case _event_queue_handle
, _alert_timeout
, ...
fb1f2c9
to
ddc20f6
Compare
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.
We're almost there, we just need to cleanup the value of _event_queue_handle
when it is cancelled (or triggered).
ddc20f6
to
6eac2a4
Compare
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.
Just a couple more issues and please add an mbed_lib.json, see:
#15
services/inc/LinkLossService.h
Outdated
* The on_alert_requested() and on_alert_end() event handlers should be overridden | ||
* by your application. For example, in the former case, you could alert the user by | ||
* flashing lights, making noises, moving, etc. | ||
* |
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.
* | |
* This service requires access to gap events. Please register a ChainableGapEventHandler with Gap and pass it to this service. |
void LinkLossService::onDisconnectionComplete(const ble::DisconnectionCompleteEvent &event) | ||
{ | ||
AlertLevel level = get_alert_level(); | ||
if (_alert_handler != nullptr && event.getReason() == ble::disconnection_reason_t::CONNECTION_TIMEOUT && level != AlertLevel::NO_ALERT) { |
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.
if (_alert_handler != nullptr && event.getReason() == ble::disconnection_reason_t::CONNECTION_TIMEOUT && level != AlertLevel::NO_ALERT) { | |
if (_alert_handler != nullptr && event.getReason() == ble::disconnection_reason_t::CONNECTION_TIMEOUT && level != AlertLevel::NO_ALERT && !_in_alert) { |
{ | ||
const uint8_t level = *write_request->data; | ||
|
||
if (level <= *reinterpret_cast<uint8_t *>(AlertLevel::HIGH_ALERT)) { |
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.
if (level <= *reinterpret_cast<uint8_t *>(AlertLevel::HIGH_ALERT)) { | |
if (level <= static_cast<uint8_t>(AlertLevel::HIGH_ALERT)) { |
abe8dc4
to
4c3494f
Compare
e474742
to
8ee4f22
Compare
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.
Minor change request when invalid data are written from a peer.
After this it should be good to go.
|
||
if (level <= (uint8_t)(AlertLevel::HIGH_ALERT)) { | ||
set_alert_level((AlertLevel) level); | ||
} |
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.
Could you return an error if the alert is out of range ?
* Add Link Loss Service * Set auth reply if alert level is out of range
The Link Loss Service uses the Alert Level characteristic, as defined in the Bluetooth SIG Assigned Numbers, to cause an
alert in the device when the link is lost.
Reviewers
@pan-
@paul-szczepanek-arm