h2zero / NimBLE-Arduino

A fork of the NimBLE library structured for compilation with Arduino, for use with ESP32, nRF5x.
https://h2zero.github.io/NimBLE-Arduino/
Apache License 2.0
672 stars 138 forks source link

NimBLE & SerialBT Same TIme Crashing #548

Closed Bwanna closed 1 year ago

Bwanna commented 1 year ago

Setup: ESP32 DevKit C

Issue: NimBLE & SerialBT crash when running same time. (core ESP32 BLE & SerialBT run fine) -I'm not yet experienced enough to decode the error msg and offer any suggestions. Any Suggestions?

Below is the Code and the Error Msg: Sketch: `/*

include

include

include

include

include

BluetoothSerial SerialBT;

int scanTime = 5; //In seconds NimBLEScan* pBLEScan;

void setup() { Serial.begin(115200); Serial.println("Scanning...");

// Initialize Bluetooth Serial SerialBT.begin("ESP32");

NimBLEDevice::init(""); pBLEScan = NimBLEDevice::getScan(); pBLEScan->setActiveScan(true); pBLEScan->setInterval(100); pBLEScan->setFilterPolicy(BLE_HCI_SCAN_FILT_NO_WL); pBLEScan->setWindow(99); pBLEScan-> setMaxResults (0); //Results not stored, relies on Callback only to process data }

void loop() { bleScannerLoop(); bluetoothSerialLoop(); }

void bluetoothSerialLoop() { if (Serial.available()) { String termtext = Serial.readStringUntil('\n'); int data = termtext.toInt(); SerialBT.print(termtext); Serial.print(termtext); } } void bleScannerLoop() { BLEScanResults foundDevices = NimBLEDevice::getScan()->start(5); for (int i = 0; i < foundDevices.getCount(); i++) { NimBLEAdvertisedDevice device = foundDevices.getDevice(i); Serial.print("Found device: "); Serial.println(device.getAddress().toString().c_str()); } } ` Error Msg:

`clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1344 load:0x40078000,len:13924 ho 0 tail 12 room 4 load:0x40080400,len:3600 entry 0x400805f0 Scanning... ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400929dc file: "d:\Arduinofiles\libraries\NimBLE-Arduino\src\NimBLEDevice.cpp" line 879 func: static void NimBLEDevice::init(const string&) expression: esp_bt_controller_init(&bt_cfg)

abort() was called at PC 0x400929df on core 1

Backtrace: 0x4008395d:0x3ffcb0d0 0x400929e9:0x3ffcb0f0 0x40098925:0x3ffcb110 0x400929df:0x3ffcb190 0x400d37e2:0x3ffcb1b0 0x400d2237:0x3ffcb200 0x400e94af:0x3ffcb250

ELF file SHA256: eb7593b2f45f575b `

h2zero commented 1 year ago

NimBLE is BLE only, classic Bluetooth cannot be used with this library.

Bwanna commented 1 year ago

h2Zero,

Just to verify... the BluetoothSerial.h can't be used in the same sketch with the NimBLEDevice.h ?

Thanks,

h2zero commented 1 year ago

That's correct.

Bwanna commented 1 year ago

Thank you for the information.