Closed
Description
HI @h2zero I know you are busy with fixing the Client stuff, but something on the Server side broke along the way.
Simple custom characteristic creation using NIMBLE_PROPERTY::READ
makes the app crash on pService->start()
.
Example code:
// Includes for BLE Arduino-NimBLE
#include <NimBLEUtils.h>
#include <NimBLEServer.h>
#include <NimBLEDevice.h>
#include <NimBLEAdvertising.h>
/** Unique device name */
char apName[] = "ESP32-xxxxxxxxxxxx";
// List of Service and Characteristic UUIDs
#define SERVICE_UUID "0000AAAA-EAD2-11E7-80C1-9A214CF093AE"
#define WIFI_UUID "00005555-EAD2-11E7-80C1-9A214CF093AE"
... // skipping the callbacks
/**
* initBLE
* Initialize BLE service and characteristic
* Start BLE server and service advertising
*/
void initBLE()
{
// Initialize BLE and set output power
BLEDevice::init(apName);
BLEDevice::setPower(ESP_PWR_LVL_P7);
BLEDevice::setMTU(256);
Serial.printf("BLE advertising using %s\n", apName);
// Create BLE Server
pServer = BLEDevice::createServer();
// Set server callbacks
pServer->setCallbacks(new MyServerCallbacks());
// Create BLE Service
pService = pServer->createService(SERVICE_UUID);
// Create BLE Characteristic for WiFi settings
pCharacteristicWiFi = pService->createCharacteristic(
// BLEUUID(WIFI_UUID),
WIFI_UUID,
NIMBLE_PROPERTY::READ |
NIMBLE_PROPERTY::WRITE);
/** Add properties the same way as characteristics now **/
pCharacteristicWiFi->createDescriptor("2902");
pCharacteristicWiFi->setCallbacks(new MyCallbackHandler());
// Start the service
pService->start();
// Start advertising
pAdvertising = pServer->getAdvertising();
pAdvertising->addServiceUUID(WIFI_UUID);
pAdvertising->start();
}
Serial debug output:
Build: Apr 5 2020 10:15:02
Read from preferences:
primary SSID: XYZ2 password: secret
secondary SSID: XYZ3 password: secret
I NimBLEDevice: "BLE Host Task Started"
I NimBLEDevice: "NimBle host synced."
D NimBLEDevice: ">> setPower: 7"
D NimBLEDevice: "<< setPower"
BLE advertising using ESP32-3C71BF6CE284
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400e43e3 PS : 0x00060530 A0 : 0x800d65d8 A1 : 0x3ffcb5c0
A2 : 0x00000004 A3 : 0x3ffcb600 A4 : 0x3ffc3600 A5 : 0x00000002
A6 : 0x3ffcb610 A7 : 0x3ffce201 A8 : 0x00002902 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x40085110 A12 : 0x3ffce444 A13 : 0x3ffcb538
A14 : 0x3ffcb5a0 A15 : 0xfefefe01 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace: 0x400e43e3:0x3ffcb5c0 0x400d65d5:0x3ffcb5e0 0x400d5f2d:0x3ffcb600 0x400d1de1:0x3ffcb690 0x400d233f:0x3ffcb6d0 0x400eb93f:0x3ffcb790 0x4008dadd:0x3ffcb7b0
Decoded backtrace:
PC: 0x400e43e3: ble_uuid_cmp at .pio\libdeps\esp32devmaxapp\NimBLE-Arduino\src\nimble\host\src\ble_uuid.c line 71
EXCVADDR: 0x00000004
Decoding stack results
0x400e43e3: ble_uuid_cmp at .pio\libdeps\esp32devmaxapp\NimBLE-Arduino\src\nimble\host\src\ble_uuid.c line 71
0x400d65d5: NimBLEUUID::equals(NimBLEUUID) at .pio\libdeps\esp32devmaxapp\NimBLE-Arduino\src\NimBLEUUID.cpp line 181
0x400d5f2d: NimBLEService::start() at .pio\libdeps\esp32devmaxapp\NimBLE-Arduino\src\NimBLEService.cpp line 129
0x400d1de1: initBLE() at src\main.cpp line 355
0x400d233f: setup() at src\main.cpp line 531
0x400eb93f: loopTask(void*) at C:\users\beegee\.platformio\packages\framework-arduinoespressif32\cores\esp32\main.cpp line 14
0x4008dadd: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
I tried as well with the BLE Uart example and it crashes at the same place. Btw. there is an error in the BLE Uart example.
// Create a BLE Characteristic
pTxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
/******* Enum Type NIMBLE_PROPERTY now *******
BLECharacteristic::PROPERTY_WRITE
);
**********************************************/
NIMBLE_PROPERTY::WRITE);
should be
// Create a BLE Characteristic
pTxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
/******* Enum Type NIMBLE_PROPERTY now *******
BLECharacteristic::PROPERTY_WRITE
);
**********************************************/
NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
Metadata
Metadata
Assignees
Labels
No labels