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.

Committer:
KarimAzzouz
Date:
Mon Dec 15 18:17:52 2014 +0000
Revision:
1:c856cfe550a7
Parent:
0:1d89681580f2
added the updateTxPower method to the example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KarimAzzouz 0:1d89681580f2 1 #include "mbed.h"
KarimAzzouz 0:1d89681580f2 2 #include "BLEDevice.h"
KarimAzzouz 0:1d89681580f2 3 #include "TxPower.h"
KarimAzzouz 0:1d89681580f2 4
KarimAzzouz 0:1d89681580f2 5 BLEDevice ble;
KarimAzzouz 0:1d89681580f2 6
KarimAzzouz 0:1d89681580f2 7 void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
KarimAzzouz 0:1d89681580f2 8 {
KarimAzzouz 0:1d89681580f2 9 ble.startAdvertising(); // restart advertising
KarimAzzouz 0:1d89681580f2 10 }
KarimAzzouz 0:1d89681580f2 11
KarimAzzouz 0:1d89681580f2 12 int main() {
KarimAzzouz 0:1d89681580f2 13
KarimAzzouz 0:1d89681580f2 14 ble.init();
KarimAzzouz 0:1d89681580f2 15 ble.onDisconnection(disconnectionCallback);
KarimAzzouz 0:1d89681580f2 16
KarimAzzouz 1:c856cfe550a7 17 TxPowerService tx(ble, -30); // setting up the service and assigning an initial value
KarimAzzouz 1:c856cfe550a7 18 tx.updateTxPower(-10); //changing the initial value just for testing ....
KarimAzzouz 0:1d89681580f2 19
KarimAzzouz 0:1d89681580f2 20 ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
KarimAzzouz 0:1d89681580f2 21 ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
KarimAzzouz 0:1d89681580f2 22 ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000));
KarimAzzouz 0:1d89681580f2 23 ble.startAdvertising();
KarimAzzouz 0:1d89681580f2 24
KarimAzzouz 0:1d89681580f2 25 while (true) {
KarimAzzouz 0:1d89681580f2 26
KarimAzzouz 0:1d89681580f2 27 ble.waitForEvent();
KarimAzzouz 0:1d89681580f2 28
KarimAzzouz 0:1d89681580f2 29 }
KarimAzzouz 0:1d89681580f2 30
KarimAzzouz 0:1d89681580f2 31 }