v2
Dependencies: BLE_API mbed DOOR
Fork of DOOR by
Diff: main.cpp
- Revision:
- 67:81b595625ce0
- Parent:
- 60:3034dc913ea1
- Child:
- 68:4a8fdfe70ab3
--- a/main.cpp Mon May 18 09:07:16 2015 +0000 +++ b/main.cpp Wed Oct 21 18:49:02 2015 +0000 @@ -16,6 +16,7 @@ #include "mbed.h" #include "iBeaconService.h" +#include "UARTService.h" /** * For this demo application, populate the beacon advertisement payload @@ -26,6 +27,7 @@ */ BLEDevice ble; +UARTService *uart; /** * The Beacon payload has the following composition: @@ -42,11 +44,39 @@ uint16_t majorNumber = 1122; uint16_t minorNumber = 3344; uint16_t txPower = 0xC8; +DigitalOut led1(P0_5); + +void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason); +void onDataWritten(const GattCharacteristicWriteCBParams *params); + +void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) +{ + ble.startAdvertising(); +} + +void onDataWritten(const GattCharacteristicWriteCBParams *params) +{ + // TODO - this stuff will need to be retrofitted to deal with string commands + if(*params->data == 0x33){ + led1 = 0; + } + else if(*params->data == 0x34){ + led1 = 1; + } + +} int main(void) { + led1=1; + ble.init(); - + + ble.onDisconnection(disconnectionCallback); + ble.onDataWritten(onDataWritten); + + + uart = new UARTService(ble); iBeaconService ibeacon(ble, uuid, majorNumber, minorNumber, txPower); ble.setAdvertisingInterval(1000); /* 1000ms. */