esp32-snippets icon indicating copy to clipboard operation
esp32-snippets copied to clipboard

about Bluetooth low energy

Open hzhh110 opened this issue 4 years ago • 0 comments

Hello, is there a Bluetooth low energy solution? Now running Bluetooth alone requires 80-90ma consumption, how can it be smaller? void setupBLE(String BLEName) { const char *ble_name = BLEName.c_str(); BLEDevice::init(ble_name); // BLEDevice::setPower(); BLEServer *pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); BLEService *pService = pServer->createService(SERVICE_UUID); //创建一个BLE服务 pCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_NOTIFY); pCharacteristic->addDescriptor(new BLE2902()); BLECharacteristic *pCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX, BLECharacteristic::PROPERTY_WRITE); pCharacteristic->setCallbacks(new MyCallbacks()); pService->start(); pServer->getAdvertising()->start(); Serial.println("Waiting a client connection to notify..."); } void setup() { Serial.begin(115200); setupBLE("JH-ESP32-BT-CAM"); }

hzhh110 avatar Apr 21 '21 08:04 hzhh110