Demo for the Tx Power service
Dependencies: BLE_API mbed nRF51822
Demo for the Tx Power service (included in the services folder). i kept the service format the same as the official mbed libraries.
Diff: main.cpp
- Revision:
- 0:1d89681580f2
- Child:
- 1:c856cfe550a7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 15 17:54:09 2014 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "BLEDevice.h" +#include "TxPower.h" + +BLEDevice ble; + +void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) +{ + ble.startAdvertising(); // restart advertising +} + +int main() { + + ble.init(); + ble.onDisconnection(disconnectionCallback); + + TxPowerService(ble, -30); + + ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); + ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); + ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000)); + ble.startAdvertising(); + + while (true) { + + ble.waitForEvent(); + + } + +}