Example of BLE scan/connect/service discovery
Fork of BLE_LEDBlinker by
Revision 3:146eba831693, committed 2015-06-08
- Comitter:
- rgrover1
- Date:
- Mon Jun 08 06:37:03 2015 +0000
- Parent:
- 2:3e1e967035cb
- Child:
- 4:460ce53dc854
- Commit message:
- rename led1 as alivenessLED.; And some minor addition to comments.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jun 08 06:30:35 2015 +0000
+++ b/main.cpp Mon Jun 08 06:37:03 2015 +0000
@@ -20,13 +20,13 @@
#include "DiscoveredService.h"
BLEDevice ble;
-DigitalOut led1(LED1);
+DigitalOut alivenessLED(LED1, 1);
bool triggerLedCharacteristic = false;
DiscoveredCharacteristic ledCharacteristic;
void periodicCallback(void) {
- led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
+ alivenessLED = !alivenessLED; /* Do blinky on LED1 while we're waiting for BLE events */
}
void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params) {
@@ -98,7 +98,6 @@
}
int main(void) {
- led1 = 1;
Ticker ticker;
ticker.attach(periodicCallback, 1);
@@ -106,6 +105,8 @@
ble.onConnection(connectionCallback);
ble.onDisconnection(disconnectionCallback);
+ /* Request for comments: should setupOnDataRead() be a static for DiscoveredCharacteristic?
+ * Or should it be passed in as a parameter to read()? */
DiscoveredCharacteristic::setupOnDataRead(triggerToggledWrite);
DiscoveredCharacteristic::setupOnDataWrite(triggerRead);
