Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed BLE_API nRF51822
Revision 23:52e8e05df60c, committed 2019-03-07
- Comitter:
- vazbyte
- Date:
- Thu Mar 07 14:18:32 2019 +0000
- Parent:
- 22:406127954d1f
- Commit message:
- workss;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 09 17:08:47 2015 +0000
+++ b/main.cpp Thu Mar 07 14:18:32 2019 +0000
@@ -6,7 +6,7 @@
uint16_t readCharUUID = 0xA001;
uint16_t writeCharUUID = 0xA002;
-const static char DEVICE_NAME[] = "ChangeMe!!"; // change this
+const static char DEVICE_NAME[] = "OCCUPY-CRICHTON-ST"; // change this
static const uint16_t uuid16_list[] = {0xFFFF}; //Custom UUID, FFFF is reserved for development
/* Set Up custom Characteristics */
@@ -20,7 +20,6 @@
GattCharacteristic *characteristics[] = {&readChar, &writeChar};
GattService customService(customServiceUUID, characteristics, sizeof(characteristics) / sizeof(GattCharacteristic *));
-
/*
* Restart advertising when phone app disconnects
*/
@@ -29,9 +28,6 @@
BLE::Instance(BLE::DEFAULT_INSTANCE).gap().startAdvertising();
}
-/*
- * Handle writes to writeCharacteristic
-*/
void writeCharCallback(const GattWriteCallbackParams *params)
{
/* Check to see what characteristic was written, by handle */
@@ -81,10 +77,10 @@
/* Start advertising */
ble.gap().startAdvertising();
}
+void wakeup_event_cb() {
+ led != led;
+}
-/*
- * Main loop
-*/
int main(void)
{
/* initialize stuff */
@@ -93,12 +89,12 @@
BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE);
ble.init(bleInitComplete);
- /* SpinWait for initialization to complete. This is necessary because the
- * BLE object is used in the main loop below. */
- while (ble.hasInitialized() == false) { /* spin loop */ }
-
- /* Infinite loop waiting for BLE interrupt events */
- while (true) {
+ Ticker ticker;
+ int counter = 0;
+ ticker.attach(wakeup_event_cb, 0.3);
+ while (ble.hasInitialized()) {
+ counter++;
+ printf("hello %i!\n", counter);
ble.waitForEvent(); /* Save power */
}
}
\ No newline at end of file