Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adafruit Feather ESP32-S3 panik resets in the Scan Continuous example. #636

Open
jstraub opened this issue Jan 28, 2024 · 1 comment
Open

Comments

@jstraub
Copy link

jstraub commented Jan 28, 2024

Hey :) great library! It works beautifully on an Arduino ESP32 for me and I am trying to port the code to the Adafruit Feather ESP32-S3 Reverse TFT now so I can have a display. While doing so I am getting panik resets. I have narrowed this down to the following line in the Scan Continuous example:

  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);

The example code I am using:

#include <NimBLEDevice.h>

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

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
  /*** Only a reference to the advertised device is passed now
    void onResult(BLEAdvertisedDevice advertisedDevice) { **/
    void onResult(BLEAdvertisedDevice* advertisedDevice) {
  /** Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str()); **/
      Serial.printf("Advertised Device: %s \n", advertisedDevice->toString().c_str());
    }
};

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

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  // less or equal setInterval value
}

void loop() {
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  Serial.print("Devices found: ");
  Serial.println(foundDevices.getCount());
  Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(2000);
}

I checked that the pBLEScan pointer is not a nullptr. If I comment out the offending line the code runs fine (but doesnt do any scanning of course). The code works fine on my other ESP32 from Arduino.

Any idea what might be going wrong or how to debug it?

@h2zero
Copy link
Owner

h2zero commented Feb 6, 2024

Could you provide a debug log and or backtrace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants