Bluetooth LE Advertising

ddewaele
Posts: 4
Joined: Wed Aug 30, 2017 9:54 pm

Bluetooth LE Advertising

Postby ddewaele » Wed Aug 30, 2017 10:01 pm

I'm trying to run the ble_adv sample from ESP-IDF and get my Sparkfun ESP32 Thing to show up on my Nordic NR Connect app on my iPhone but it doesn't show up in my list of beacons.

I did manage to see my ESP32 when I was using the Adruino Simple BLE example, so the board / bluetooth stack / iPhone setup is working but I am wondering why the esp-idf samples aren't working

This is the output I'm getting :

Code: Select all

[0;32mI (29) boot: ESP-IDF v3.0-dev-394-ga4fe12c 2nd stage bootloader[0m
[0;32mI (29) boot: compile time 20:18:08[0m
[0;32mI (47) boot: Enabling RNG early entropy source...[0m
[0;32mI (47) boot: SPI Speed      : 40MHz[0m
[0;32mI (59) boot: SPI Mode       : DIO[0m
[0;32mI (71) boot: SPI Flash Size : 4MB[0m
[0;32mI (84) boot: Partition Table:[0m
[0;32mI (95) boot: ## Label            Usage          Type ST Offset   Length[0m
[0;32mI (117) boot:  0 nvs              WiFi data        01 02 00009000 00006000[0m
[0;32mI (141) boot:  1 phy_init         RF data          01 01 0000f000 00001000[0m
[0;32mI (164) boot:  2 factory          factory app      00 00 00010000 00100000[0m
[0;32mI (187) boot: End of partition table[0m
[0;32mI (200) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x05624 ( 22052) map[0m
[0;32mI (252) esp_image: segment 1: paddr=0x0001564c vaddr=0x3ffc0000 size=0x0283c ( 10300) load[0m
[0;32mI (268) esp_image: segment 2: paddr=0x00017e90 vaddr=0x40080000 size=0x00400 (  1024) load[0m
[0;32mI (284) esp_image: segment 3: paddr=0x00018298 vaddr=0x40080400 size=0x07d78 ( 32120) load[0m
[0;32mI (351) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x161b0 ( 90544) map[0m
[0;32mI (448) esp_image: segment 5: paddr=0x000361d0 vaddr=0x40088178 size=0x0b5f8 ( 46584) load[0m
[0;32mI (508) esp_image: segment 6: paddr=0x000417d0 vaddr=0x400c0000 size=0x00000 (     0) load[0m
[0;32mI (543) boot: Loaded app from partition at offset 0x10000[0m
[0;32mI (544) boot: Disabling RNG early entropy source...[0m
[0;32mI (545) cpu_start: Pro cpu up.[0m
[0;32mI (556) cpu_start: Starting app cpu, entry point is 0x40080de4[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (589) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (609) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM[0m
[0;32mI (628) heap_init: At 3FFC45B8 len 0001BA48 (110 KiB): DRAM[0m
[0;32mI (647) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
[0;32mI (667) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (686) heap_init: At 40093770 len 0000C890 (50 KiB): IRAM[0m
[0;32mI (706) cpu_start: Pro cpu start user code[0m
[0;32mI (764) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (194) cpu_start: Starting scheduler on APP CPU.[0m
[0;32mI (264) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m
[0;32mI (554) phy: phy_version: 357.0, a6bf95b, Jul 25 2017, 12:28:06, 0, 0[0m
BLE advt task start
host rcv pkt: 040e0405030c00
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 1
host rcv pkt: 040e0405062000
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 2
host rcv pkt: 040e0405082000
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 3
host rcv pkt: 040e04050a2000
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 4
BLE Advertise, flag_send_avail: 1, cmd_sent: 4

In other posts / videos, I noticed that the bluetooth hardware address was logged during boot (BTDM CONTROLLER VERSION AND DR address). Something I'm not seeing in my logs.

The Bluetooth module is enabled from the menuconfig (otherwise the sample doesn't compile).

Is there anything else I need to setup in the toolchain ? Should this simple BLE advertising sample work out of the box ?

Thx.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Bluetooth LE Advertising

Postby kolban » Thu Aug 31, 2017 3:17 am

I see you are testing with ESP-IDF master which is the un-released best so far Github stream. Have you considered testing with the latest official release ... which as of this date is v2.1.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ddewaele
Posts: 4
Joined: Wed Aug 30, 2017 9:54 pm

Re: Bluetooth LE Advertising

Postby ddewaele » Thu Aug 31, 2017 4:15 am

Thanks for the tip. However same result with the 2.1 release. No errors n the logs but it's not showing up in Nrf Connect.
Should I see some "low level" bluetooth stack related stuff in the logs (like the hw address of the device) ?

Code: Select all

[0;32mI (31) boot: ESP-IDF v2.1-2-g7138fb0 2nd stage bootloader[0m
[0;32mI (31) boot: compile time 06:08:26[0m
[0;32mI (49) boot: Enabling RNG early entropy source...[0m
[0;32mI (49) boot: SPI Speed      : 40MHz[0m
[0;32mI (60) boot: SPI Mode       : DIO[0m
[0;32mI (72) boot: SPI Flash Size : 4MB[0m
[0;32mI (84) boot: Partition Table:[0m
[0;32mI (95) boot: ## Label            Usage          Type ST Offset   Length[0m
[0;32mI (118) boot:  0 nvs              WiFi data        01 02 00009000 00006000[0m
[0;32mI (141) boot:  1 phy_init         RF data          01 01 0000f000 00001000[0m
[0;32mI (164) boot:  2 factory          factory app      00 00 00010000 00100000[0m
[0;32mI (188) boot: End of partition table[0m
[0;32mI (201) boot: Disabling RNG early entropy source...[0m
[0;32mI (218) boot: Loading app partition at offset 00010000[0m
[0;32mI (632) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512) [0m
[0;32mI (632) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x04a84 ( 19076) map[0m
[0;32mI (648) boot: segment 2: paddr=0x00024a94 vaddr=0x3ffc0000 size=0x02238 (  8760) load[0m
[0;32mI (678) boot: segment 3: paddr=0x00026cd4 vaddr=0x40080000 size=0x00400 (  1024) load[0m
[0;32mI (701) boot: segment 4: paddr=0x000270dc vaddr=0x40080400 size=0x12c5c ( 76892) load[0m
[0;32mI (763) boot: segment 5: paddr=0x00039d40 vaddr=0x400c0000 size=0x00000 (     0) load[0m
[0;32mI (764) boot: segment 6: paddr=0x00039d48 vaddr=0x00000000 size=0x062c0 ( 25280) [0m
[0;32mI (785) boot: segment 7: paddr=0x00040010 vaddr=0x400d0018 size=0x150b4 ( 86196) map[0m
[0;32mI (811) cpu_start: Pro cpu up.[0m
[0;32mI (822) cpu_start: Starting app cpu, entry point is 0x40080dac[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (855) heap_alloc_caps: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (877) heap_alloc_caps: At 3FFAFF10 len 000000F0 (0 KiB): DRAM[0m
[0;32mI (897) heap_alloc_caps: At 3FFC4058 len 0001BFA8 (111 KiB): DRAM[0m
[0;32mI (918) heap_alloc_caps: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
[0;32mI (939) heap_alloc_caps: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (960) heap_alloc_caps: At 4009305C len 0000CFA4 (51 KiB): IRAM[0m
[0;32mI (981) cpu_start: Pro cpu start user code[0m
[0;32mI (1038) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (200) cpu_start: Starting scheduler on APP CPU.[0m
[0;32mI (250) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m
[0;32mI (530) phy: phy_version: 355.1, 59464c5, Jun 14 2017, 20:25:06, 0, 0[0m
BLE advt task start
host rcv pkt: 040e0405030c00
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 1
host rcv pkt: 040e0405062000
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 2
host rcv pkt: 040e0405082000
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 3
host rcv pkt: 040e04050a2000
controller rcv pkt ready
BLE Advertise, flag_send_avail: 1, cmd_sent: 4
BLE Advertise, flag_send_avail: 1, cmd_sent: 4
BLE Advertise, flag_send_avail: 1, cmd_sent: 4

ddewaele
Posts: 4
Joined: Wed Aug 30, 2017 9:54 pm

Re: Bluetooth LE Advertising

Postby ddewaele » Fri Sep 01, 2017 5:14 am

In most bluetooth examples in esp-idf where I see a call to esp_ble_gap_start_advertising I would expect the advertisement to just work and have the device show up in a BLE scanning app like Nrf Connect.

Same thing for the GATT server sample, the advertising call works, I don't see anything special in the logs, but still the device is not showing up.

Hardware-wise I assume everything is because when I run the Arduino SimpleBleClient sample I can see the ESP32 device in my nrf Connect app).

So I'm guessing some kind of issue with my toolchain or menuconfig ? (although I followed the instructions and the problems seem to be limited to BLE). Is there anything special one needs to do / tweak in order for BLE to work ?

Code: Select all

0;32mI (586) GATTS_DEMO: REGISTER_APP_EVT, status 0, app_id 0
[0m
[0;32mI (586) GATTS_DEMO: CREATE_SERVICE_EVT___, status 0,  service_handle 40
[0m
[0;32mI (596) GATTS_DEMO: SERVICE_START_EVT, status 0, service_handle 40
[0m
[0;32mI (606) GATTS_DEMO: ADD_CHAR_EVT, status 0,  attr_handle 42, service_handle 40
[0m
[0;32mI (606) GATTS_DEMO: the gatts demo char length = 3
[0m
[0;32mI (616) GATTS_DEMO: prf_char[0] =11
[0m
[0;32mI (616) GATTS_DEMO: prf_char[1] =22
[0m
[0;32mI (626) GATTS_DEMO: prf_char[2] =33
[0m
[0;32mI (626) GATTS_DEMO: ADD_DESCR_EVT, status 0, attr_handle 43, service_handle 40
[0m
[0;32mI (636) GATTS_DEMO: REGISTER_APP_EVT, status 0, app_id 1
[0m
[0;32mI (646) GATTS_DEMO: CREATE_SERVICE_EVT, status 0,  service_handle 44
[0m
[0;32mI (646) GATTS_DEMO: SERVICE_START_EVT, status 0, service_handle 44
[0m
[0;32mI (656) GATTS_DEMO: ADD_CHAR_EVT, status 0,  attr_handle 46, service_handle 44
[0m
[0;32mI (666) GATTS_DEMO: ADD_DESCR_EVT, status 0, attr_handle 47, service_handle 44

ddewaele
Posts: 4
Joined: Wed Aug 30, 2017 9:54 pm

Re: Bluetooth LE Advertising

Postby ddewaele » Sat Sep 02, 2017 5:22 pm

Found the issue with some help from github : https://github.com/espressif/esp-idf/issues/953

Seems that the crystal frequency (Component Config -> ESP32 Specific -> Main XTAL frequency) on the 2.1 branch is hardcoded to 40MHz. On the 2.1 tar bal it is set to auto-detect.

The Sparkfun ESP32 Thing uses a 26MHz crystal :)

Another interesting discussion on that topic can be found here : viewtopic.php?t=2464

When setting the XTAL to auto-detect the samples started working (This also explains why I thought that my ESP32 had a "default baudrate of 74880 instead of 115200 :). Auto-detecting the XTAL frequency allows for serial output on 115200 bps :)

Who is online

Users browsing this forum: No registered users and 114 guests