High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Revision 24:12eb3f19e9a4, committed 2014-01-08
- Comitter:
- ktownsend
- Date:
- Wed Jan 08 11:13:14 2014 +0000
- Parent:
- 23:f19c60478e1b
- Child:
- 25:7cf2a38ea175
- Commit message:
- Code cleanup
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jan 07 19:58:06 2014 +0000 +++ b/main.cpp Wed Jan 08 11:13:14 2014 +0000 @@ -16,7 +16,6 @@ uint8_t iBeaconPayload[25] = { 0x4C, 0x00, 0x02, 0x15, 0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61, 0x00, 0x00, 0x00, 0x00, 0xC8 }; - /* iBeacon includes the FLAG and MSD fields */ error = advData.addFlags(GapAdvertisingData::BREDR_NOT_SUPPORTED); error = advData.addData(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, iBeaconPayload, 25); @@ -35,13 +34,22 @@ { ble_error_t error; GattService battService ( 0x180F ); - GattCharacteristic battLevel ( 0x2A19, 1, 1, 0x10 | 0x02); - + GattCharacteristic battLevel ( 0x2A19, 1, 1, BLE_GATT_CHAR_PROPERTIES_NOTIFY | BLE_GATT_CHAR_PROPERTIES_READ); + + /* Make sure we get a clean start */ error = radio.reset(); + + /* Add the characteristic to our service */ error = battService.addCharacteristic(battLevel); + + /* Pass the service into the radio */ error = radio.addService(battService); + + /* Configure the radio and start advertising with default values */ + /* Make sure you've added all of your services before calling this function! */ error = radio.start(); + /* Now that we're live, update the battery level characteristic */ uint8_t batt = 72; error = radio.writeCharacteristic(battLevel.handle, (uint8_t*)&batt, sizeof(batt));