BLE Library with custom services for the tortuga bike
Fork of BLE_API by
Diff: ble/services/BikeBatteryService.h
- Revision:
- 1207:da7745688342
- Parent:
- 1206:8afbec0520f5
diff -r 8afbec0520f5 -r da7745688342 ble/services/BikeBatteryService.h --- a/ble/services/BikeBatteryService.h Fri Jul 15 12:49:23 2016 +0000 +++ b/ble/services/BikeBatteryService.h Mon Jul 18 09:25:32 2016 +0000 @@ -47,12 +47,15 @@ batteryLevel3(level3), batteryLevelCharacteristic1(BATTERY_LEVEL_1_CHARACTERISTIC_UUID, &batteryLevel1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), batteryLevelCharacteristic2(BATTERY_LEVEL_2_CHARACTERISTIC_UUID, &batteryLevel2, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), - batteryLevelCharacteristic3(BATTERY_LEVEL_3_CHARACTERISTIC_UUID, &batteryLevel3, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) { + batteryLevelCharacteristic3(BATTERY_LEVEL_3_CHARACTERISTIC_UUID, &batteryLevel3, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) + { GattCharacteristic *charTable[] = {&batteryLevelCharacteristic1, &batteryLevelCharacteristic2, &batteryLevelCharacteristic3}; GattService batteryService(BATTERY_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); ble.gattServer().addService(batteryService); + //printf("adress of _ble: %#x\n", &_ble); + //printf("adress of ble: %#x\n", &ble); } /** @@ -63,11 +66,15 @@ * Update to battery level. */ void updateBatteryLevel1(uint8_t newLevel) { + //printf("try to update batlevel 1\n"); if (newLevel != batteryLevel1) { batteryLevel1 = newLevel; ble.gattServer().write(batteryLevelCharacteristic1.getValueHandle(), &batteryLevel1, 1); + //printf("BLE battery Level 1 update : %i\n", batteryLevel1); + //printf("adress of ble: %#x\n", &ble); } + } void updateBatteryLevel2(uint8_t newLevel) { if (newLevel != batteryLevel2) @@ -81,6 +88,7 @@ { batteryLevel3 = newLevel; ble.gattServer().write(batteryLevelCharacteristic3.getValueHandle(), &batteryLevel3, 1); + //printf("battery level updated\n"); } }