diff --git a/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp b/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp index d39397950..1bd5d5336 100644 --- a/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp +++ b/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp @@ -117,11 +117,18 @@ e74dd9c0-a301-4a6f-95a1-f0e1dbea8e1e write|read total image size, 32 bi e272ebac-d463-4b98-bc84-5cc1a39ee517 write data, variable sized, recommended 512 bytes, write one for each block of file 4826129c-c22a-43a3-b066-ce8f0d5bacc6 write crc32, write last - writing this will complete the OTA operation, now you can read result 5e134862-7411-4424-ac4a-210937432c77 read|notify result code, readable but will notify when the OTA operation completes + +We also implement the following standard GATT entries because SW update probably needs them: + +ESP_GATT_UUID_SW_VERSION_STR/0x2a28 +ESP_GATT_UUID_MANU_NAME/0x2a29 +ESP_GATT_UUID_HW_VERSION_STR/0x2a27 + */ -BLEService *createUpdateService(BLEServer *server) +BLEService *createUpdateService(BLEServer *server, std::string hwVendor, std::string swVersion, std::string hwVersion) { // Create the BLE Service - BLEService *service = server->createService("cb0b9a0b-a84c-4c0d-bdbb-442e3144ee30"); + BLEService *service = server->createService(BLEUUID("cb0b9a0b-a84c-4c0d-bdbb-442e3144ee30"), 25, 0); assert(!resultC); resultC = new BLECharacteristic("5e134862-7411-4424-ac4a-210937432c77", BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY); @@ -133,10 +140,23 @@ BLEService *createUpdateService(BLEServer *server) resultC->addDescriptor(addBLEDescriptor(new BLE2902())); // Needed so clients can request notification + BLECharacteristic *swC = new BLECharacteristic(BLEUUID((uint16_t)ESP_GATT_UUID_SW_VERSION_STR), BLECharacteristic::PROPERTY_READ); + swC->setValue(swVersion); + service->addCharacteristic(addBLECharacteristic(swC)); + + BLECharacteristic *mfC = new BLECharacteristic(BLEUUID((uint16_t)ESP_GATT_UUID_MANU_NAME), BLECharacteristic::PROPERTY_READ); + mfC->setValue(hwVendor); + service->addCharacteristic(addBLECharacteristic(mfC)); + + BLECharacteristic *hwvC = new BLECharacteristic(BLEUUID((uint16_t)ESP_GATT_UUID_HW_VERSION_STR), BLECharacteristic::PROPERTY_READ); + hwvC->setValue(hwVersion); + service->addCharacteristic(addBLECharacteristic(hwvC)); + return service; } -void destroyUpdateService() { +void destroyUpdateService() +{ assert(resultC); resultC = NULL; diff --git a/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.h b/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.h index b91e9c22d..60b1f6696 100644 --- a/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.h +++ b/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.h @@ -2,7 +2,7 @@ #include -BLEService *createUpdateService(BLEServer* server); +BLEService *createUpdateService(BLEServer* server, std::string hwVendor, std::string swVersion, std::string hwVersion); void destroyUpdateService(); void bluetoothRebootCheck(); \ No newline at end of file diff --git a/lib/BluetoothOTA/src/BluetoothUtil.cpp b/lib/BluetoothOTA/src/BluetoothUtil.cpp index b33c6ff93..4573f43aa 100644 --- a/lib/BluetoothOTA/src/BluetoothUtil.cpp +++ b/lib/BluetoothOTA/src/BluetoothUtil.cpp @@ -276,7 +276,7 @@ BLEServer *initBLE(std::string deviceName, std::string hwVendor, std::string swV // We now let users create the battery service only if they really want (not all devices have a battery) // BLEService *pBattery = createBatteryService(pServer); - pUpdate = createUpdateService(pServer); // We need to advertise this so our android ble scan operation can see it + pUpdate = createUpdateService(pServer, hwVendor, swVersion, hwVersion); // We need to advertise this so our android ble scan operation can see it // It seems only one service can be advertised - so for now don't advertise our updater // pServer->getAdvertising()->addServiceUUID(pUpdate->getUUID());