ESP32-POE Bluetooth not working together with promiscuous mode

Started by amatsusah, February 12, 2020, 11:55:11 AM

Previous topic - Next topic

amatsusah

I am facing a problem with ESP32-POE, when i try to start a bluetooth beacon and turn on promiscuous mode, the board just crashes. the code i use works fine on my other esp32 board (i currently use DOIT ESP32 DEVKITv1).

Currently i am using arduino IDE with ESP32 library version 1.0.3.

the current code i am using is the following :

void setIBeacon() {
char id[12];
String uuid;
uint64_t chipid = ESP.getEfuseMac(); // The chip ID is essentially its MAC address(length: 6 bytes).
uint16_t chip = (uint16_t)(chipid >> 32);
snprintf(id, 12, "%04X%08X", chip, (uint32_t)chipid);
snprintf(uniqueid, 32, "ESP32-%04X%08X_%s", chip, (uint32_t)chipid, FW_VERSION);
uuid = "1935CE03F2D247F899AF"+String(id);
unsigned long int uidul=strtoul("0000000044817512", NULL, 16);
uint64_t uid = uint64_t(uidul);
BLEBeacon oBeacon = BLEBeacon();
oBeacon.setManufacturerId(0x4C00);
oBeacon.setProximityUUID(BLEUUID((uint32_t)(uid)));
oBeacon.setMajor(chip);
oBeacon.setMinor((uint32_t)chipid);
oBeacon.setSignalPower(-60);
BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
oAdvertisementData.setFlags(0x04);
  std::string strServiceData = "";
   strServiceData += (char)26;     // Len
  strServiceData += (char)0xFF;   // Type
  strServiceData += oBeacon.getData();
  oAdvertisementData.addData(strServiceData);
pAdvertising->setAdvertisementData(oAdvertisementData);
  Serial.println("Service Data set!");
Serial.println("");

 pAdvertising->setScanResponseData(oAdvertisementData);
  Serial.println("Scan response set!");

}


void initBLEIBeacon(){
  BLEDevice::init("");

  // Create BLE Server
  BLEServer *pServer = BLEDevice::createServer();
 
  pAdvertising = pServer->getAdvertising();

  setIBeacon();

  // Start advertising
  BLEDevice::startAdvertising();
  Serial.println("Advertising started...");
}

void initPromiscuous(){
  wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  esp_wifi_init(&cfg);
  esp_wifi_set_ps(WIFI_PS_NONE);
  esp_wifi_set_storage(WIFI_STORAGE_RAM);
  esp_wifi_set_mode(WIFI_MODE_NULL);
  esp_wifi_start();
  esp_wifi_set_promiscuous(true);
  esp_wifi_set_promiscuous_filter(&filt);
  esp_wifi_set_promiscuous_rx_cb(&promiscuousCallback);
  esp_wifi_set_channel(channel,WIFI_SECOND_CHAN_NONE);
}

void setup() {
Serial.begin(115200);
if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
        Serial.println("SPIFFS Mount Failed");
        return;
    }
    else{
      Serial.println("SPIFFS Mount Success");
    }
// Setup promiscuous mode.
initPromiscuous();
initBLEIBeacon();
lastBoot = millis();
}

and when i run the code on ESP32-POE, the board just crashes and bootloops with the following stacktrace. this doesn't occur with my other ESP32 board.

Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4000c46c  PS      : 0x00060230  A0      : 0x801338ff  A1      : 0x3fff7ba0 
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000cb8  A5      : 0x00000000 
A6      : 0x00000001  A7      : 0x000000cb  A8      : 0x80084e09  A9      : 0x3fff7b40 
A10     : 0x00000000  A11     : 0x00001800  A12     : 0x00000000  A13     : 0x00000003 
A14     : 0x00001800  A15     : 0x00000083  SAR     : 0x00000008  EXCCAUSE: 0x0000001d 
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x000000ca 

Backtrace: 0x4000c46c:0x3fff7ba0 0x401338fc:0x3fff7bb0 0x40122d77:0x3fff7bd0 0x400fc0be:0x3fff7bf0 0x400fc0fb:0x3fff7c10 0x4008e009:0x3fff7c40

PC: 0x4000c46c
EXCVADDR: 0x00000000

Decoding stack results
0x401338fc: RFCOMM_Init at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/stack/rfcomm/port_api.c line 1719
0x40122d77: BTE_InitStack at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/main/bte_init.c line 166
0x400fc0be: btu_task_start_up at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/stack/btu/btu_task.c line 281
0x400fc0fb: btu_task_thread_handler at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bt/bluedroid/stack/btu/btu_task.c line 226
0x4008e009: vPortTaskWrapper at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/port.c line 143


any help will be appreciated on pointing out any mistakes i made or any suggestions on how i could get both promiscuous mode and bluetooth running together on ESP32-POE. I currently have no idea how to fix this because the code works fine on my other board.

Just the bluetooth code or promiscuous code running seperately works fine but crashes when run together.

Thank you.