turn off battery service for now

pull/1/head
geeksville 2020-02-02 13:37:02 -08:00
rodzic 255463f6b8
commit ef4e7911f5
2 zmienionych plików z 17 dodań i 12 usunięć

Wyświetl plik

@ -40,6 +40,7 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w
# Low priority
* reneable the bluetooth battely level service on the T-BEAM, because we can read battery level there
* report esp32 device code bugs back to the mothership via android
# Done

Wyświetl plik

@ -78,10 +78,24 @@ BLEService *createBatteryService(BLEServer* server) {
addWithDesc(pBattery, &BatteryLevelCharacteristic, "Percentage 0 - 100");
BatteryLevelCharacteristic.addDescriptor(new BLE2902()); // Needed so clients can request notification
// I don't think we need to advertise this
// server->getAdvertising()->addServiceUUID(pBattery->getUUID());
pBattery->start();
return pBattery;
}
/**
* Update the battery level we are currently telling clients.
* level should be a pct between 0 and 100
*/
void updateBatteryLevel(uint8_t level) {
// Pretend to update battery levels - fixme do elsewhere
BatteryLevelCharacteristic.setValue(&level, 1);
BatteryLevelCharacteristic.notify();
}
void dumpCharacteristic(BLECharacteristic *c) {
std::string value = c->getValue();
@ -115,15 +129,14 @@ BLEServer *initBLE(std::string deviceName) {
BLEService *pDevInfo = createDeviceInfomationService(pServer);
BLEService *pBattery = createBatteryService(pServer);
pServer->getAdvertising()->addServiceUUID(pBattery->getUUID());
// We now let users create the battery service only if they really want (not all devices have a battery)
// BLEService *pBattery = createBatteryService(pServer);
BLEService *pUpdate = createUpdateService(pServer); // We need to advertise this so our android ble scan operation can see it
pServer->getAdvertising()->addServiceUUID(pUpdate->getUUID());
// start all our services (do this after creating all of them)
pDevInfo->start();
pBattery->start();
pUpdate->start();
// Start advertising
@ -134,14 +147,5 @@ BLEServer *initBLE(std::string deviceName) {
// Called from loop
void loopBLE() {
static uint8_t level = 31;
// Pretend to update battery levels - fixme do elsewhere
BatteryLevelCharacteristic.setValue(&level, 1);
BatteryLevelCharacteristic.notify();
delay(5000);
level = (level + 1) % 100;
bluetoothRebootCheck();
}