Skip to content

Simultaneous BLE causes WiFiMulti.run to fail on 3.0.0 #9736

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

Closed
1 task done
PaulZC opened this issue May 31, 2024 · 4 comments · Fixed by #9738
Closed
1 task done

Simultaneous BLE causes WiFiMulti.run to fail on 3.0.0 #9736

PaulZC opened this issue May 31, 2024 · 4 comments · Fixed by #9738
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@PaulZC
Copy link
Contributor

PaulZC commented May 31, 2024

Board

ESP32-WROOM-32E but also ESP32-WROVER-IE with PSRAM

Device Description

SparkFun ESP32 Thing Plus C

Hardware Configuration

No

Version

v3.0.0

IDE Name

Arduino IDE 1.8.19 - but also seen with the CLI

Operating System

Windows

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

We have been using simultaneous BLE and WiFi successfully for at least two years, on arduino-esp32 <= 2.0.11. We are migrating to 3.0.0 and have noticed that having BLE enabled causes WiFiMulti.run to fail to connect... We've distilled the issue into the following sketch. Change START_BLE to 0 to disable BLE see the code run normally.

Sketch

#define START_BLE 1

#include <WiFi.h>
#include <WiFiMulti.h>

WiFiMulti wifiMulti;
#define WIFI_SSID "<ADD_YOUR_WIFI_SSID_HERE>"
#define WIFI_PASSWORD "<ADD_YOUR_WIFI_PASSWORD_HERE>"

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

void setup() {
  delay(1000);
  Serial.begin(115200);

#if (START_BLE)
  Serial.println("Starting BLE work!");

  BLEDevice::init("Long name works now");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic =
    pService->createCharacteristic(CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE);

  pCharacteristic->setValue("Hello World says Neil");
  pService->start();
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();  // this still is working for backward compatibility
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x06);  // functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();
  Serial.println("Characteristic defined! Now you can read it in your phone!\r\n");

  delay(1000);
#endif
}

void loop() {
  Serial.println("\r\nLoop start\r\n");
  
  static int attempt = 0;

  WiFi.mode(WIFI_STA);

  delay(1000);

  Serial.printf("\r\nConnecting to Wifi : attempt %d\r\n\r\n", ++attempt);

  //wifiMulti.APlistClean(); // Not supported with core < v3.0.0
  wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD);

  if (wifiMulti.run() == WL_CONNECTED) {
    Serial.print("\r\nWiFi connected with IP address: ");
    Serial.println(WiFi.localIP());
    Serial.println("");
  }
  else {
    Serial.println("\r\nWiFi connect failed!\r\n");
    // Wait for second scan to complete : [D][WiFiMulti.cpp:313] run(): [WIFI] start scan
    for (int i = 0; i < 110; i++)
      delay(100);
  }
  
  Serial.println("");

  delay(1000);

  WiFi.mode(WIFI_OFF);

  delay(1000);
}

Debug Message

