Code cleanup

master
ktownsend 2014-01-08 11:13:14 +00:00
parent cbb13c0aa7
commit b9cf8e2cee
1 changed files with 11 additions and 3 deletions

View File

@ -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));