- Rebooting...
- ets Jun 8 2016 00:22:57
- rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
- configsip: 0, SPIWP:0xee
- clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
- mode:DIO, clock div:1
- load:0x3fff0018,len:4
- load:0x3fff001c,len:1216
- ho 0 tail 12 room 4
- load:0x40078000,len:9720
- ho 0 tail 12 room 4
- load:0x40080400,len:6352
- entry 0x400806b8
- Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
- Core 1 register dump:
- PC : 0x401c0f37 PS : 0x00060f30 A0 : 0x800d1178 A1 : 0x3ffcdc50
- A2 : 0x00000000 A3 : 0x3eaa9c81 A4 : 0x3f4015a5 A5 : 0x00000003
- A6 : 0x00000001 A7 : 0x00000000 A8 : 0x800d10f6 A9 : 0x3ffcdc10
- A10 : 0x3ffe2c68 A11 : 0x00000012 A12 : 0x3ffc5dc8 A13 : 0x3f40198c
- A14 : 0xffffffff A15 : 0x00000000 SAR : 0x00000018 EXCCAUSE: 0x0000001c
- EXCVADDR: 0x00000034 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
- Backtrace: 0x401c0f37:0x3ffcdc50 0x400d1175:0x3ffcdc70 0x400d6d63:0x3ffcdca0 0x4008eb51:0x3ffcdcc0
I am trying to set up a BLEServer with my Esp32 module and whenever there is no more client connected to the server it should go back to sleep. I wanted to acheieve that with the function getConnectedCount() of the class BLEServer. However, whenever this specific line of code gets called, in my code the first time when it happens is in the setup() function, the esp32 gets into an endless reboot loop.
It happens just after this line in the following code block : connected pServer->getConnectedCount();
- #include <WiFi.h>
- #include <BLEDevice.h>
- #include <BLEUtils.h>
- #include <BLEServer.h>
- #include <stdint.h>
- #include "time.h"
- #define uS_TO_S_FACTOR 1000000ULL // museconds to seconds
- #define BUZZER 4
- #define SERVICE_UUID "144c4a01-27f0-4583-9e67-b18fd02575c8"
- #define CHARACTERISTIC_UUID "074db863-df24-4ffa-a05c-6ea474a88208"
- #define HOURS(X) (X)*60*60*uS_TO_S_FACTOR
- #define SECONDS(X) (X)*uS_TO_S_FACTOR
- #define TIMEOUT 10000
- volatile const int ping = 0xA1;
- volatile const int mute = 0xB1;
- uint32_t connected = 0;
- BLEServer *pServer;
- void powerSave(uint64_t sleepTime){
- setCpuFrequencyMhz(80);
- WiFi.disconnect(true);
- WiFi.mode(WIFI_OFF);
- btStop();
- esp_sleep_enable_timer_wakeup(sleepTime);
- esp_deep_sleep_start();
- }
- void startBLE(){
- esp_bt_controller_enable(ESP_BT_MODE_BLE);
- BLEDevice::init("BluePing");
- BLEServer *pServer = BLEDevice::createServer();
- BLEService *pService = pServer->createService(SERVICE_UUID);
- BLECharacteristic *pCharacteristic = pService->createCharacteristic(
- CHARACTERISTIC_UUID,
- BLECharacteristic::PROPERTY_READ |
- BLECharacteristic::PROPERTY_WRITE
- );
- pService->start();
- BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
- pAdvertising->addServiceUUID(SERVICE_UUID);
- pAdvertising->setScanResponse(true);
- pAdvertising->setMinPreferred(0x06);
- pAdvertising->setMinPreferred(0x12);
- BLEDevice::startAdvertising();
- }
- void checkBLE(){
- connected = pServer->getConnectedCount();
- while(connected != 0){
- // execute commands if present
- connected = pServer->getConnectedCount(); // Keine verbindung mehr -> raus
- }
- }
- void setup() {
- // if(getsleepmodeform rtc memoy) powerSave(HOURS()); // sleepMode -> für jeweilige hours sleepen
- Serial.begin(115200);
- pinMode(BUZZER, OUTPUT);
- startBLE();
- connected = pServer->getConnectedCount();
- unsigned long currentMil = millis();
- while (connected == 0){ // ready to pair
- Serial.println("looking to pair");
- //connected = pServer->getConnectedCount(); // if client hat sich verbunden -> raus
- if (millis() - currentMil >= (TIMEOUT * 1UL)){
- Serial.println("timeout, no conn found");
- break; // zeit überschritten -> raus
- }
- }
- if (connected > 0) checkBLE();
- powerSave(SECONDS(10)); // muss nach erst ausgeführt werden wenn keine connection mehr besteht
- }
- void loop() {}
I get this repeating reboot message: