#pragma once #include #include "SimpleAllocator.h" #include #include #include #include #ifdef CONFIG_BLUEDROID_ENABLED // Help routine to add a description to any BLECharacteristic and add it to the service void addWithDesc(BLEService *service, BLECharacteristic *c, const char *description); void dumpCharacteristic(BLECharacteristic *c); /** converting endianness pull out a 32 bit value */ uint32_t getValue32(BLECharacteristic *c, uint32_t defaultValue); // TODO(girts): create a class for the bluetooth utils helpers? using StartBluetoothPinScreenCallback = std::function; using StopBluetoothPinScreenCallback = std::function; BLEServer *initBLE(StartBluetoothPinScreenCallback startBtPinScreen, StopBluetoothPinScreenCallback stopBtPinScreen, std::string devName, std::string hwVendor, std::string swVersion, std::string hwVersion = ""); /// Add a characteristic that we will delete when we restart BLECharacteristic *addBLECharacteristic(BLECharacteristic *c); /// Add a characteristic that we will delete when we restart BLEDescriptor *addBLEDescriptor(BLEDescriptor *c); /// Any bluetooth objects you allocate _must_ come from this pool if you want to be able to call deinitBLE() extern SimpleAllocator btPool; #endif /// Given a level between 0-100, update the BLE attribute void updateBatteryLevel(uint8_t level); void deinitBLE(); void loopBLE(); void reinitBluetooth();