From b9cf8e2ceee716bc1dbda3d2f84f96587aa6b594 Mon Sep 17 00:00:00 2001 From: ktownsend Date: Wed, 8 Jan 2014 11:13:14 +0000 Subject: [PATCH] Code cleanup --- main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index d23cb1f..657747d 100644 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,6 @@ void startBeacon(void) 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 @@ void startBatteryService(void) { 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));