-
Notifications
You must be signed in to change notification settings - Fork 116
Add example exercising the GattClient API. #111
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
Conversation
@apalmieriGH @marcbonnici Could you review the code of this example. It doesn't work on NRF based targets due to a timing issue and it works on Nucleo targets with the help of this patch: ARMmbed/ble-x-nucleo-idb0xa1#33 |
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.
The code itself looks fine to me.
BLE_GattClient/README.md
Outdated
@@ -0,0 +1,32 @@ | |||
# BLE Gatt Client example | |||
|
|||
This application demonstrate detailed uses of the GattClient APIs. |
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.
"demonstrate" -> "demonstrates"
BLE_GattClient/README.md
Outdated
|
||
This application demonstrate detailed uses of the GattClient APIs. | ||
|
||
When the application is started it advertise itself to its environment with the |
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.
"advertise" -> "advertises"
BLE_GattClient/README.md
Outdated
This application demonstrate detailed uses of the GattClient APIs. | ||
|
||
When the application is started it advertise itself to its environment with the | ||
device name `GattClient`. Once you connected the device with your mobile phone, |
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.
"you connected the" -> "you have connected to the" or "you connect to the" ?
BLE_GattClient/README.md
Outdated
discovered and subscribes to the characteristics emitting notifications or | ||
indications. | ||
|
||
The device print the value of any indication or notification received from the |
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.
"print" -> "prints"
BLE_GattClient/README.md
Outdated
|
||
## Requirements | ||
|
||
You may us a generic BLE scanners: |
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.
"us" -> "use"
"scanners" -> "scanner"
BLE_GattClient/main.cpp
Outdated
*/ | ||
void when_service_discovered(const DiscoveredService *discovered_service) | ||
{ | ||
// print informations of the service discovered |
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.
"informations" -> "information"
/** | ||
* Handle characteristics discovered. | ||
* | ||
* The GattClient invoke this function when a characteristic has been |
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.
"invoke" -> "invokes"
BLE_GattClient/main.cpp
Outdated
/** | ||
* Handle termination of the service and characteristic discovery process. | ||
* | ||
* The GattClient invoke this function when a the service and characteristic |
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.
"invoke" -> "invokes"
Remove "a" from "a the service"
BLE_GattClient/main.cpp
Outdated
}; | ||
|
||
/** | ||
* Handle initialization adn shutdown of the BLE Instance. |
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.
"adn" -> "and"
BLE_GattClient/main.cpp
Outdated
} | ||
|
||
/** | ||
* Stop the gatt client process when a the device is disconnected then |
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.
"when a the device disconnected" -> "when a device disconnects"
@marcbonnici Thanks for the review; I have addressed your comments. |
@pan- very useful example, it is good for me. |
@nvlsianpu There is some faillure on NRF targets with that example; the issue seems located in the client class. Could you look after those ? |
@paul-szczepanek-arm Could you review this example ? |
BLE_GattClient/main.cpp
Outdated
*/ | ||
void process_next_characteristic(void) | ||
{ | ||
if (_it == 0) { |
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 (_it == NULL) {
alternatively reverse order of the if else to avoid comparing to NULL, I'm just complaining about using 0 for pointer comparison
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.
I agree we have to be consistent; even if the meaning is exactly the same in C++ (NULL is an integer that evaluate to 0).
However we do not use the yoda notation in our code.
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.
I didn't mean reverse the order of the variables in the if I meant reverse the if statements:
if (_it) {
_it = _it->next;
} else {
_it = _characteristics;
}
Yoda either I do not like.
BLE_GattClient/main.cpp
Outdated
|
||
events::EventQueue &_event_queue; | ||
BLE &_ble_interface; | ||
GattClientProcess gatt_client_process; |
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.
missing _ prefix from private var
BLE_GattClient/main.cpp
Outdated
return; | ||
} | ||
|
||
gap.setAdvertisingParams(make_advertising_params()); |
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.
I'm getting mixed messages here, the API doc says: "It would be uncommon for this API to be used directly; there are other APIs to tweak advertisement parameters individually" yet we use it in examples?
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.
That comment has been removed from the Gap
class; unfortunatelly it is still present in the BLE
class but the member function is deprecated.
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.
review concluded offline with agreement to separate/hide the gap part
@nvlsianpu Any update ? |
@paul-szczepanek-arm I've updated the PR accordingly to your comments; Could you review the changes ? |
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.
you appear to have reverted a few minor fixes in the last commit (diff with last)
BLE_GattClient/BLEProcess.h
Outdated
} | ||
|
||
/** | ||
* Stop the gatt client process when a the device is disconnected then |
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.
"a the" -> "the"
I think this is good to go; @paul-szczepanek-arm @donatieng What do you think ? |
merge |
Add example exercising the GattClient API.
The example demonstrate uses of:
TODO
Improve the documentation