>>>>> Here is the verbose output when running on arduino-esp32 3.0.0 latest. Here it fails. Scroll down to ">>>>>" to see the working output on 2.0.17.

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_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:0x3fff0030,len:1288
load:0x40078000,len:13872
load:0x40080400,len:4
ho 8 tail 4 room 4
load:0x40080404,len:3048
entry 0x40080590
[     1][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400e5dfc
[    13][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400e5dcc
[    26][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400e5d9c
[    40][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400e5d6c
[    53][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400e5dfc
[    66][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400e5dcc
[    80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400e5d9c
[    93][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400e5d6c
[   107][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400e5dfc
[   120][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400e5dcc
[   134][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400e5d9c
[   147][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400e5d6c
[   163][D][esp32-hal-cpu.c:264] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[   200][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type UART_RX (2) with bus 0x3ffbdb80
[   211][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 1 successfully set to type UART_TX (3) with bus 0x3ffbdb80
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32
  Package           : D0WD-Q5
  Revision          : 1.44
  Cores             : 2
  Frequency         : 240 MHz
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : Yes
  BT Low Energy     : Yes
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   260320 B ( 254.2 KB)
  Free Bytes        :   231324 B ( 225.9 KB)
  Allocated Bytes   :    23516 B (  23.0 KB)
  Minimum Free Bytes:   226140 B ( 220.8 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         : 16777216 B (16 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : DIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  6400.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00650000, size:  6400.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00C90000, size:  3456.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x00FF0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : May 31 2024 09:49:01
  Compile Host OS   : windows
  ESP-IDF Version   : v5.1.4-51-g442a798083-dirty
  Arduino Version   : 3.0.0
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32_THING_PLUS_C
  Arduino Variant   : esp32thing_plus_c
  Arduino FQBN      : esp32:esp32:esp32thing_plus_c:FlashFreq=80,PartitionScheme=default,UploadSpeed=921600,DebugLevel=verbose,EraseFlash=none
============ Before Setup End ============
[  1706][V][esp32-hal-uart.c:408] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(3) txPin(1)
[  1715][V][esp32-hal-uart.c:497] uartBegin(): UART0 not installed. Starting installation
[  1726][V][esp32-hal-uart.c:544] uartBegin(): UART0 initialization done.
Starting BLE work!
[  2408][V][BLEDevice.cpp:77] createServer(): >> createServer
[  2414][V][BLEServer.cpp:284] registerApp(): >> registerApp - 0
[  2420][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: RegisterAppEvt (0x3ffd4464), owner: <N/A> for registerApp
[  2431][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: RegisterAppEvt (0x3ffd4464), owner: registerApp
[  2441][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: RegisterAppEvt (0x3ffd4464), owner: registerApp for registerApp
[  2441][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_REG_EVT
[  2463][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_REG_EVT
[  2471][V][BLEUtils.cpp:1561] dumpGattServerEvent(): [status: ESP_GATT_OK, app_id: 0]
[  2479][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_REG_EVT
[  2488][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: RegisterAppEvt (0x3ffd4464), owner: registerApp
[  2498][V][BLEServer.cpp:275] handleGATTServerEvent(): << handleGATTServerEvent
[  2498][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: RegisterAppEvt (0x3ffd4464), owner: <N/A>
[  2515][V][BLEServer.cpp:288] registerApp(): << registerApp
[  2521][V][BLEDevice.cpp:84] createServer(): << createServer
[  2526][V][BLEServer.cpp:66] createService(): >> createService - 4fafc201-1fb5-459e-8fcc-c5c9c331914b
[  2536][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: CreateEvt (0x3ffe0e30), owner: <N/A> for createService
[  2546][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: CreateEvt (0x3ffe0e30), owner: createService
[  2556][V][BLEService.cpp:59] executeCreate(): >> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b
[  2571][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: CreateEvt (0x3ffe1064), owner: <N/A> for executeCreate
[  2582][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: CreateEvt (0x3ffe1064), owner: executeCreate
[  2591][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe1064), owner: executeCreate for executeCreate
[  2592][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_CREATE_EVT
[  2614][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_CREATE_EVT
[  2622][V][BLEUtils.cpp:1491] dumpGattServerEvent(): [status: ESP_GATT_OK, service_handle: 40 0x28, service_id: [uuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, inst_id: 0]]
[  2638][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_CREATE_EVT
[  2647][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: CreateEvt (0x3ffe0e30), owner: createService
[  2657][V][BLEService.cpp:186] setHandle(): >> setHandle - Handle=0x28, service UUID=4fafc201-1fb5-459e-8fcc-c5c9c331914b)
[  2668][V][BLEService.cpp:192] setHandle(): << setHandle
[  2673][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: CreateEvt (0x3ffe1064), owner: executeCreate
[  2683][V][BLEServer.cpp:275] handleGATTServerEvent(): << handleGATTServerEvent
[  2683][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1064), owner: <N/A>
[  2700][V][BLEService.cpp:76] executeCreate(): << executeCreate
[  2706][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe0e30), owner: <N/A> for createService
[  2717][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe0e30), owner: <N/A>
[  2727][V][BLEServer.cpp:81] createService(): << createService
[  2733][V][BLEService.cpp:212] addCharacteristic(): >> addCharacteristic()
[  2739][D][BLEService.cpp:213] addCharacteristic(): Adding characteristic: uuid=beb5483e-36e1-4688-b7f5-ea07361b26a8 to service: UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
[  2757][V][BLEService.cpp:225] addCharacteristic(): << addCharacteristic()
[  2764][V][BLECharacteristic.cpp:628] setValue(): >> setValue: length=21, data=48656c6c6f20576f726c642073617973204e65696c, characteristic UUID=beb5483e-36e1-4688-b7f5-ea07361b26a8
[  2780][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: SetValue (0x3ffe194c), owner: <N/A> for <Unknown>
[  2790][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: SetValue (0x3ffe194c), owner: <Unknown>
[  2799][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: SetValue (0x3ffe194c), owner: <Unknown>
[  2808][V][BLECharacteristic.cpp:637] setValue(): << setValue
[  2814][V][BLEService.cpp:128] start(): >> start(): Starting service (esp_ble_gatts_start_service): UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
[  2828][V][BLECharacteristic.cpp:79] executeCreate(): >> executeCreate()
[  2835][D][BLECharacteristic.cpp:88] executeCreate(): Registering characteristic (esp_ble_gatts_add_char): uuid: beb5483e-36e1-4688-b7f5-ea07361b26a8, service: UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
[  2855][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: CreateEvt (0x3ffe1884), owner: <N/A> for executeCreate
[  2865][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: CreateEvt (0x3ffe1884), owner: executeCreate
[  2875][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe1884), owner: executeCreate for executeCrea[  2875][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_ADD_CHAR_EVT
[  2897][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_ADD_CHAR_EVT
[  2906][V][BLEUtils.cpp:1451] dumpGattServerEvent(): [status: ESP_GATT_OK, attr_handle: 42 0x2a, service_handle: 40 0x28, char_uuid: beb5483e-36e1-4688-b7f5-ea07361b26a8]
[  2921][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_ADD_CHAR_EVT
[  2931][V][BLECharacteristic.cpp:577] setHandle(): >> setHandle: handle=0x2a, characteristic uuid=beb5483e-36e1-4688-b7f5-ea07361b26a8
[  2943][V][BLECharacteristic.cpp:579] setHandle(): << setHandle
[  2949][V][BLECharacteristic.cpp:191] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_ADD_CHAR_EVT
[  2959][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: CreateEvt (0x3ffe1884), owner: executeCreate
[  2969][V][BLECharacteristic.cpp:444] handleGATTServerEvent(): << handleGATTServerEvent
[  2969][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1884), owner: <N/A>
p  2986][V][BLEServer.cpp:275] handleGATTServerEv[e n t2(9)8:6 ]<[<V ]h[aBnLdElCehGaArTaTcSteerrviesrtEivce.nctp
 :111] executeCreate(): << executeCreate
[  3000][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: StartEvt (0x3ffe112c), owner: <N/A> for start
[  3009][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: StartEvt (0x3ffe112c), owner: start
[  3018][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: StartEvt (0x3ffe112c), owner: start for start
[  3019][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_START_EVT
[  3039][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_START_EVT
[  3048][V][BLEUtils.cpp:1572] dumpGattServerEvent(): [status: ESP_GATT_OK, service_handle: 0x28]
[  3056][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_START_EVT
[  3066][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: StartEvt (0x3ffe112c), owner: start
[  3074][V][BLECharacteristic.cpp:191] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_START_EVT
[  3074][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: StartEvt (0x3ffe112c), owner: <N/A>
[  3094][V][BLEService.cpp:153] start(): << start()
[  3094][V][BLECharacteristic.cpp:444] handleGATTServerEvent(): << handleGATTServerEvent
[  3106][V][BLEServer.cpp:275] handleGATTServerEvent(): << handleGATTServerEvent
[  3106][I][BLEDevice.cpp:553] getAdvertising(): create advertising
[  3119][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3125][V][BLEDevice.cpp:560] startAdvertising(): >> startAdvertising
[  3132][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3137][V][BLEAdvertising.cpp:216] start(): >> start: customAdvData: 0, customScanResponseData: 0
[  3146][D][BLEAdvertising.cpp:233] start(): - advertising service: 4fafc201-1fb5-459e-8fcc-c5c9c331914b
[  3156][V][BLEAdvertising.cpp:284] start(): << start
[  3160][V][BLEUtils.cpp:967] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
[  3170][V][BLEDevice.cpp:562] startAdvertising(): << startAdvertising
Characteristic defined! Now you can read it in your phone!

[  3177][V][BLEUtils.cpp:975] dumpGapEvent(): [status: 0]
[  3187][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3193][D][BLEAdvertising.cpp:529] handleGAPEvent(): handleGAPEvent [event no: 0]
[  3200][V][BLEUtils.cpp:967] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
[  3210][V][BLEUtils.cpp:1127] dumpGapEvent(): [status: 0]
[  3216][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3222][D][BLEAdvertising.cpp:529] handleGAPEvent(): handleGAPEvent [event no: 1]
[  3229][V][BLEUtils.cpp:967] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_START_COMPLETE_EVT
[  3239][V][BLEUtils.cpp:995] dumpGapEvent(): [status: 0]
[  3244][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3250][D][BLEAdvertising.cpp:529] handleGAPEvent(): handleGAPEvent [event no: 6]
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   260320 B ( 254.2 KB)
  Free Bytes        :   141800 B ( 138.5 KB)
  Allocated Bytes   :   108224 B ( 105.7 KB)
  Minimum Free Bytes:   140896 B ( 137.6 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------
     1 : UART_TX[0]
     3 : UART_RX[0]
============ After Setup End =============

Loop start

[  4271][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[  4285][V][STA.cpp:184] _onStaEvent(): STA Started
[  4290][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[  4297][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START

Connecting to Wifi : attempt 1

[  5283][I][WiFiMulti.cpp:86] addAP(): [WIFI][APlistAdd] add SSID: VM4924742
[ 15294][D][WiFiMulti.cpp:310] run(): [WIFI] delete old wifi config...
[ 15300][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 15306][D][WiFiMulti.cpp:313] run(): [WIFI] start scan

WiFi connect failed!

[ 20915][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 8
[ 20923][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE

E (36911) wifi:NAN WiFi stop
[ 27313][V][STA.cpp:188] _onStaEvent(): STA Stopped
[ 27319][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 12 - STA_STOP
[ 27327][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 12 - STA_STOP
[ 27338][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 8 - WIFI_OFF

Loop start

[ 28363][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[ 28375][V][STA.cpp:184] _onStaEvent(): STA Started
[ 28380][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[ 28387][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START

Connecting to Wifi : attempt 2

[ 29373][I][WiFiMulti.cpp:86] addAP(): [WIFI][APlistAdd] add SSID: VM4924742
[ 39384][D][WiFiMulti.cpp:310] run(): [WIFI] delete old wifi config...
[ 39390][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 39396][D][WiFiMulti.cpp:313] run(): [WIFI] start scan

WiFi connect failed!

[ 45003][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 129, Status: 0, Results: 8
[ 45011][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE

E (61001) wifi:NAN WiFi stop
[ 51403][V][STA.cpp:188] _onStaEvent(): STA Stopped
[ 51409][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 12 - STA_STOP
[ 51417][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 12 - STA_STOP
[ 51428][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 8 - WIFI_OFF

Loop start

[ 52454][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[ 52467][V][STA.cpp:184] _onStaEvent(): STA Started
[ 52472][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[ 52479][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START

Connecting to Wifi : attempt 3

[ 53465][I][WiFiMulti.cpp:86] addAP(): [WIFI][APlistAdd] add SSID: VM4924742
[ 63476][D][WiFiMulti.cpp:310] run(): [WIFI] delete old wifi config...
[ 63482][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 63488][D][WiFiMulti.cpp:313] run(): [WIFI] start scan

WiFi connect failed!

[ 69094][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 130, Status: 0, Results: 8
[ 69104][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE


>>>>> Here is the verbose output when running on arduino-esp32 2.0.17. Here it is working:

13:33:33.732 -> [    15][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
13:33:34.764 -> [  1047][V][esp32-hal-uart.c:330] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(3) txPin(1)
13:33:34.798 -> [  1056][V][esp32-hal-uart.c:416] uartBegin(): UART0 not installed. Starting installation
13:33:34.798 -> [  1067][V][esp32-hal-uart.c:463] uartBegin(): UART0 initialization done.
13:33:34.798 -> Starting BLE work!
13:33:35.479 -> [  1762][V][BLEDevice.cpp:76] createServer(): >> createServer
13:33:35.479 -> [  1768][V][BLEServer.cpp:291] registerApp(): >> registerApp - 0
13:33:35.526 -> [  1774][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: RegisterAppEvt (0x3ffe158c), owner: <N/A> for registerApp
13:33:35.526 -> [  1785][V][FreeRTOS.cpp:198] take(): Semaphore taken:  name: RegisterAppEvt (0x3ffe158c), owner: registerApp
13:33:35.526 -> [  1794][V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: RegisterAppEvt (0x3ffe158c), owner: registerApp for registerApp
13:33:35.526 -> [  1795][D][BLEDevice.cpp:102] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_REG_EVT
13:33:35.526 -> [  1817][V][BLEUtils.cpp:1530] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_REG_EVT
13:33:35.573 -> [  1825][V][BLEUtils.cpp:1673] dumpGattServerEvent(): [status: ESP_GATT_OK, app_id: 0]
13:33:35.573 -> [  1833][V][BLEServer.cpp:144] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_REG_EVT
13:33:35.573 -> [  1842][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: RegisterAppEvt (0x3ffe158c), owner: registerApp
13:33:35.573 -> [  1852][V][BLEServer.cpp:281] handleGATTServerEvent(): << handleGATTServerEvent
13:33:35.573 -> [  1852][V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: RegisterAppEvt (0x3ffe158c), owner: <N/A>
13:33:35.620 -> [  1869][V][BLEServer.cpp:295] registerApp(): << registerApp
13:33:35.620 -> [  1874][V][BLEDevice.cpp:83] createServer(): << createServer
13:33:35.620 -> [  1880][V][BLEServer.cpp:67] createService(): >> createService - 4fafc201-1fb5-459e-8fcc-c5c9c331914b
13:33:35.620 -> [  1889][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: CreateEvt (0x3ffe1858), owner: <N/A> for createService
13:33:35.620 -> [  1900][V][FreeRTOS.cpp:198] take(): Semaphore taken:  name: CreateEvt (0x3ffe1858), owner: createService
13:33:35.620 -> [  1910][V][BLEService.cpp:60] executeCreate(): >> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b
13:33:35.667 -> [  1925][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: CreateEvt (0x3ffe1ac4), owner: <N/A> for executeCreate
13:33:35.667 -> [  1935][V][FreeRTOS.cpp:198] take(): Semaphore taken:  name: CreateEvt (0x3ffe1ac4), owner: executeCreate
13:33:35.667 -> [  1945][V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe1ac4), owner: executeCreate for executeCreate
13:33:35.667 -> [  1946][D][BLEDevice.cpp:102] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_CREATE_EVT
13:33:35.715 -> [  1968][V][BLEUtils.cpp:1530] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_CREATE_EVT
13:33:35.715 -> [  1976][V][BLEUtils.cpp:1599] dumpGattServerEvent(): [status: ESP_GATT_OK, service_handle: 40 0x28, service_id: [uuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, inst_id: 0]]
13:33:35.715 -> [  1991][V][BLEServer.cpp:144] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_CREATE_EVT
13:33:35.715 -> [  2000][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: CreateEvt (0x3ffe1858), owner: createService
13:33:35.762 -> [  2010][V][BLEService.cpp:194] setHandle(): >> setHandle - Handle=0x28, service UUID=4fafc201-1fb5-459e-8fcc-c5c9c331914b)
13:33:35.762 -> [  2021][V][BLEService.cpp:200] setHandle(): << setHandle
13:33:35.762 -> [  2026][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: CreateEvt (0x3ffe1ac4), owner: executeCreate
13:33:35.762 -> [  2036][V][BLEServer.cpp:281] handleGATTServerEvent(): << handleGATTServerEvent
13:33:35.762 -> [  2036][V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1ac4), owner: <N/A>
13:33:35.762 -> [  2053][V][BLEService.cpp:76] executeCreate(): << executeCreate
13:33:35.809 -> [  2059][V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe1858), owner: <N/A> for createService
13:33:35.809 -> [  2070][V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1858), owner: <N/A>
13:33:35.809 -> [  2080][V][BLEServer.cpp:83] createService(): << createService
13:33:35.809 -> [  2086][V][BLEService.cpp:222] addCharacteristic(): >> addCharacteristic()
13:33:35.809 -> [  2093][D][BLEService.cpp:225] addCharacteristic(): Adding characteristic: uuid=beb5483e-36e1-4688-b7f5-ea07361b26a8 to service: UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
13:33:35.856 -> [  2110][V][BLEService.cpp:237] addCharacteristic(): << addCharacteristic()
13:33:35.856 -> [  2117][V][BLECharacteristic.cpp:659] setValue(): >> setValue: length=21, data=48656c6c6f20576f726c642073617973204e65696c, characteristic UUID=beb5483e-36e1-4688-b7f5-ea07361b26a8
13:33:35.856 -> [  2133][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: SetValue (0x3ffe2440), owner: <N/A> for <Unknown>
13:33:35.856 -> [  2143][V][FreeRTOS.cpp:198] take(): Semaphore taken:  name: SetValue (0x3ffe2440), owner: <Unknown>
13:33:35.903 -> [  2152][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: SetValue (0x3ffe2440), owner: <Unknown>
13:33:35.903 -> [  2161][V][BLECharacteristic.cpp:668] setValue(): << setValue
13:33:35.903 -> [  2167][V][BLEService.cpp:134] start(): >> start(): Starting service (esp_ble_gatts_start_service): UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
13:33:35.903 -> [  2181][V][BLECharacteristic.cpp:79] executeCreate(): >> executeCreate()
13:33:35.903 -> [  2188][D][BLECharacteristic.cpp:90] executeCreate(): Registering characteristic (esp_ble_gatts_add_char): uuid: beb5483e-36e1-4688-b7f5-ea07361b26a8, service: UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
13:33:35.950 -> [  2207][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: CreateEvt (0x3ffe1d94), owner: <N/A> for executeCreate
13:33:35.950 -> [  2218][V][FreeRTOS.cpp:198] take(): Semaphore taken:  name: CreateEvt (0x3ffe1d94), owner: executeCreate
13:33:35.950 -> [  2228][V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe1d94), owner: executeCreate for executeCreat  2228][D][BLEDevice.cpp:102] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_ADD_CHAR_EVT
13:33:35.996 -> [  2250][V][BLEUtils.cpp:1530] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_ADD_CHAR_EVT
13:33:35.996 -> [  2259][V][BLEUtils.cpp:1553] dumpGattServerEvent(): [status: ESP_GATT_OK, attr_handle: 42 0x2a, service_handle: 40 0x28, char_uuid: beb5483e-36e1-4688-b7f5-ea07361b26a8]
13:33:35.996 -> [  2274][V][BLEServer.cpp:144] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_ADD_CHAR_EVT
13:33:35.996 -> [  2283][V][BLECharacteristic.cpp:604] setHandle(): >> setHandle: handle=0x2a, characteristic uuid=beb5483e-36e1-4688-b7f5-ea07361b26a8
13:33:36.043 -> [  2295][V][BLECharacteristic.cpp:606] setHandle(): << setHandle
13:33:36.043 -> [  2301][V][BLECharacteristic.cpp:205] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_ADD_CHAR_EVT
13:33:36.043 -> [  2311][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: CreateEvt (0x3ffe1d94), owner: executeCreate
13:33:36.043 -> [  2321][V][BLECharacteristic.cpp:465] handleGATTServerEvent(): << handleGATTServerEvent
13:33:36.043 -> [  2321][V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1d94), owner: <N/A>
13:33:36.043 -> [  2339][V][BLEServer.[c p p2:323891]][ Vh]a[nBdLlEeCGhAaTrTaScetrevreirsEtviecn.tc(p)p:: 1<1<6 ]h aenxdelceuGtAeTCTrSeeartvee(r)E en executeCreate
13:33:36.090 -> [  2352][V][FreeRTOS.cpp:189] take(): Semaphore taking: name: StartEvt (0x3ffe1b8c), owner: <N/A> for start
13:33:36.090 -> [  2361][V][FreeRTOS.cpp:198] take(): Semaphore taken:  name: StartEvt (0x3ffe1b8c), owner: start
13:33:36.090 -> [  2370][V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: StartEvt (0x3ffe1b8c), owner: start for start
13:33:36.090 -> [  2371][D][BLEDevice.cpp:102] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_START_EVT
13:33:36.137 -> [  2391][V][BLEUtils.cpp:1530] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_START_EVT
13:33:36.137 -> [  2399][V][BLEUtils.cpp:1686] dumpGattServerEvent(): [status: ESP_GATT_OK, service_handle: 0x28]
13:33:36.137 -> [  2408][V][BLEServer.cpp:144] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_START_EVT
13:33:36.137 -> [  2417][V][FreeRTOS.cpp:143] give(): Semaphore giving: name: StartEvt (0x3ffe1b8c), owner: start
13:33:36.137 -> [  2426][V][BLECharacteristic.cpp:205] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_START_EVT
13:33:36.184 -> [  2426][V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: StartEvt (0x3ffe1b8c), owner: <N/A>
13:33:36.184 -> [  2445[] [ V2]4[4B5L]E[SVe]r[vBiLcEeC.hcaprpa:159] start(): <c<t esrtiasrtti(c).c
13:33:36.184 -> pp:465] handleGATTServerEvent(): << handleGATTServerEvent
13:33:36.184 -> [  2458][V][BLEServer.cpp:281] handleGATTServerEvent(): << handleGATTServerEvent
13:33:36.184 -> [  2458][I][BLEDevice.cpp:577] getAdvertising(): create advertising
13:33:36.184 -> [  2471][D][BLEDevice.cpp:579] getAdvertising(): get advertising
13:33:36.184 -> [  2477][V][BLEDevice.cpp:584] startAdvertising(): >> startAdvertising
13:33:36.231 -> [  2483][D][BLEDevice.cpp:579] getAdvertising(): get advertising
13:33:36.231 -> [  2489][V][BLEAdvertising.cpp:187] start(): >> start: customAdvData: 0, customScanResponseData: 0
13:33:36.231 -> [  2498][D][BLEAdvertising.cpp:199] start(): - advertising service: 4fafc201-1fb5-459e-8fcc-c5c9c331914b
13:33:36.231 -> [  2508][V][BLEAdvertising.cpp:252] start(): << start
13:33:36.231 -> [  2512][V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
13:33:36.231 -> [  2522][V][BLEDevice.cpp:586] startAdvertising(): << startAdvertising
13:33:36.278 -> Characteristic defined! Now you can read it in your phone!
13:33:36.278 -> 
13:33:36.278 -> [  2528][V][BLEUtils.cpp:1056] dumpGapEvent(): [status: 0]
13:33:36.278 -> [  2539][D][BLEDevice.cpp:579] getAdvertising(): get advertising
13:33:36.278 -> [  2545][D][BLEAdvertising.cpp:506] handleGAPEvent(): handleGAPEvent [event no: 0]
13:33:36.278 -> [  2552][V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
13:33:36.278 -> [  2562][V][BLEUtils.cpp:1206] dumpGapEvent(): [status: 0]
13:33:36.278 -> [  2568][D][BLEDevice.cpp:579] getAdvertising(): get advertising
13:33:36.325 -> [  2573][D][BLEAdvertising.cpp:506] handleGAPEvent(): handleGAPEvent [event no: 1]
13:33:36.325 -> [  2581][V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_START_COMPLETE_EVT
13:33:36.325 -> [  2590][V][BLEUtils.cpp:1074] dumpGapEvent(): [status: 0]
13:33:36.325 -> [  2595][D][BLEDevice.cpp:579] getAdvertising(): get advertising
13:33:36.325 -> [  2601][D][BLEAdvertising.cpp:506] handleGAPEvent(): handleGAPEvent [event no: 6]
13:33:37.268 -> 
13:33:37.268 -> Loop start
13:33:37.268 -> 
13:33:37.268 -> [  3549][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 0 - WIFI_READY
13:33:37.268 -> [  3560][V][WiFiGeneric.cpp:341] _arduino_event_cb(): STA Started
13:33:37.315 -> [  3567][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 2 - STA_START
13:33:38.302 -> 
13:33:38.302 -> Connecting to Wifi : attempt 1
13:33:38.302 -> 
13:33:38.302 -> [  4560][I][WiFiMulti.cpp:84] addAP(): [WIFI][APlistAdd] add SSID: VM4924742
13:33:41.688 -> [  7944][V][WiFiGeneric.cpp:384] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 4
13:33:41.688 -> [  7953][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 1 - SCAN_DONE
13:33:41.688 -> [  7961][I][WiFiMulti.cpp:114] run(): [WIFI] scan done
13:33:41.688 -> [  7966][I][WiFiMulti.cpp:119] run(): [WIFI] 4 networks found
13:33:41.688 -> [  7972][D][WiFiMulti.cpp:149] run():  --->   0: [11][18:35:D1:9D:ED:09] VM4924742 (-71) *
13:33:41.688 -> [  7980][D][WiFiMulti.cpp:151] run():        1: [6][58:CB:52:D8:5E:1E] VM6184319 (-76) *
13:33:41.735 -> [  7988][D][WiFiMulti.cpp:151] run():        2: [6][40:0D:10:48:45:51] VM6184319 (-85) *
13:33:41.735 -> [  7996][D][WiFiMulti.cpp:151] run():        3: [1][58:CB:52:D8:49:F7] VM6184319 (-90) *
13:33:41.735 -> [  8004][I][WiFiMulti.cpp:160] run(): [WIFI] Connecting BSSID: 18:35:D1:9D:ED:09 SSID: VM4924742 Channel: 11 (-71)
13:33:41.735 -> [  8016][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
13:33:41.829 -> [  8118][V][WiFiGeneric.cpp:356] _arduino_event_cb(): STA Connected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Channel: 11, Auth: WPA2_PSK
13:33:41.876 -> [  8130][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
13:33:42.016 -> [  8298][V][WiFiGeneric.cpp:370] _arduino_event_cb(): STA Got New IP:192.168.0.88
13:33:42.016 -> [  8307][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
13:33:42.063 -> [  8315][D][WiFiGeneric.cpp:1103] _eventCallback(): STA IP: 192.168.0.88, MASK: 255.255.255.0, GW: 192.168.0.1
13:33:42.063 -> [  8325][I][WiFiMulti.cpp:174] run(): [WIFI] Connecting done.
13:33:42.063 -> [  8330][D][WiFiMulti.cpp:175] run(): [WIFI] SSID: VM4924742
13:33:42.063 -> [  8336][D][WiFiMulti.cpp:176] run(): [WIFI] IP: 192.168.0.88
13:33:42.063 -> [  8342][D][WiFiMulti.cpp:177] run(): [WIFI] MAC: 18:35:D1:9D:ED:09
13:33:42.063 -> [  8348][D][WiFiMulti.cpp:178] run(): [WIFI] Channel: 11
13:33:42.063 -> 
13:33:42.063 -> WiFi connected with IP address: 192.168.0.88
13:33:42.110 -> 
13:33:42.110 -> 
13:33:43.095 -> [  9357][V][WiFiGeneric.cpp:363] _arduino_event_cb(): STA Disconnected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Reason: 8
13:33:43.095 -> [  9369][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
13:33:43.095 -> [  9370][V][WiFiGeneric.cpp:344] _arduino_event_cb(): STA Stopped
13:33:43.095 -> [  9383][W][WiFiGeneric.cpp:1062] _eventCallback(): Reason: 8 - ASSOC_LEAVE
13:33:43.142 -> [  9390][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 3 - STA_STOP
13:33:43.189 -> E (19255) wifi:timeout when WiFi un-init, type=4
13:33:44.127 -> 
13:33:44.127 -> Loop start
13:33:44.127 -> 
13:33:44.174 -> [ 10425][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 0 - WIFI_READY
13:33:44.174 -> [ 10436][V][WiFiGeneric.cpp:341] _arduino_event_cb(): STA Started
13:33:44.174 -> [ 10443][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 2 - STA_START
13:33:45.158 -> 
13:33:45.158 -> Connecting to Wifi : attempt 2
13:33:45.158 -> 
13:33:45.158 -> [ 11436][I][WiFiMulti.cpp:84] addAP(): [WIFI][APlistAdd] add SSID: VM4924742
13:33:48.534 -> [ 14821][V][WiFiGeneric.cpp:384] _arduino_event_cb(): SCAN Done: ID: 129, Status: 0, Results: 6
13:33:48.581 -> [ 14830][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 1 - SCAN_DONE
13:33:48.581 -> [ 14838][I][WiFiMulti.cpp:114] run(): [WIFI] scan done
13:33:48.581 -> [ 14843][I][WiFiMulti.cpp:119] run(): [WIFI] 6 networks found
13:33:48.581 -> [ 14848][D][WiFiMulti.cpp:149] run():  --->   0: [11][18:35:D1:9D:ED:09] VM4924742 (-73) *
13:33:48.581 -> [ 14857][D][WiFiMulti.cpp:151] run():        1: [6][58:CB:52:D8:5E:1E] VM6184319 (-75) *
13:33:48.581 -> [ 14865][D][WiFiMulti.cpp:151] run():        2: [6][40:0D:10:48:45:51] VM6184319 (-86) *
13:33:48.581 -> [ 14873][D][WiFiMulti.cpp:151] run():        3: [1][58:CB:52:D8:49:F7] VM6184319 (-90) *
13:33:48.628 -> [ 14881][D][WiFiMulti.cpp:151] run():        4: [1][C0:05:C2:46:C3:59] VM1245360 (-93) *
13:33:48.628 -> [ 14889][D][WiFiMulti.cpp:151] run():        5: [11][D4:35:1D:17:49:49] vodafone174949 (-95) *
13:33:48.628 -> [ 14897][I][WiFiMulti.cpp:160] run(): [WIFI] Connecting BSSID: 18:35:D1:9D:ED:09 SSID: VM4924742 Channel: 11 (-73)
13:33:48.628 -> [ 14909][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
13:33:48.722 -> [ 14992][V][WiFiGeneric.cpp:356] _arduino_event_cb(): STA Connected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Channel: 11, Auth: WPA2_PSK
13:33:48.722 -> [ 15005][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
13:33:48.909 -> [ 15159][V][WiFiGeneric.cpp:370] _arduino_event_cb(): STA Got Same IP:192.168.0.88
13:33:48.909 -> [ 15167][D][WiFiGeneric.cpp:1040] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
13:33:48.909 -> [ 15174][D][WiFiGeneric.cpp:1103] _eventCallback(): STA IP: 192.168.0.88, MASK: 255.255.255.0, GW: 192.168.0.1
13:33:48.909 -> [ 15184][I][WiFiMulti.cpp:174] run(): [WIFI] Connecting done.
13:33:48.909 -> [ 15190][D][WiFiMulti.cpp:175] run(): [WIFI] SSID: VM4924742
13:33:48.909 -> [ 15195][D][WiFiMulti.cpp:176] run(): [WIFI] IP: 192.168.0.88
13:33:48.909 -> [ 15201][D][WiFiMulti.cpp:177] run(): [WIFI] MAC: 18:35:D1:9D:ED:09
13:33:48.956 -> [ 15207][D][WiFiMulti.cpp:178] run(): [WIFI] Channel: 11
13:33:48.956 -> 
13:33:48.956 -> WiFi connected with IP address: 192.168.0.88
13:33:48.956 -> 
13:33:48.956 ->

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@PaulZC PaulZC added the Status: Awaiting triage Issue is waiting for triage label May 31, 2024
@PaulZC
Copy link
Contributor Author

PaulZC commented May 31, 2024

It has to be something really really subtle with the way BLE and WiFiMulti are instantiated and initialized. This code works, even though it should be functionally identical to the non-working example above:

#define GLOBAL_WIFIMULTI 1

#define START_WIFIMULTI_BEFORE_BLE 0

#define START_BLE 1

#include <WiFi.h>
#include <WiFiMulti.h>

#if (GLOBAL_WIFIMULTI)
WiFiMulti wifiMulti;
#endif

#define WIFI_SSID "<ADD_YOUR_WIFI_SSID_HERE>"
#define WIFI_PASSWORD "<ADD_YOUR_WIFI_PASSWORD_HERE>"

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

void setup() {
  delay(1000);
  Serial.begin(115200);

#if (START_WIFIMULTI_BEFORE_BLE)
  startWiFiMulti();
#endif

#if (START_BLE)
  Serial.println("Starting BLE work!");

  BLEDevice::init("Long name works now");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic =
    pService->createCharacteristic(CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE);

  pCharacteristic->setValue("Hello World says Neil");
  pService->start();
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();  // this still is working for backward compatibility
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x06);  // functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();
  Serial.println("Characteristic defined! Now you can read it in your phone!\r\n");

  delay(1000);
#endif
}

void loop() {
  static int attempt = 0;

  Serial.printf("\r\nLoop start : attempt %d\r\n\r\n", ++attempt);

  startWiFiMulti();
}

void startWiFiMulti() {  
  Serial.println("\r\nLoop start\r\n");
  
  WiFi.mode(WIFI_STA);

  delay(1000);

#if (GLOBAL_WIFIMULTI)
  static bool ssidAdded = false;

  if(!ssidAdded) {
    wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD);
    ssidAdded = true;
  }
#else
  WiFiMulti wifiMulti;
  wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD);
#endif

  Serial.println("\r\nConnecting to Wifi\r\n");

  if (wifiMulti.run() == WL_CONNECTED) {
    Serial.print("\r\nWiFi connected with IP address: ");
    Serial.println(WiFi.localIP());
    Serial.println("");
  }
  else {
    Serial.println("\r\nWiFi connect failed!\r\n");
    // Wait for second scan to complete : [D][WiFiMulti.cpp:313] run(): [WIFI] start scan
    for (int i = 0; i < 110; i++)
      delay(100);
  }
  
  Serial.println("");

  delay(1000);

  WiFi.mode(WIFI_OFF);

  delay(1000);  
}
[     1][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400e5e24
[    13][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400e5df4
[    26][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400e5dc4
[    40][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400e5d94
[    53][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400e5e24
[    66][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400e5df4
[    80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400e5dc4
[    93][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400e5d94
[   107][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400e5e24
[   120][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400e5df4
[   134][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400e5dc4
[   147][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400e5d94
[   163][D][esp32-hal-cpu.c:264] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[   200][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type UART_RX (2) with bus 0x3ffbdb80
[   211][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 1 successfully set to type UART_TX (3) with bus 0x3ffbdb80
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32
  Package           : D0WD-Q5
  Revision          : 1.44
  Cores             : 2
  Frequency         : 240 MHz
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : Yes
  BT Low Energy     : Yes
  IEEE 802.15.4     : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   260312 B ( 254.2 KB)
  Free Bytes        :   231316 B ( 225.9 KB)
  Allocated Bytes   :    23516 B (  23.0 KB)
  Minimum Free Bytes:   226132 B ( 220.8 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         : 16777216 B (16 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 80 MHz
  Bus Mode          : DIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  6400.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00650000, size:  6400.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00C90000, size:  3456.0 KB, type: DATA, subtype: SPIFFS
           coredump : addr: 0x00FF0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : May 31 2024 09:49:01
  Compile Host OS   : windows
  ESP-IDF Version   : v5.1.4-51-g442a798083-dirty
  Arduino Version   : 3.0.0
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : ESP32_THING_PLUS_C
  Arduino Variant   : esp32thing_plus_c
  Arduino FQBN      : esp32:esp32:esp32thing_plus_c:FlashFreq=80,PartitionScheme=default,UploadSpeed=921600,DebugLevel=verbose,EraseFlash=none
============ Before Setup End ============
[  1706][V][esp32-hal-uart.c:408] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(3) txPin(1)
[  1715][V][esp32-hal-uart.c:497] uartBegin(): UART0 not installed. Starting installation
[  1726][V][esp32-hal-uart.c:544] uartBegin(): UART0 initialization done.
Starting BLE work!
[  2413][V][BLEDevice.cpp:77] createServer(): >> createServer
[  2419][V][BLEServer.cpp:284] registerApp(): >> registerApp - 0
[  2425][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: RegisterAppEvt (0x3ffd446c), owner: <N/A> for registerApp
[  2436][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: RegisterAppEvt (0x3ffd446c), owner: registerApp
[  2446][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: RegisterAppEvt (0x3ffd446c), owner: registerApp for registerApp
[  2446][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_REG_EVT
[  2468][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_REG_EVT
[  2476][V][BLEUtils.cpp:1561] dumpGattServerEvent(): [status: ESP_GATT_OK, app_id: 0]
[  2484][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_REG_EVT
[  2493][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: RegisterAppEvt (0x3ffd446c), owner: registerApp
[  2503][V][BLEServer.cpp:275] handleGATTServerEvent(): << handleGATTServerEvent
[  2503][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: RegisterAppEvt (0x3ffd446c), owner: <N/A>
[  2520][V][BLEServer.cpp:288] registerApp(): << registerApp
[  2526][V][BLEDevice.cpp:84] createServer(): << createServer
[  2531][V][BLEServer.cpp:66] createService(): >> createService - 4fafc201-1fb5-459e-8fcc-c5c9c331914b
[  2541][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: CreateEvt (0x3ffe0e30), owner: <N/A> for createService
[  2551][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: CreateEvt (0x3ffe0e30), owner: createService
[  2561][V][BLEService.cpp:59] executeCreate(): >> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b
[  2576][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: CreateEvt (0x3ffe1064), owner: <N/A> for executeCreate
[  2587][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: CreateEvt (0x3ffe1064), owner: executeCreate
[  2596][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe1064), owner: executeCreate for executeCreate
[  2597][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_CREATE_EVT
[  2619][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_CREATE_EVT
[  2627][V][BLEUtils.cpp:1491] dumpGattServerEvent(): [status: ESP_GATT_OK, service_handle: 40 0x28, service_id: [uuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, inst_id: 0]]
[  2643][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_CREATE_EVT
[  2652][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: CreateEvt (0x3ffe0e30), owner: createService
[  2662][V][BLEService.cpp:186] setHandle(): >> setHandle - Handle=0x28, service UUID=4fafc201-1fb5-459e-8fcc-c5c9c331914b)
[  2673][V][BLEService.cpp:192] setHandle(): << setHandle
[  2678][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: CreateEvt (0x3ffe1064), owner: executeCreate
[  2688][V][BLEServer.cpp:275] handleGATTServerEvent(): << handleGATTServerEvent
[  2688][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1064), owner: <N/A>
[  2705][V][BLEService.cpp:76] executeCreate(): << executeCreate
[  2711][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: CreateEvt (0x3ffe0e30), owner: <N/A> for createService
[  2722][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe0e30), owner: <N/A>
[  2732][V][BLEServer.cpp:81] createService(): << createService
[  2738][V][BLEService.cpp:212] addCharacteristic(): >> addCharacteristic()
[  2744][D][BLEService.cpp:213] addCharacteristic(): Adding characteristic: uuid=beb5483e-36e1-4688-b7f5-ea07361b26a8 to service: UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
[  2762][V][BLEService.cpp:225] addCharacteristic(): << addCharacteristic()
[  2769][V][BLECharacteristic.cpp:628] setValue(): >> setValue: length=21, data=48656c6c6f20576f726c642073617973204e65696c, characteristic UUID=beb5483e-36e1-4688-b7f5-ea07361b26a8
[  2785][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: SetValue (0x3ffe194c), owner: <N/A> for <Unknown>
[  2795][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: SetValue (0x3ffe194c), owner: <Unknown>
[  2804][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: SetValue (0x3ffe194c), owner: <Unknown>
[  2813][V][BLECharacteristic.cpp:637] setValue(): << setValue
[  2819][V][BLEService.cpp:128] start(): >> start(): Starting service (esp_ble_gatts_start_service): UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
[  2834][V][BLECharacteristic.cpp:79] executeCreate(): >> executeCreate()
[  2840][D][BLECharacteristic.cpp:88] executeCreate(): Registering characteristic (esp_ble_gatts_add_char): uuid: beb5483e-36e1-4688-b7f5-ea07361b26a8, service: UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, handle: 0x0028
[  2860][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: CreateEvt (0x3ffe1884), owner: <N/A> for executeCreate
[  2870][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: CreateEvt (0x3ffe1884), owner: executeCreate
2880][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_ADD_CHAR_EVT executeCreate
[  2903][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_ADD_CHAR_EVT
[  2911][V][BLEUtils.cpp:1451] dumpGattServerEvent(): [status: ESP_GATT_OK, attr_handle: 42 0x2a, service_handle: 40 0x28, char_uuid: beb5483e-36e1-4688-b7f5-ea07361b26a8]
[  2926][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_ADD_CHAR_EVT
[  2936][V][BLECharacteristic.cpp:577] setHandle(): >> setHandle: handle=0x2a, characteristic uuid=beb5483e-36e1-4688-b7f5-ea07361b26a8
[  2948][V][BLECharacteristic.cpp:579] setHandle(): << setHandle
[  2954][V][BLECharacteristic.cpp:191] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_ADD_CHAR_EVT
[  2964][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: CreateEvt (0x3ffe1884), owner: executeCreate
[  2974][V][BLECharacteristic.cpp:444] handleGATTServerEvent(): << handleGATTServerEvent
[  2974][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: CreateEvt (0x3ffe1884), owner: <N/A>
[  2991][V][BLEServer.cpp:275] handleGA[T T S2e9r9v1e]r[EVv]e[nBtL(E)C:h a<r<a chtaenrdilsetGiAcT.TcSpepr:v1e1r1E]v eenxtec
uteCreate(): << executeCreate
[  3005][V][FreeRTOS.cpp:179] take(): Semaphore taking: name: StartEvt (0x3ffe112c), owner: <N/A> for start
[  3015][V][FreeRTOS.cpp:188] take(): Semaphore taken:  name: StartEvt (0x3ffe112c), owner: start
[  3024][V][FreeRTOS.cpp:59] wait(): >> wait: Semaphore waiting: name: StartEvt (0x3ffe112c), owner: start for start
[  3024][D][BLEDevice.cpp:96] gattServerEventHandler(): gattServerEventHandler [esp_gatt_if: 4] ... ESP_GATTS_START_EVT
[  3045][V][BLEUtils.cpp:1434] dumpGattServerEvent(): GATT ServerEvent: ESP_GATTS_START_EVT
[  3053][V][BLEUtils.cpp:1572] dumpGattServerEvent(): [status: ESP_GATT_OK, service_handle: 0x28]
[  3062][V][BLEServer.cpp:137] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_START_EVT
[  3071][V][FreeRTOS.cpp:136] give(): Semaphore giving: name: StartEvt (0x3ffe112c), owner: start
[  3080][V][BLECharacteristic.cpp:191] handleGATTServerEvent(): >> handleGATTServerEvent: ESP_GATTS_START_EVT
[  3080][V][FreeRTOS.cpp:73] wait(): << wait: Semaphore released: name: StartEvt (0x3ffe112c), owner: <N/A>
[  3099][V][BLEService.cpp:153] start(): << start()
[  3099][V][BLECharacteristic.cpp:444] handleGATTServerEvent(): << handleGATTServerEvent
[  3111][V][BLEServer.cpp:275] handleGATTServerEvent(): << handleGATTServerEvent
[  3111][I][BLEDevice.cpp:553] getAdvertising(): create advertising
[  3125][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3131][V][BLEDevice.cpp:560] startAdvertising(): >> startAdvertising
[  3137][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3143][V][BLEAdvertising.cpp:216] start(): >> start: customAdvData: 0, customScanResponseData: 0
[  3152][D][BLEAdvertising.cpp:233] start(): - advertising service: 4fafc201-1fb5-459e-8fcc-c5c9c331914b
[  3161][V][BLEAdvertising.cpp:284] start(): << start
[  3165][V][BLEUtils.cpp:967] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
[  3175][V][BLEDevice.cpp:562] startAdvertising(): << startAdvertising
Characteristic defined! Now you can read it in your phone!

[  3182][V][BLEUtils.cpp:975] dumpGapEvent(): [status: 0]
[  3192][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3198][D][BLEAdvertising.cpp:529] handleGAPEvent(): handleGAPEvent [event no: 0]
[  3206][V][BLEUtils.cpp:967] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
[  3216][V][BLEUtils.cpp:1127] dumpGapEvent(): [status: 0]
[  3221][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3227][D][BLEAdvertising.cpp:529] handleGAPEvent(): handleGAPEvent [event no: 1]
[  3234][V][BLEUtils.cpp:967] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_ADV_START_COMPLETE_EVT
[  3243][V][BLEUtils.cpp:995] dumpGapEvent(): [status: 0]
[  3249][D][BLEDevice.cpp:555] getAdvertising(): get advertising
[  3254][D][BLEAdvertising.cpp:529] handleGAPEvent(): handleGAPEvent [event no: 6]
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   260312 B ( 254.2 KB)
  Free Bytes        :   141800 B ( 138.5 KB)
  Allocated Bytes   :   108216 B ( 105.7 KB)
  Minimum Free Bytes:   140896 B ( 137.6 KB)
  Largest Free Block:   110580 B ( 108.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------
     1 : UART_TX[0]
     3 : UART_RX[0]
============ After Setup End =============

Loop start : attempt 1


Loop start

[  4276][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[  4290][V][STA.cpp:184] _onStaEvent(): STA Started
[  4295][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[  4302][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START
[  5287][I][WiFiMulti.cpp:86] addAP(): [WIFI][APlistAdd] add SSID: VM4924742

Connecting to Wifi

[ 12634][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 6
[ 12643][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE
[ 12651][I][WiFiMulti.cpp:129] run(): [WIFI] scan done
[ 12656][I][WiFiMulti.cpp:134] run(): [WIFI] 6 networks found
[ 12662][V][WiFiMulti.cpp:175] run(): known ssid: VM4924742, has failed: no
[ 12669][V][WiFiMulti.cpp:208] run(): rssi_scan: -78, bestNetworkDb: -2147483648
[ 12676][V][WiFiMulti.cpp:211] run(): best network is now: VM4924742
[ 12682][D][WiFiMulti.cpp:228] run():  --->   0: [11][18:35:D1:9D:ED:09] VM4924742 (-78) (*) (visible)
[ 12691][D][WiFiMulti.cpp:233] run():         1: [6][58:CB:52:D8:5E:1E] VM6184319 (-84) (*) (visible)
[ 12701][D][WiFiMulti.cpp:233] run():         2: [6][40:0D:10:48:45:51] VM6184319 (-88) (*) (visible)
[ 12710][D][WiFiMulti.cpp:233] run():         3: [1][58:CB:52:D8:49:F7] VM6184319 (-90) (*) (visible)
[ 12719][D][WiFiMulti.cpp:233] run():         4: [11][8C:83:94:6B:6D:FB] BT-XPFH75 (-94) (*) (visible)
[ 12728][D][WiFiMulti.cpp:233] run():         5: [11][7A:83:94:6B:6D:FC] EE WiFi (-94) ( ) (visible)
[ 12737][V][WiFiMulti.cpp:239] run(): foundCount = 1, failCount = 0
[ 12743][I][WiFiMulti.cpp:249] run(): [WIFI] Connecting BSSID: 18:35:D1:9D:ED:09 SSID: VM4924742 Channel: 11 (-78)
[ 12753][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 12877][V][STA.cpp:204] _onStaEvent(): STA Connected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Channel: 11, Auth: WPA2_PSK
[ 12889][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 13 - STA_CONNECTED
[ 12896][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 13 - STA_CONNECTED
[ 13129][V][NetworkInterface.cpp:66] _onIpEvent(): sta Got New IP: 192.168.0.88 MASK: 255.255.255.0 GW: 192.168.0.1
[ 13140][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 16 - STA_GOT_IP
[ 13147][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 16 - STA_GOT_IP
[ 13155][D][STA.cpp:169] _onStaArduinoEvent(): STA IP: 192.168.0.88, MASK: 255.255.255.0, GW: 192.168.0.1
[ 13164][I][WiFiMulti.cpp:272] run(): [WIFI] Connecting done.
[ 13170][D][WiFiMulti.cpp:273] run(): [WIFI] SSID: VM4924742
[ 13175][D][WiFiMulti.cpp:274] run(): [WIFI] IP: 192.168.0.88
[ 13181][D][WiFiMulti.cpp:275] run(): [WIFI] MAC: 18:35:D1:9D:ED:09
[ 13188][D][WiFiMulti.cpp:276] run(): [WIFI] Channel: 11
[ 13193][D][WiFiMulti.cpp:334] resetFails(): [WIFI] Resetting failure flags

WiFi connected with IP address: 192.168.0.88


E (28588) wifi:NAN WiFi stop
[ 14206][V][STA.cpp:214] _onStaEvent(): STA Disconnected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Reason: 8
[ 14216][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 14 - STA_DISCONNECTED
[ 14217][V][STA.cpp:188] _onStaEvent(): STA Stopped
[ 14229][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 14 - STA_DISCONNECTED
[ 14237][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
[ 14243][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 12 - STA_STOP
[ 14250][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 12 - STA_STOP
[ 14263][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 8 - WIFI_OFF

Loop start : attempt 2


Loop start

[ 15287][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[ 15301][V][STA.cpp:184] _onStaEvent(): STA Started
[ 15306][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[ 15313][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START

Connecting to Wifi

[ 23639][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 129, Status: 0, Results: 7
[ 23648][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE
[ 23656][I][WiFiMulti.cpp:129] run(): [WIFI] scan done
[ 23661][I][WiFiMulti.cpp:134] run(): [WIFI] 7 networks found
[ 23666][V][WiFiMulti.cpp:175] run(): known ssid: VM4924742, has failed: no
[ 23673][V][WiFiMulti.cpp:208] run(): rssi_scan: -77, bestNetworkDb: -2147483648
[ 23680][V][WiFiMulti.cpp:211] run(): best network is now: VM4924742
[ 23687][D][WiFiMulti.cpp:228] run():  --->   0: [11][18:35:D1:9D:ED:09] VM4924742 (-77) (*) (visible)
[ 23696][D][WiFiMulti.cpp:233] run():         1: [6][58:CB:52:D8:5E:1E] VM6184319 (-87) (*) (visible)
[ 23705][D][WiFiMulti.cpp:233] run():         2: [1][58:CB:52:D8:49:F7] VM6184319 (-89) (*) (visible)
[ 23714][D][WiFiMulti.cpp:233] run():         3: [6][40:0D:10:48:45:51] VM6184319 (-93) (*) (visible)
[ 23723][D][WiFiMulti.cpp:233] run():         4: [11][98:AA:FC:36:F8:2B] Wi-Fi Socket (-94) ( ) (visible)
[ 23733][D][WiFiMulti.cpp:233] run():         5: [11][7A:83:94:6B:6D:FC] EE WiFi (-96) ( ) (visible)
[ 23742][D][WiFiMulti.cpp:233] run():         6: [11][8C:83:94:6B:6D:FB] BT-XPFH75 (-97) (*) (visible)
[ 23751][V][WiFiMulti.cpp:239] run(): foundCount = 1, failCount = 0
[ 23757][I][WiFiMulti.cpp:249] run(): [WIFI] Connecting BSSID: 18:35:D1:9D:ED:09 SSID: VM4924742 Channel: 11 (-77)
[ 23767][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 23846][V][STA.cpp:204] _onStaEvent(): STA Connected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Channel: 11, Auth: WPA2_PSK
[ 23858][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 13 - STA_CONNECTED
[ 23866][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 13 - STA_CONNECTED
[ 24003][V][NetworkInterface.cpp:66] _onIpEvent(): sta Got New IP: 192.168.0.88 MASK: 255.255.255.0 GW: 192.168.0.1
[ 24014][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 16 - STA_GOT_IP
[ 24021][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 16 - STA_GOT_IP
[ 24028][D][STA.cpp:169] _onStaArduinoEvent(): STA IP: 192.168.0.88, MASK: 255.255.255.0, GW: 192.168.0.1
[ 24038][I][WiFiMulti.cpp:272] run(): [WIFI] Connecting done.
[ 24044][D][WiFiMulti.cpp:273] run(): [WIFI] SSID: VM4924742
[ 24050][D][WiFiMulti.cpp:274] run(): [WIFI] IP: 192.168.0.88
[ 24056][D][WiFiMulti.cpp:275] run(): [WIFI] MAC: 18:35:D1:9D:ED:09
[ 24062][D][WiFiMulti.cpp:276] run(): [WIFI] Channel: 11
[ 24068][D][WiFiMulti.cpp:334] resetFails(): [WIFI] Resetting failure flags

WiFi connected with IP address: 192.168.0.88


E (39463) wifi:NAN WiFi stop
[ 25081][V][STA.cpp:214] _onStaEvent(): STA Disconnected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Reason: 8
[ 25091][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 14 - STA_DISCONNECTED
[ 25092][V][STA.cpp:188] _onStaEvent(): STA Stopped
[ 25104][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 14 - STA_DISCONNECTED
[ 25112][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
[ 25118][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 12 - STA_STOP
[ 25125][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 12 - STA_STOP
[ 25138][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 8 - WIFI_OFF

Loop start : attempt 3


Loop start

[ 26162][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[ 26175][V][STA.cpp:184] _onStaEvent(): STA Started
[ 26180][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[ 26187][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START

Connecting to Wifi

[ 34514][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 130, Status: 0, Results: 6
[ 34523][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE
[ 34531][I][WiFiMulti.cpp:129] run(): [WIFI] scan done
[ 34536][I][WiFiMulti.cpp:134] run(): [WIFI] 6 networks found
[ 34541][V][WiFiMulti.cpp:175] run(): known ssid: VM4924742, has failed: no
[ 34548][V][WiFiMulti.cpp:208] run(): rssi_scan: -77, bestNetworkDb: -2147483648
[ 34555][V][WiFiMulti.cpp:211] run(): best network is now: VM4924742
[ 34562][D][WiFiMulti.cpp:228] run():  --->   0: [11][18:35:D1:9D:ED:09] VM4924742 (-77) (*) (visible)
[ 34571][D][WiFiMulti.cpp:233] run():         1: [1][58:CB:52:D8:49:F7] VM6184319 (-89) (*) (visible)
[ 34580][D][WiFiMulti.cpp:233] run():         2: [6][58:CB:52:D8:5E:1E] VM6184319 (-90) (*) (visible)
[ 34589][D][WiFiMulti.cpp:233] run():         3: [11][7A:83:94:6B:6D:FC] EE WiFi (-94) ( ) (visible)
[ 34598][D][WiFiMulti.cpp:233] run():         4: [6][40:0D:10:48:45:51] VM6184319 (-95) (*) (visible)
[ 34607][D][WiFiMulti.cpp:233] run():         5: [11][8C:83:94:6B:6D:FB] BT-XPFH75 (-95) (*) (visible)
[ 34617][V][WiFiMulti.cpp:239] run(): foundCount = 1, failCount = 0
[ 34623][I][WiFiMulti.cpp:249] run(): [WIFI] Connecting BSSID: 18:35:D1:9D:ED:09 SSID: VM4924742 Channel: 11 (-77)
[ 34633][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 34710][V][STA.cpp:204] _onStaEvent(): STA Connected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Channel: 11, Auth: WPA2_PSK
[ 34722][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 13 - STA_CONNECTED
[ 34729][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 13 - STA_CONNECTED
[ 34941][V][NetworkInterface.cpp:66] _onIpEvent(): sta Got New IP: 192.168.0.88 MASK: 255.255.255.0 GW: 192.168.0.1
[ 34952][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 16 - STA_GOT_IP
[ 34959][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 16 - STA_GOT_IP
[ 34966][D][STA.cpp:169] _onStaArduinoEvent(): STA IP: 192.168.0.88, MASK: 255.255.255.0, GW: 192.168.0.1
[ 34976][I][WiFiMulti.cpp:272] run(): [WIFI] Connecting done.
[ 34982][D][WiFiMulti.cpp:273] run(): [WIFI] SSID: VM4924742
[ 34987][D][WiFiMulti.cpp:274] run(): [WIFI] IP: 192.168.0.88
[ 34993][D][WiFiMulti.cpp:275] run(): [WIFI] MAC: 18:35:D1:9D:ED:09
[ 35000][D][WiFiMulti.cpp:276] run(): [WIFI] Channel: 11
[ 35005][D][WiFiMulti.cpp:334] resetFails(): [WIFI] Resetting failure flags

WiFi connected with IP address: 192.168.0.88


E (50401) wifi:NAN WiFi stop
[ 36017][V][STA.cpp:214] _onStaEvent(): STA Disconnected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Reason: 8
[ 36028][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 14 - STA_DISCONNECTED
[ 36028][V][STA.cpp:188] _onStaEvent(): STA Stopped
[ 36040][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 14 - STA_DISCONNECTED
[ 36048][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
[ 36055][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 12 - STA_STOP
[ 36062][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 12 - STA_STOP
[ 36074][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 8 - WIFI_OFF

Loop start : attempt 4


Loop start

[ 37099][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 9 - WIFI_READY
[ 37112][V][STA.cpp:184] _onStaEvent(): STA Started
[ 37117][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 11 - STA_START
[ 37125][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 11 - STA_START

Connecting to Wifi

[ 45451][V][WiFiGeneric.cpp:77] _arduino_event_cb(): SCAN Done: ID: 131, Status: 0, Results: 7
[ 45460][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 10 - SCAN_DONE
[ 45468][I][WiFiMulti.cpp:129] run(): [WIFI] scan done
[ 45473][I][WiFiMulti.cpp:134] run(): [WIFI] 7 networks found
[ 45479][V][WiFiMulti.cpp:175] run(): known ssid: VM4924742, has failed: no
[ 45486][V][WiFiMulti.cpp:208] run(): rssi_scan: -75, bestNetworkDb: -2147483648
[ 45493][V][WiFiMulti.cpp:211] run(): best network is now: VM4924742
[ 45499][D][WiFiMulti.cpp:228] run():  --->   0: [11][18:35:D1:9D:ED:09] VM4924742 (-75) (*) (visible)
[ 45508][D][WiFiMulti.cpp:233] run():         1: [6][58:CB:52:D8:5E:1E] VM6184319 (-88) (*) (visible)
[ 45517][D][WiFiMulti.cpp:233] run():         2: [1][58:CB:52:D8:49:F7] VM6184319 (-89) (*) (visible)
[ 45527][D][WiFiMulti.cpp:233] run():         3: [6][40:0D:10:48:45:51] VM6184319 (-93) (*) (visible)
[ 45536][D][WiFiMulti.cpp:233] run():         4: [11][7A:83:94:6B:6D:FC] EE WiFi (-94) ( ) (visible)
[ 45545][D][WiFiMulti.cpp:233] run():         5: [11][8C:83:94:6B:6D:FB] BT-XPFH75 (-94) (*) (visible)
[ 45554][D][WiFiMulti.cpp:233] run():         6: [11][98:AA:FC:36:F8:2B] Wi-Fi Socket (-96) ( ) (visible)
[ 45563][V][WiFiMulti.cpp:239] run(): foundCount = 1, failCount = 0
[ 45570][I][WiFiMulti.cpp:249] run(): [WIFI] Connecting BSSID: 18:35:D1:9D:ED:09 SSID: VM4924742 Channel: 11 (-75)
[ 45580][W][STA.cpp:533] disconnect(): STA already disconnected.
[ 45665][V][STA.cpp:204] _onStaEvent(): STA Connected: SSID: VM4924742, BSSID: 18:35:d1:9d:ed:09, Channel: 11, Auth: WPA2_PSK
[ 45677][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 13 - STA_CONNECTED
[ 45685][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 13 - STA_CONNECTED
[ 45902][V][NetworkInterface.cpp:66] _onIpEvent(): sta Got New IP: 192.168.0.88 MASK: 255.255.255.0 GW: 192.168.0.1
[ 45913][V][NetworkEvents.cpp:119] checkForEvent(): Network Event: 16 - STA_GOT_IP
[ 45920][D][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 16 - STA_GOT_IP
[ 45928][D][STA.cpp:169] _onStaArduinoEvent(): STA IP: 192.168.0.88, MASK: 255.255.255.0, GW: 192.168.0.1
[ 45937][I][WiFiMulti.cpp:272] run(): [WIFI] Connecting done.
[ 45943][D][WiFiMulti.cpp:273] run(): [WIFI] SSID: VM4924742
[ 45949][D][WiFiMulti.cpp:274] run(): [WIFI] IP: 192.168.0.88
[ 45954][D][WiFiMulti.cpp:275] run(): [WIFI] MAC: 18:35:D1:9D:ED:09
[ 45961][D][WiFiMulti.cpp:276] run(): [WIFI] Channel: 11
[ 45967][D][WiFiMulti.cpp:334] resetFails(): [WIFI] Resetting failure flags

WiFi connected with IP address: 192.168.0.88

@me-no-dev
Copy link
Member

what actually happens is that for some reason the first sketch takes too long to scan (same on my end) and the second scans in about 8 seconds. Timeout is set to 10 seconds, so it timeouts before results come. I will add a fix for the timeout to WiFiMulti

@me-no-dev
Copy link
Member

@PaulZC
Copy link
Contributor Author

PaulZC commented May 31, 2024

@me-no-dev : sincere thanks for the very fast fix!

The fix works for me - both in my simple example and in our much larger product firmware.

Thanks again - and have a great weekend,
Paul

Just for information - for anyone else reading this issue:

  • With this fix, the default WiFiMulti.run scan timeout is now 60 seconds - it was 10 seconds and slightly too short
  • If needed, you can adjust the timeout with e.g. WiFi.setScanTimeout(20000); // Set scan timeout to 20s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants