diff --git a/src/ble.cpp b/src/ble.cpp index e3b9216a..2d721be1 100644 --- a/src/ble.cpp +++ b/src/ble.cpp @@ -35,24 +35,6 @@ SOFTWARE. // Tilt data format is described here. Only SG and Temp is transmitted over BLE. // https://kvurd.com/blog/tilt-hydrometer-ibeacon-data-format/ -class CharacteristicCallbacks : public NimBLECharacteristicCallbacks { - private: - volatile bool _isRead = false; - - public: - void clearReadFlag() { _isRead = false; } - bool isRead() { return _isRead; } - - void onRead(NimBLECharacteristic* pCharacteristic) { -#if LOG_LEVEL == 6 - Log.verbose(F("BLE : Remote reading data" CR)); -#endif - _isRead = true; - } -}; - -static CharacteristicCallbacks myCharCallbacks; - void BleSender::init() { if (_initFlag) return; @@ -218,39 +200,6 @@ void BleSender::sendCustomBeaconData(float battery, float tempC, float gravity, _advertising->stop(); } -void BleSender::sendGravitymonData(String payload) { - Log.info(F("BLE : Updating data for gravitymon data transmission" CR)); - - _advertising->stop(); - - if (!_server) { - Log.info( - F("BLE : Creating BLE server for gravitymon data transmission" CR)); - - _server = BLEDevice::createServer(); - _service = _server->createService(BLEUUID("180a")); - _characteristic = _service->createCharacteristic( - BLEUUID("2ac4"), NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::BROADCAST); - _characteristic->setCallbacks(&myCharCallbacks); - _service->start(); - _advertising->addServiceUUID(BLEUUID("180a")); - _advertising->setName("gravitymon"); - _advertising->setScanResponse(false); - _advertising->setMinPreferred(0x06); - _advertising->setMaxPreferred(0x12); - } - - myCharCallbacks.clearReadFlag(); - - if (payload.length() > 510) { - writeErrorLog("BLE : Payload is to long for sending over BLE"); - payload = "{\"error\":\"payload to long\"}"; - } - - _characteristic->setValue(payload); - _advertising->start(); -} - void BleSender::dumpPayload(const char* p, int len) { for (int i = 0; i < len; i++) { EspSerial.printf("%X%X ", (*(p + i) & 0xf0) >> 4, (*(p + i) & 0x0f)); @@ -258,6 +207,4 @@ void BleSender::dumpPayload(const char* p, int len) { EspSerial.println(); } -bool BleSender::isGravitymonDataSent() { return myCharCallbacks.isRead(); } - #endif // ENABLE_BLE diff --git a/src/ble.hpp b/src/ble.hpp index a49eb41d..c09ff048 100644 --- a/src/ble.hpp +++ b/src/ble.hpp @@ -53,10 +53,6 @@ class BleSender { void sendEddystone(float battery, float tempC, float gravity, float angle); void sendCustomBeaconData(float battery, float tempC, float gravity, float angle); - - // Use GATT - void sendGravitymonData(String payload); - bool isGravitymonDataSent(); }; #endif // ENABLE_BLE diff --git a/src/config.hpp b/src/config.hpp index 6bd22c3d..d2252ae7 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -32,7 +32,6 @@ enum BleFormat { BLE_DISABLED = 0, BLE_TILT = 1, BLE_TILT_PRO = 2, - BLE_GRAVITYMON_SERVICE = 3, BLE_GRAVITYMON_EDDYSTONE = 4, BLE_GRAVITYMON_IBEACON = 5 }; diff --git a/src/main.cpp b/src/main.cpp index 7b02a1eb..3dc95418 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -320,16 +320,6 @@ bool loopReadGravity() { myBleSender.sendEddystone(myBatteryVoltage.getVoltage(), tempC, gravitySG, angle); } break; - case BleFormat::BLE_GRAVITYMON_SERVICE: { - TemplatingEngine engine; - GravmonPush push(&myConfig); - push.setupTemplateEngine(engine, angle, gravitySG, corrGravitySG, - tempC, (millis() - runtimeMillis) / 1000, - myBatteryVoltage.getVoltage()); - String tpl = push.getTemplate(GravmonPush::TEMPLATE_BLE); - String payload = engine.create(tpl.c_str()); - myBleSender.sendGravitymonData(payload); - } break; } } #endif // ESP32 && !ESP32S2 @@ -362,22 +352,6 @@ bool loopReadGravity() { (millis() - runtimeMillis) / 1000); } } - -#if defined(ESP32) && !defined(ESP32S2) - if (myConfig.getBleFormat() == BleFormat::BLE_GRAVITYMON_SERVICE) { - Log.notice(F("Main: Waiting for ble service to be read." CR)); - int i = 0; - while (!myBleSender.isGravitymonDataSent() && i < 10) { - delay(500); - EspSerial.print("."); - i++; - } - EspSerial.print(CR); - if (myBleSender.isGravitymonDataSent()) - Log.notice(F("Main: Ble service was read by client." CR)); - } -#endif // ESP32 && !ESP32S2 - PERF_END("loop-push"); // Send stats to influx after each push run.