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: BLE_API mbed nRF51822
Diff: main.cpp
- Revision:
- 5:b3f8e10b9602
- Parent:
- 4:ac0ee88ea0ed
- Child:
- 6:1d7e5fcc8d00
--- a/main.cpp Tue Feb 17 15:57:48 2015 +0000
+++ b/main.cpp Tue Feb 17 17:11:18 2015 +0000
@@ -17,11 +17,13 @@
/*Variable Declarations*/
const static char DEVICE_NAME[] = "BLE_Broadcaster";
-static volatile bool connected;
+static volatile bool go = false;
void blink(void)
{
led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
+ go = true;
+
}
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
@@ -83,24 +85,17 @@
while(true) {
ble.waitForEvent(); // this will return upon any system event (such as an interrupt or a ticker wakeup)
-
- if(x) {
- pc.printf("Command = %u\r\n", cmdOn);
- broadcasterService.sendCommand(cmdOn);
- x = false;
- } else {
- pc.printf("Command = %u\r\n", cmdOff);
- broadcasterService.sendCommand(cmdOff);
- x = true;
+ if(go) {
+ if(x) {
+ pc.printf("Command = %u\r\n", cmdOn);
+ broadcasterService.sendCommand(cmdOn);
+ x = false;
+ } else {
+ pc.printf("Command = %u\r\n", cmdOff);
+ broadcasterService.sendCommand(cmdOff);
+ x = true;
+ }
+ go = false;
}
-
- //testCommand++;
-
- //if (testCommand > 100) {
-// testCommand = 0;
-// }
-//
-// pc.printf("Level = %u\r\n", testCommand);
-// testService.sendCommand(testCommand);
}
}
\ No newline at end of file