Dissertation project, looking at BLE communication in cars. This project is BLE peripheral acting as car indicator stalk
Dependencies: BLE_API mbed nRF51822
Fork of BLE_GATT_test1 by
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