Any idea on this one? I need to switch to WiFi periodically to transmit the data back but can't deinit.
If I call NimBLEDevice::deinit(true); after clearing the scan results I get:
E NimBLEDevice: esp_nimble_hci_and_controller_deinit() failed with error: 259
#include "ATC_MiThermometer.h"
const int scanTime = 5; // BLE scan time in seconds
// List of known sensors' BLE addresses
std::vector<std::string> knownBLEAddresses = { "A4:C1:38:C5:3E:18" };
ATC_MiThermometer miThermometer(knownBLEAddresses);
void setup() {
Serial.begin(115200);
// Initialization
miThermometer.begin();
}
void loop() {
miThermometer.begin();
// Set sensor data invalid
miThermometer.resetData();
// Get sensor data - run BLE scan for <scanTime>
unsigned found = miThermometer.getData(scanTime);
for (int i = 0; i < miThermometer.data.size(); i++) {
if (miThermometer.data[i].valid) {
Serial.println();
Serial.printf("Sensor %d: %s\n", i, knownBLEAddresses[i].c_str());
Serial.printf("Name: %s\n", miThermometer.data[i].name.c_str());
Serial.printf("%.2f°C\n", miThermometer.data[i].temperature / 100.0);
Serial.printf("%.2f%%\n", miThermometer.data[i].humidity / 100.0);
Serial.printf("%.3fV\n", miThermometer.data[i].batt_voltage / 1000.0);
Serial.printf("%d%%\n", miThermometer.data[i].batt_level);
Serial.printf("%ddBm\n", miThermometer.data[i].rssi);
Serial.printf("Measurement Count: %d\n", miThermometer.data[i].count);
// Print boolean flags
Serial.printf("Reed Switch State: %s\n", miThermometer.data[i].reedSwitchState ? "Open" : "Closed");
Serial.printf("GPIO TRG Output: %s\n", miThermometer.data[i].gpioTrgOutput ? "High" : "Low");
Serial.printf("Control Parameters: %s\n", miThermometer.data[i].controlParameters ? "Set" : "Not Set");
Serial.printf("Temperature Trigger Event: %s\n", miThermometer.data[i].tempTriggerEvent ? "Triggered" : "Not Triggered");
Serial.printf("Humidity Trigger Event: %s\n", miThermometer.data[i].humiTriggerEvent ? "Triggered" : "Not Triggered");
Serial.println();
}
}
Serial.println("BLE Devices found (total): " + String(found));
// Delete results from BLEScan buffer to release memory
miThermometer.clearScanResults();
delay(5000);
NimBLEDevice::deinit(true);
}
Any idea on this one? I need to switch to WiFi periodically to transmit the data back but can't deinit. If I call
NimBLEDevice::deinit(true);
after clearing the scan results I get:E NimBLEDevice: esp_nimble_hci_and_controller_deinit() failed with error: 259