GithubHelp home page GithubHelp logo

esp32-nimble's People

Contributors

catunlock avatar chocolateloverraj avatar cliffhan avatar codepainters avatar geovie avatar haobogu avatar jannesbrands avatar jasta avatar juliankrieger avatar kpcyrd avatar mbv avatar mnlphlp avatar oleander avatar p3zhy avatar pilotniq avatar sampaioletti avatar taks avatar tufteddeer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

esp32-nimble's Issues

use Nimble for ClassicBT

Hi,

I'm wondering whether we can use Nimble for classic bluetooth connections since until now most of the equipments are defaultly set in classic mode. I've tried the ble scan example and it works perfectly, the problem is I want it to be connectable with Raspberry pi 4b but esp32 is not seeing its mac addr anyway. Also, it cannot see my mac and iphone's BT MAC either.

Any function calls or examples to use classic BT?

Any help would be really appreciated!

Cody

`BLEDevice::set_device_name` doesn't change the name

This is what I tried: ChocolateLoverRaj@746d2bc

let name = String::from_utf8(args.recv_data.to_vec())
    .unwrap()
    .trim()
    .to_owned();
println!("Changing name to: {:#?}", name);
BLEDevice::set_device_name(&name).unwrap();

The name doesn't change. I also tried starting advertising again after that, but the name still doesn't change.

Device name changes to 'nimble' after pairing

Hi,

I am using a variation of the example code provided for the BLE Keyboard. What I noticed is that my device gets advertised with the name I define with the following:

let device = BLEDevice::take();
// ...
let ble_advertising = device.get_advertising();
ble_advertising.name("ESP32 Keyboard")
//...

However after pairing the name on the client side changes to 'nimble'.
This happens on my Linux laptop and on my Android phone. For the FireTV Cube the name stays as advertised.
Any idea what could cause this?

Thanks in advance for any pointers,
schaze

Accept BLESecurity when taking the BLEDevice

I was thinking of creating different security profiles based on some feature (for example) but the BLEDevice does not accept BLESecurity when taking it.

It is possible to do something like this?:

...
#[cfg(feature = "low_security")]
let ble_security = BLESecurity::builder()
            .security()
            .set_auth(true, true, true)
            .set_passkey(123456)
            .set_io_cap(SecurityIOCap::DisplayOnly);

#[cfg(feature = "high_security")]
let ble_security = BLESecurity::builder()
            .security()
            .set_auth(true, true, true)
            .set_passkey(952384)
            .set_io_cap(SecurityIOCap::DisplayOnly);

let ble_device = BLEDevice::take_with_security_conf(ble_security);
...

Indication callback

Hi,

Is there a way to have app to know if indicate acknowledge received by server? Something like on_read callback?

Examples apparently not advertising on ESP32-C3-DevKitM-1

I have an ESP32-C3-DevKitM-1 and tried to get the ble_server example working and while everything seemingly is working right from the logs:

https://gist.github.com/jasta/25be24926dd3c2067e26461ebd54b09a

The device doesn't appear in scan results from LightBlue on my Android phone. Not sure what I could've done wrong since I just ran the example without modification (except to change the default target in .cargo/config.toml) on two different boards just to sanity check and neither have externally visible advertisements. Any pointers are greatly appreciated!

[Feature request]: Set maximum lenght of a characteristic

NimBLE-Arduino has the possibility to set a maximum length of bytes which a characteristic supports (https://h2zero.github.io/NimBLE-Arduino/class_nim_b_l_e_characteristic.html#aa32224e69115e9ba60ac614e8f37a871`max_length`), i don't see this possibility here.

In my opinion it would be useful to reject some kind of values.
Or is there an option to reject values e.g. in the on_write callback which i have overlooked?

Thanks in advance.

WDYT? Btw. thanks for this crate.

How to turn off logging / output to `stdout`?

I am going to use stdout for sending data, and I want to use this library without interfering with other messages sent to stdout. Is there an option to turn off all logging that this library does?

Errors with iPhone pairing

I have the following blE server

let ble_device = Esp32BleDevice::take();
        ble_device
            .security()
            .set_auth(true, true, true)
            .set_passkey(ble_configuration.pin_number)
            .set_io_cap(SecurityIOCap::DisplayOnly);

And the following characteristic

let settings_characteristic = main_service.lock().create_characteristic(
            BleUuid::from_uuid128_string(SETTINGS_CHARACTERISTIC_UUID).unwrap(),
            NimbleProperties::READ
                | NimbleProperties::READ_ENC
                | NimbleProperties::READ_AUTHEN
                | NimbleProperties::WRITE
                | NimbleProperties::WRITE_ENC
                | NimbleProperties::WRITE_AUTHEN
        );

When I try to read there from an android, there is no problem.
The problem comes with iPhone connections.
If I use NimbleProperties::READ_AUTHEN or NimbleProperties::WRITE_AUTHEN I can connect to the esp32-c3 but I can't read or write on that characteristic. It always says Error Reading Characteristic 68F... Authentication is insufficient
If I remove NimbleProperties::READ_AUTHEN or NimbleProperties::WRITE_AUTHEN

let settings_characteristic = main_service.lock().create_characteristic(
            BleUuid::from_uuid128_string(SETTINGS_CHARACTERISTIC_UUID).unwrap(),
            NimbleProperties::READ
                | NimbleProperties::READ_ENC
                | NimbleProperties::WRITE
                | NimbleProperties::WRITE_ENC
        );

I can use that characteristic but the first time I try to read from there It says: Error Reading Characteristic 68F... Authentication is insufficient but when I try to read again, it works.

The last thing that I'm not able to solve is when I try to disconnect and connect again from iPhone device. No matter if I use NimbleProperties::READ_ENC or NimbleProperties::READ_ENC and NimbleProperties::READ_AUTHEN I'm not able to reconnect that device again from iPhone. It says Failed to Connect: Peer removed pairing information

The only way I can reconnect the Iphone with the esp32-c3 is going to Settings->Bluetooth->[Device name] and delete the connection data of the device.

It looks like esp32-c3 is not able to save some kind of data that iPhone needs to connect with this device again.

I make some research and seems to have something to do with LTK (Long Term Key) and RPA (Resolvable Private Address) but I'm not able to solve it.

espressif/esp-nimble#8

espressif/esp-nimble#33

Does anyone have or have had the same problem?

This is my sdkconfig.defaults file

# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7000

# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
# This allows to use 1 ms granuality for thread sleeps (10 ms by default).
#CONFIG_FREERTOS_HZ=1000

# Workaround for https://github.com/espressif/esp-idf/issues/7631
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n

# Bluetooth
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_NIMBLE_NVS_PERSIST=y

CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
CONFIG_BTDM_CTRL_MODE_BTDM=n

This is my partition table

# Name,   Type, SubType,  Offset,   Size,  Flags
nvs,      data, nvs,      0x9000,  0x4000,
otadata,  data, ota,      0xd000,  0x2000,
phy_init, data, phy,      0xf000,  0x1000,
factory,  app,  factory,  0x10000,  1M,
ota_0,    app,  ota_0,    ,         1M,
ota_1,    app,  ota_1,    ,         1M,
report_data,  data, nvs, ,        0x12000

๐Ÿค” I am doing something wrong?

cargo check error

When I add this dependency the check fails.
Please help me see what the problem is.
Cargo.toml

[package]
name = "esp32-test"
version = "0.1.0"
authors = ["zzn"]
edition = "2021"
resolver = "2"
rust-version = "1.71"

[profile.release]
opt-level = "s"

[profile.dev]
debug = true    # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
default = ["std", "embassy", "esp-idf-svc/native"]

pio = ["esp-idf-svc/pio"]
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"]
alloc = ["esp-idf-svc/alloc"]
nightly = ["esp-idf-svc/nightly"]
experimental = ["esp-idf-svc/experimental"]
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"]

[dependencies]
log = { version = "0.4", default-features = false }
esp-idf-svc = { version = "0.47.3", default-features = false }
esp32-nimble = "0.3.0"

[build-dependencies]
embuild = "0.31.3"

cargo check result:

    Checking embedded-svc v0.26.4
error[E0053]: method `acquire` has an incompatible type for trait
   --> /home/zzn/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/esp-idf-hal-0.42.5/src/task.rs:749:29
    |
749 |         unsafe fn acquire() {
    |                             ^ expected `bool`, found `()`
    |
    = note: expected signature `unsafe fn() -> bool`
               found signature `unsafe fn()`
help: change the output type to match the trait
    |
749 |         unsafe fn acquire() -> bool {
    |                             +++++++

error[E0053]: method `release` has an incompatible type for trait
   --> /home/zzn/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/esp-idf-hal-0.42.5/src/task.rs:753:35
    |
753 |         unsafe fn release(_token: ()) {
    |                                   ^^
    |                                   |
    |                                   expected `bool`, found `()`
    |                                   help: change the parameter type to match the trait: `bool`
    |
    = note: expected signature `unsafe fn(bool)`
               found signature `unsafe fn(())`

For more information about this error, try `rustc --explain E0053`.
error: could not compile `esp-idf-hal` (lib) due to 2 previous errors

Thx

Publish latest code to crates.io

The crates.io version is outdated and isn't compatible with the examples. I copied and pasted an example and got an error because this is different:
GitHub:

callback: impl FnMut(&mut Self, &BLEConnDesc) + Send + Sync + 'static,

crates.io:
https://taks.github.io/esp32-nimble/src/esp32_nimble/server/ble_server.rs.html#47

callback: impl FnMut(&mut Self, &esp_idf_sys::ble_gap_conn_desc) + Send + Sync + 'static,

Panic when trying to write_value() after the device disconnected

I observe a crash using esp32-nimble v0.5.1 .
The scenario is as follows:

  • I successfully connect to the BLE device with BLEClient::connect(), followed by get_service() and get_characteristic()
  • I periodically call BLERemoteCharacteristic::write_value() to control the device.
  • then I power off the device.

At that point my app panics:

thread 'main' panicked at /home/czajnik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp32-nimble-0.5.1/src/client/ble_writer.rs:20:19:
attempt to subtract with overflow

Just before the panic I can see it disconnected the device:

I (67205) esp32_nimble::client::ble_client: Disconnected: 520

Corresponding line:

      let mtu = { esp_idf_sys::ble_att_mtu(self.conn_handle) - 3 } as usize;

Obviously the subtraction underflows, because ble_att_mtu() returns 0 if connection is gone:

/**
 * Retrieves the ATT MTU of the specified connection.  If an MTU exchange for
 * this connection has occurred, the MTU is the lower of the two peers'
 * preferred values.  Otherwise, the MTU is the default value of 23.
 *
 * @param conn_handle           The handle of the connection to query.
 *
 * @return                      The specified connection's ATT MTU, or 0 if
 *                                  there is no such connection.
 */
uint16_t ble_att_mtu(uint16_t conn_handle);

I could check the connection state before calling write_value(), but there's probably a race condition here (toctou error).
I assumed that write_value() should handle such a situation gracefully.

Do I miss something important here (I'm both Rust and BLE noob)?

More Documentation

Thanks for this amazing repo, it has let me program my Adafruit ESP32 Feather fully in Rust without having to resort to the Arduino IDE's implementation of BLE!

I am a bit confused however, there is not much documentation for getting started or exact what some functions do. The naming is great and useful, but the only place I can find any working code is in the examples directory.
I am not experienced with BLE embedded (yet), so maybe most frameworks are similar enough that you can understand what is going on just by looking at the naming by itself, but as a beginner I find this time consuming.

Because of that, I would request just some basic 'Getting Started' code and/or some extra documentation.
I'll be forking this repo and submitting PRs tagging this issue.

Multiple connection to the BLE server

Hi,

I need to connect multiple clients to the BLE server. Using your example code for the server, only one client at a time is connected. Is there a way to enable a multi-client connection?

Thank you!

Unresolved import `core::sync::atomic::AtomicU64`

I am trying to use this library with a ESP32-C3 unfortunately when adding esp32-nimble to the dependencies I get a compiler error:

error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
   --> /home/derfetzer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/atomic-polyfill-1.0.3/src/polyfill.rs:6:17
    |
6   |         pub use core::sync::atomic::$atomic_type;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `AtomicU64` in `sync::atomic`
...
169 | atomic_int!(u64, AtomicU64, polyfill_u64);
    | -----------------------------------------
    | |                |
    | |                help: a similar name exists in the module: `AtomicU32`
    | in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0432]: unresolved import `core::sync::atomic::AtomicI64`
   --> /home/derfetzer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/atomic-polyfill-1.0.3/src/polyfill.rs:6:17
    |
6   |         pub use core::sync::atomic::$atomic_type;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `AtomicI64` in `sync::atomic`
...
174 | atomic_int!(i64, AtomicI64, polyfill_i64);
    | -----------------------------------------
    | |                |
    | |                help: a similar name exists in the module: `AtomicI32`
    | in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0432`.
error: could not compile `atomic-polyfill` (lib) due to 2 previous errors

I am using the esp-idf-template and only added the CONFIG_BT_* flags and this library as a dependency.

It seems there have been issues with Xtensa targets in the past (embassy-rs/atomic-polyfill#14).
The last hint there was to update the compiler version but I did espup update just today.

Do you have any idea what the problem could be?

Thanks in advance!

BLE advertising stops almost immediately

I've been trying to get this library up and running for a while now on multiple IDF versions (4.4 and 5.1 most recently) but keep running into the same issue. I'm running the ble_server.rs verbatim, on an ESP-WROOM-32, ESP-WROOM-32E and ESP32S3, the advertising starts and seems to work fine, but after less than a second (I think?) it shuts down. I'll then reset my ESP and the same thing happens: advertising starts and immediately stops. The full logs on restart (currently running 5.1, logs on 4.4 were very similar/the same):

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:2
load:0x3fff0030,len:7104
0x3fff0030 - g_ticks_per_us_app
    at ??:??
load:0x40078000,len:15576
0x40078000 - __udivmoddi4
    at ??:??
load:0x40080400,len:4
0x40080400 - _init
    at ??:??
ho 8 tail 4 room 4
load:0x40080404,len:3876
0x40080404 - _iram_text_start
    at ??:??
entry 0x4008064c
0x4008064c - _iram_text_start
    at ??:??
I (31) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (31) boot: compile time Jun  7 2023 07:48:23
I (33) boot: Multicore bootloader
I (37) boot: chip revision: v3.1
I (41) boot.esp32: SPI Speed      : 40MHz
I (46) boot.esp32: SPI Mode       : DIO
I (50) boot.esp32: SPI Flash Size : 8MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (79) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (86) boot:  2 factory          factory app      00 00 00010000 00200000
I (94) boot: End of partition table
I (98) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=30660h (198240) map
I (178) esp_image: segment 1: paddr=00040688 vaddr=3ffbdb60 size=045c4h ( 17860) load
I (185) esp_image: segment 2: paddr=00044c54 vaddr=40080000 size=0b3c4h ( 46020) load
I (205) esp_image: segment 3: paddr=00050020 vaddr=400d0020 size=90214h (590356) map
I (418) esp_image: segment 4: paddr=000e023c vaddr=4008b3c4 size=0ce40h ( 52800) load
I (452) boot: Loaded app from partition at offset 0x10000
I (452) boot: Disabling RNG early entropy source...
I (464) cpu_start: Multicore app
I (464) cpu_start: Pro cpu up.
I (464) cpu_start: Starting app cpu, entry point is 0x4008224c
0x4008224c - call_start_cpu1
    at /home/simon/rust-projects/esp32-test/.embuild/espressif/esp-idf/v5.1.1/components/esp_system/port/cpu_start.c:154
I (0) cpu_start: App cpu up.
I (482) cpu_start: Pro cpu start user code
I (482) cpu_start: cpu freq: 160000000 Hz
I (482) cpu_start: Application information:
I (487) cpu_start: Project name:     libespidf
I (492) cpu_start: App version:      1
I (497) cpu_start: Compile time:     Jan  1 1980 00:00:00
I (503) cpu_start: ELF file SHA256:  0000000000000000...
I (509) cpu_start: ESP-IDF:          v5.1.1
I (514) cpu_start: Min chip rev:     v0.0
I (518) cpu_start: Max chip rev:     v3.99 
I (523) cpu_start: Chip rev:         v3.1
I (528) heap_init: Initializing. RAM available for dynamic allocation:
I (535) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (541) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (547) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (553) heap_init: At 3FFC5190 len 0001AE70 (107 KiB): DRAM
I (560) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (566) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (572) heap_init: At 40098204 len 00007DFC (31 KiB): IRAM
I (580) spi_flash: detected chip: gd
I (583) spi_flash: flash io: dio
W (587) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
W (597) pcnt(legacy): legacy driver is deprecated, please migrate to `driver/pulse_cnt.h`
W (606) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`
I (615) coexist: coex firmware version: 80b0d89
I (621) app_start: Starting scheduler on CPU0
I (625) app_start: Starting scheduler on CPU1
mI (625) main_task: Started on CPU0
I (635) main_task: Calling app_main()
I (655) BTDM_INIT: BT controller compile version [946b762]
I (655) BTDM_INIT: Bluetooth MAC: b0:a7:32:1c:b2:ce
I (655) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (995) esp32_nimble::ble_device: BLE Host Task Started
I (1035) esp32_nimble::ble_device: Device Address: B0:A7:32:1C:B2:CE
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid 5f6d4f53-5f52-5043-5f53-56435f49445f
         handle 10
     end_handle 10
I (1105) NimBLE: GAP procedure initiated: advertise; 
I (1105) NimBLE: disc_mode=2
I (1105) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (1115) NimBLE: 

The last log line makes it feel like a freeze? I have no evidence for that though. The ESP32 is not frozen though, as I can just add a log line in the final loop and it keeps happening.

Mark `&mut BLEAdvertising` as `Send`?

Is it safe for &mut BLEAdvertising to be marked with Send similar to 0468826? I want to access the advertising from the on_write callback. Currently I'm using channels, but it would be more convenient if I could just use Arc.

This is related to #17

no_std not compiling (esp-idf-sys: Unsupported target)

I already have esp32-nimble working in a std context just fine, but I would also like to get it running in a no_std context as well, since there seems to be a no_std feature.

However, I'm unable to get esp32-nimble to build, getting the following error:

error: failed to run custom build command for `esp-idf-sys v0.33.7`

Caused by:
  process didn't exit successfully: `/home/leon/Desktop/dev/esp32c6-no-std/target/debug/build/esp-idf-sys-823049c3c6f61c3a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_CMAKE_GENERATOR
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=EXTRA-COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENT_MANAGER

  --- stderr
  Build configuration: BuildConfig {
      esp_idf_tools_install_dir: None,
      esp_idf_sdkconfig: None,
      esp_idf_sdkconfig_defaults: None,
      mcu: None,
      native: NativeConfig {
          esp_idf_version: None,
          esp_idf_repository: None,
          esp_idf_cmake_generator: None,
          idf_path: None,
          extra_components: [],
          esp_idf_components: None,
          esp_idf_component_manager: None,
      },
      esp_idf_sys_root_crate: None,
  }
  Error: Unsupported target 'riscv32imac-unknown-none-elf'

Please see this repo for an example setup. If I remove the esp32-nimble dependency, and remove all references to in in the main.rs, it builds fine. I've also tried with the esp32c3 (riscv32imc-unknown-none-elf), but ultimately, the error is the same (unsupported target).

Am I missing something here, or is there something else that needs to be done to get no_std working?

Use packedstruct instead of unsafe transmuation

Hey,
Nice crate - i hacked it up a bit to try to make it safer.

Most (but not all) of the unsafe usage is around trying to convert various structures into various byte representations and back.
Or make bitwise copies of non-Copy structures, etc.

For those cases, the packed_struct crate can be used to do it without pain or unsafe code.

Bonding breaks secure connection

Hey, I am trying to use bonding and secure connection on 2 esp32-s3's.
Using your examples of secure server and secure client everything works the first time. But after I reload the client, they connect, but the client hangs on secure connection, and the server prints, that an unhandled event happens (esp32_nimble::server::ble_server: unhandled event: 17) (If i checked correctly, 17 is BLE_GAP_EVENT_REPEAT_PAIRING). After that client just times out.

Without bonding everything works just fine.

I used your examples without changing them, so I don't think I have to post the code.

I am using esp-idf v4.4 with the help of esp-idf-template, if that's in any way helpful.

ble server example watchdog

Hi just a quick question,

Why is the watchdog timer turned off in the ble server example?
Also i'm happy to work on any minor tasks if you guys need something done!

Thanks!

Why is the value of a characteristic automatically changed but notify is not automatically called?

I connected to an ESP32-C3 BLE server and there is a read, write, and notify characteristic. I enabled notifications on the first device and then changed the value with the second device. The first device did not get a notification. When I read the value with the first device manually, I saw the updated value. When I added notify() to the code on write, notifications worked as expected.

  • Is this expected behavior?
  • If yes, why are notifications not automatic? Seems inconsistent / confusing.

`ble_server` - Client constantly connects and disconnects

I ran cargo run --example ble_server without any modifications to the example, and I get this log:

I (186902) ble_server: Multi-connect support: start advertising
I (186902) NimBLE: GAP procedure initiated: advertise; 
I (186912) NimBLE: disc_mode=2
I (186912) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (186922) NimBLE: 

I (188112) ble_server: Client disconnected (205)
I (188242) ble_server: Client connected
I (188242) NimBLE: GAP procedure initiated: 
I (188242) NimBLE: connection parameter update; conn_handle=2 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (188252) NimBLE: 

I (188262) ble_server: Multi-connect support: start advertising
I (188262) NimBLE: GAP procedure initiated: advertise; 
I (188272) NimBLE: disc_mode=2
I (188272) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (188282) NimBLE: 

I (189552) ble_server: Client disconnected (205)

And it repeats forever. I can connect to the ESP32C3 from one device, but when I try to connect a second device the ESP32C3 crashes and restarts.

Unable to import the library into a project

Hi,

I have some problems importing this library into my project.

[package]
name = "esp32-bluetooth-firmware"
version = "0.1.0"
authors = ["Nicolas Farabegoli <[email protected]>"]
edition = "2021"
resolver = "2"

[profile.release]
opt-level = "s"

[profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
pio = ["esp-idf-sys/pio"]

[dependencies]
esp-idf-sys = { version = "0.32.1", features = ["binstart"] }
esp32-nimble = "0.0.5"

[dev-dependencies]
esp-idf-sys = { version = "0.32.1", features = ["native", "binstart"] }

[build-dependencies]
embuild = "0.30.4"

Building the hello world:

use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported

fn main() {
    // It is necessary to call this function once. Otherwise some patches to the runtime
    // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
    esp_idf_sys::link_patches();

    println!("Hello, world!");
}

I get the following errors: https://pastebin.com/YUhcS7Xm

Am I missing something? How can I import the library correctly?

Thanks!

Latency and connection interval

I am wondering if the latency I am experiencing is normal and or if there is a way to speed it up. With a simple notifying characteristic running in a loop with a 1ms delay updating the value of the characteristic (integer that increase by one each time), the read operation on the client side takes approximately 90-100ms which to me seems much too slow. In other libraries such as the Arduino NimBLE library, they seem to have an option for "connection interval" which essentially allows you to increase transmission rates at the cost of power consumption. Is there an option for this in this library?

ESP32C3 BLE advertising not work

Hello!

Thanks for the library. But I am unable to use it( I try to run the example ble_server.rs and this example starts advertising, my phone sees the ESP32, but when I try to pair it, nothing happens. Literally nothing: the phone does not respond and there is silence in the ESP32 logs.

What am I doing wrong?

Logs
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x171c
0x3fcd5820 - _bss_end
    at ??:??
load:0x403cc710,len:0x968
0x403cc710 - _iram_bss_start
    at ??:??
load:0x403ce710,len:0x2f68
0x403ce710 - _iram_bss_start
    at ??:??
SHA-256 comparison failed:
Calculated: 1d06b938c0222bf626e0bdf46178b1b37ab24d03f0360fc8fcf7153c2571deaf
Expected: 68d7bdf643ba446b8ed7ae8423241d442fd052b2bc77091100ba06fd65dcf8d5
Attempting to boot anyway...
entry 0x403cc710
0x403cc710 - _iram_bss_start
    at ??:??
I (50) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (50) boot: compile time Jun  7 2023 07:59:10
I (51) boot: chip revision: v0.3
I (55) boot.esp32c3: SPI Speed      : 40MHz
I (60) boot.esp32c3: SPI Mode       : DIO
I (65) boot.esp32c3: SPI Flash Size : 4MB
I (69) boot: Enabling RNG early entropy source...
I (75) boot: Partition Table:
I (78) boot: ## Label            Usage          Type ST Offset   Length
I (86) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (93) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (101) boot:  2 factory          factory app      00 00 00010000 003f0000
I (108) boot: End of partition table
I (112) esp_image: segment 0: paddr=00010020 vaddr=3c090020 size=301e8h (197096) map
I (164) esp_image: segment 1: paddr=00040210 vaddr=3fc91200 size=02224h (  8740) load
I (166) esp_image: segment 2: paddr=0004243c vaddr=40380000 size=0dbdch ( 56284) load
I (184) esp_image: segment 3: paddr=00050020 vaddr=42000020 size=86824h (550948) map
I (305) esp_image: segment 4: paddr=000d684c vaddr=4038dbdc size=03598h ( 13720) load
I (313) boot: Loaded app from partition at offset 0x10000
I (314) boot: Disabling RNG early entropy source...
I (325) cpu_start: Unicore app
I (325) cpu_start: Pro cpu up.
I (334) cpu_start: Pro cpu start user code
I (334) cpu_start: cpu freq: 160000000 Hz
I (334) cpu_start: Application information:
I (337) cpu_start: Project name:     libespidf
I (342) cpu_start: App version:      1
I (347) cpu_start: Compile time:     Aug  2 2023 22:15:12
I (353) cpu_start: ELF file SHA256:  0000000000000000...
I (359) cpu_start: ESP-IDF:          3187b8b
I (364) cpu_start: Min chip rev:     v0.3
I (368) cpu_start: Max chip rev:     v0.99 
I (373) cpu_start: Chip rev:         v0.3
I (378) heap_init: Initializing. RAM available for dynamic allocation:
I (385) heap_init: At 3FC95E70 len 000468A0 (282 KiB): DRAM
I (391) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (398) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (406) spi_flash: detected chip: generic
I (409) spi_flash: flash io: dio
W (413) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
W (424) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`
I (432) sleep: Configure to isolate all GPIO pins in sleep state
I (439) sleep: Enable automatic switching of GPIO sleep configuration
I (446) coexist: coex firmware version: 80b0d89
I (452) coexist: coexist rom version 9387209
I (457) app_start: Starting scheduler on CPU0
I (461) main_task: Started on CPU0
I (461) main_task: Calling app_main()
I (471) BLE_INIT: BT controller compile version [963cad4]
I (471) phy_init: phy_version 970,1856f88,May 10 2023,17:44:12
W (481) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (531) BLE_INIT: Bluetooth MAC: 34:b4:72:4e:1a:ea

I (541) esp32_nimble::ble_device: BLE Host Task Started
I (541) NimBLE: GAP procedure initiated: stop advertising.

I (541) esp32_nimble::ble_device: Device Address: 34:B4:72:4E:1A:EA
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid fafafafa-fafa-fafa-fafa-fafafafafafa
         handle 10
     end_handle 17
characteristic
           uuid d4e0e0d0-1a2b-11e9-ab14-d663bd873d93
     def_handle 11
     val_handle 12
   min_key_size 0
          flags [READ]
characteristic
           uuid a3c87500-8ed3-4bdf-8a39-a01bebede295
     def_handle 13
     val_handle 14
   min_key_size 0
          flags [READ|NOTIFY]
ccc descriptor
           uuid 0x2902
         handle 15
   min_key_size 0
          flags [READ|WRITE]
characteristic
           uuid 3c9a3f00-8ed3-4bdf-8a39-a01bebede295
     def_handle 16
     val_handle 17
   min_key_size 0
          flags [READ|WRITE]
I (661) NimBLE: GAP procedure initiated: advertise; 
I (671) NimBLE: disc_mode=2
I (671) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (681) NimBLE: 
Source code
#![no_std]
#![no_main]

extern crate alloc;

use alloc::format;
use esp32_nimble::{uuid128, BLEDevice, NimbleProperties};
use esp_idf_sys as _;

#[no_mangle]
fn main() {
    esp_idf_sys::link_patches();
    esp_idf_svc::log::EspLogger::initialize_default();

    let ble_device = BLEDevice::take();

    let server = ble_device.get_server();
    server.on_connect(|_| {
        ::log::info!("Client connected");
        ::log::info!("Multi-connect support: start advertising");
        ble_device.get_advertising().start().unwrap();
    });
    let service = server.create_service(uuid128!("fafafafa-fafa-fafa-fafa-fafafafafafa"));

    // A static characteristic.
    let static_characteristic = service.lock().create_characteristic(
        uuid128!("d4e0e0d0-1a2b-11e9-ab14-d663bd873d93"),
        NimbleProperties::READ,
    );
    static_characteristic
        .lock()
        .set_value("Hello, world!".as_bytes());

    // A characteristic that notifies every second.
    let notifying_characteristic = service.lock().create_characteristic(
        uuid128!("a3c87500-8ed3-4bdf-8a39-a01bebede295"),
        NimbleProperties::READ | NimbleProperties::NOTIFY,
    );
    notifying_characteristic.lock().set_value(b"Initial value.");

    // A writable characteristic.
    let writable_characteristic = service.lock().create_characteristic(
        uuid128!("3c9a3f00-8ed3-4bdf-8a39-a01bebede295"),
        NimbleProperties::READ | NimbleProperties::WRITE,
    );
    writable_characteristic
        .lock()
        .on_read(move |_, _| {
            ::log::info!("Read from writable characteristic.");
        })
        .on_write(move |value, _param| {
            ::log::info!("Wrote to writable characteristic: {:?}", value);
        });

    let ble_advertising = ble_device.get_advertising();
    ble_advertising
        .name("ESP32-GATT-Server")
        .add_service_uuid(uuid128!("fafafafa-fafa-fafa-fafa-fafafafafafa"));

    ble_advertising.start().unwrap();

    let mut counter = 0;
    loop {
        log::info!("Pun!");

        esp_idf_hal::delay::FreeRtos::delay_ms(1000);

        notifying_characteristic
            .lock()
            .set_value(format!("Counter: {counter}").as_bytes())
            .notify();

        counter += 1;
    }
}
sdkconfig.default
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7000

CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=n
CONFIG_BT_NIMBLE_ENABLED=y

Rust version: 1.73.0-nightly (7ac9416d8 2023-07-24)
Rust target: riscv32imc-esp-espidf
Rust flags: rustflags = ["--cfg", "espidf_time64", "-C", "default-linker-libraries"]
Idf version: release/v5.1

Crash when there are devices around with invalid utf8 names

Hi, I have a neighbor with some random Chinese name device that crashes my APP whenever I try to scan with this lib

thread '<unnamed>' panicked at C:\Users\milewski\.cargo\registry\src\index.crates.io-6f17d22bba15001f\esp32-nimble-0.3.0\src\client\ble_advertised_device.rs:107:58:
called `Result::unwrap()` on an `Err` value: FromUtf8Error { bytes: [79, 84, 65, 0, 0, 0, 0, 0, 130, 0, 2, 0, 240, 110, 66, 117, 90, 90, 96], error: Utf8Error { valid_up_to: 8, error_len: Some(1) } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

image

Sending Characteristic between threads

Hey, I was trying to create a separate thread to send notifications as a server, but was unable to, because BLECharacteristic is not Send and not Sync. Hence I have a question: what is the point of wrapping characteristics in Arc Mutex if you can't share them between threads?

Passkey Size

Would it be worth adding documentation that the minimum passkey length is 6 digits for BLE

See here for reference
https://esp32.com/viewtopic.php?t=13124

So if you set a passkey to say '1234' the passkey will actually be '001234' I'm not sure if that's guaranteed or where that transform occurs, but that is how it currently works. I was struggling with it for a bit, may not be alone. (:

Turn the BLE on and off

Is there a way to turn the BLE on and off when an event happens? When a command is sent via UART for example

ESP32-C3 crashes when 2nd device connects in `ble_server` example

Steps to reproduce:

  • Change .cargo/config.toml to be for ESP32-C3
  • Change the command from espflash --monitor to espflash flash --monitor
  • cargo run --example ble_server
  • Connect to the ESP32-C3 with a device (I used LightBlue
  • Connect to the ESP32-C3 with another device while the first one is still connected

Error:

thread '<unnamed>' panicked at examples/ble_server.rs:20:42:
called `Result::unwrap()` on an `Err` value: Operation failed due to resource exhaustion.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

abort() was called at PC 0x4202b1f1 on core 0

Full log (the first part was not included because I reached the terminal max history):

I (43) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (43) boot: compile time Jun  7 2023 07:59:10
I (44) boot: chip revision: v0.4
I (48) boot.esp32c3: SPI Speed      : 40MHz
I (53) boot.esp32c3: SPI Mode       : DIO
I (57) boot.esp32c3: SPI Flash Size : 4MB
I (62) boot: Enabling RNG early entropy source...
I (68) boot: Partition Table:
I (71) boot: ## Label            Usage          Type ST Offset   Length
I (78) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (86) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (93) boot:  2 factory          factory app      00 00 00010000 003f0000
I (101) boot: End of partition table
I (105) esp_image: segment 0: paddr=00010020 vaddr=3c090020 size=2f650h (194128) map
I (156) esp_image: segment 1: paddr=0003f678 vaddr=3fc91200 size=009a0h (  2464) load
I (157) esp_image: segment 2: paddr=00040020 vaddr=42000020 size=8836ch (557932) map
I (284) esp_image: segment 3: paddr=000c8394 vaddr=3fc91ba0 size=01894h (  6292) load
I (286) esp_image: segment 4: paddr=000c9c30 vaddr=40380000 size=11198h ( 70040) load
I (312) boot: Loaded app from partition at offset 0x10000
I (312) boot: Disabling RNG early entropy source...
I (324) cpu_start: Unicore app
I (324) cpu_start: Pro cpu up.
I (333) cpu_start: Pro cpu start user code
I (333) cpu_start: cpu freq: 160000000 Hz
I (333) cpu_start: Application information:
I (336) cpu_start: Project name:     libespidf
I (341) cpu_start: App version:      v0.4.0-25-g75bb3e8-dirty
I (348) cpu_start: Compile time:     Jan  3 2024 13:10:34
I (354) cpu_start: ELF file SHA256:  0000000000000000...
I (360) cpu_start: ESP-IDF:          v5.1.1
I (364) cpu_start: Min chip rev:     v0.3
I (369) cpu_start: Max chip rev:     v0.99 
I (374) cpu_start: Chip rev:         v0.4
I (379) heap_init: Initializing. RAM available for dynamic allocation:
I (386) heap_init: At 3FC95ED0 len 00046840 (282 KiB): DRAM
I (392) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (399) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (406) spi_flash: detected chip: generic
I (410) spi_flash: flash io: dio
W (414) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
W (424) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`
I (433) sleep: Configure to isolate all GPIO pins in sleep state
I (440) sleep: Enable automatic switching of GPIO sleep configuration
I (447) coexist: coex firmware version: 80b0d89
I (452) coexist: coexist rom version 9387209
I (458) app_start: Starting scheduler on CPU0
I (462) main_task: Started on CPU0
I (462) main_task: Calling app_main()
I (472) BLE_INIT: BT controller compile version [963cad4]
I (472) phy_init: phy_version 970,1856f88,May 10 2023,17:44:12
I (522) BLE_INIT: Bluetooth MAC: ec:da:3b:35:6e:1a

I (522) esp32_nimble::ble_device: BLE Host Task Started
I (522) NimBLE: GAP procedure initiated: stop advertising.

I (522) esp32_nimble::ble_device: Device Address: EC:DA:3B:35:6E:1A
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid fafafafa-fafa-fafa-fafa-fafafafafafa
         handle 10
     end_handle 17
characteristic
           uuid d4e0e0d0-1a2b-11e9-ab14-d663bd873d93
     def_handle 11
     val_handle 12
   min_key_size 0
          flags [READ]
characteristic
           uuid a3c87500-8ed3-4bdf-8a39-a01bebede295
     def_handle 13
     val_handle 14
   min_key_size 0
          flags [READ|NOTIFY]
ccc descriptor
           uuid 0x2902
         handle 15
   min_key_size 0
          flags [READ|WRITE]
characteristic
           uuid 3c9a3f00-8ed3-4bdf-8a39-a01bebede295
     def_handle 16
     val_handle 17
   min_key_size 0
          flags [READ|WRITE]
I (652) NimBLE: GAP procedure initiated: advertise; 
I (652) NimBLE: disc_mode=2
I (652) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (662) NimBLE: 

I (1252) ble_server: Client connected
I (1252) NimBLE: GAP procedure initiated: 
I (1252) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (1262) NimBLE: 

I (1272) ble_server: Multi-connect support: start advertising
I (1272) NimBLE: GAP procedure initiated: advertise; 
I (1282) NimBLE: disc_mode=2
I (1282) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (1292) NimBLE: 

I (2472) ble_server: Client disconnected (205)
I (3392) ble_server: Client connected
I (3392) NimBLE: GAP procedure initiated: 
I (3392) NimBLE: connection parameter update; conn_handle=2 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (3402) NimBLE: 

I (3402) ble_server: Multi-connect support: start advertising
I (3412) NimBLE: GAP procedure initiated: advertise; 
I (3412) NimBLE: disc_mode=2
I (3422) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (3432) NimBLE: 

I (4632) ble_server: Client disconnected (205)
I (4742) ble_server: Client connected
I (4742) NimBLE: GAP procedure initiated: 
I (4742) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (4752) NimBLE: 

I (4752) ble_server: Multi-connect support: start advertising
I (4762) NimBLE: GAP procedure initiated: advertise; 
I (4762) NimBLE: disc_mode=2
I (4772) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (4782) NimBLE: 

I (5322) ble_server: Client connected
I (5322) NimBLE: GAP procedure initiated: 
I (5322) NimBLE: connection parameter update; conn_handle=2 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (5332) NimBLE: 

I (5332) ble_server: Multi-connect support: start advertising
I (5342) NimBLE: GAP procedure initiated: advertise; 
I (5342) NimBLE: disc_mode=2
I (5352) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (5362) NimBLE: 

I (5952) ble_server: Client disconnected (205)
I (6282) ble_server: Client connected
I (6282) NimBLE: GAP procedure initiated: 
I (6282) NimBLE: connection parameter update; conn_handle=3 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (6292) NimBLE: 

I (6292) ble_server: Multi-connect support: start advertising
I (6302) NimBLE: GAP procedure initiated: advertise; 
I (6302) NimBLE: disc_mode=2
I (6312) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (6322) NimBLE: 

I (7512) ble_server: Client disconnected (205)
I (7622) ble_server: Client connected
I (7632) NimBLE: GAP procedure initiated: 
I (7632) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (7642) NimBLE: 

I (7642) ble_server: Multi-connect support: start advertising
I (7652) NimBLE: GAP procedure initiated: advertise; 
I (7652) NimBLE: disc_mode=2
I (7662) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (7672) NimBLE: 

I (8832) ble_server: Client disconnected (205)
I (9502) ble_server: Client connected
I (9502) NimBLE: GAP procedure initiated: 
I (9502) NimBLE: connection parameter update; conn_handle=3 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (9512) NimBLE: 

I (9512) ble_server: Multi-connect support: start advertising
I (9522) NimBLE: GAP procedure initiated: advertise; 
I (9532) NimBLE: disc_mode=2
I (9532) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (9542) NimBLE: 

I (9882) ble_server: Client connected
I (9882) NimBLE: GAP procedure initiated: 
I (9882) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (9892) NimBLE: 

I (9892) ble_server: Multi-connect support: start advertising
thread '<unnamed>' panicked at examples/ble_server.rs:20:42:
called `Result::unwrap()` on an `Err` value: Operation failed due to resource exhaustion.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

abort() was called at PC 0x4202b1f1 on core 0
0x4202b1f1 - panic_abort::__rust_start_panic::abort
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort/src/lib.rs:43
Core  0 register dump:
MEPC    : 0x40381666  RA      : 0x4038a49c  SP      : 0x3fca9010  GP      : 0x3fc91a00  
0x40381666 - panic_abort
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/esp_system/panic.c:452
0x4038a49c - __ubsan_include
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/esp_system/ubsan.c:313
0x3fca9010 - vflash_mem
    at ??:??
0x3fc91a00 - coex_schm_ble_mesh_standby_bt_default_wifi_connecting
    at ??:??
TP      : 0x3fc7a6b8  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
0x3fc7a6b8 - esp_system_init_fn_init_components0
    at ??:??
0x37363534 - ??
    at ??:??
0x7271706f - s_rtc_timer_retain_mem
    at ??:??
0x33323130 - ??
    at ??:??
S0/FP   : 0x3fca904c  S1      : 0x3fca9030  A0      : 0x3fca904c  A1      : 0x3fca902e  
0x3fca904c - vflash_mem
    at ??:??
0x3fca9030 - vflash_mem
    at ??:??
0x3fca904c - vflash_mem
    at ??:??
0x3fca902e - vflash_mem
    at ??:??
A2      : 0x00000000  A3      : 0x3fca9079  A4      : 0x3fc94656  A5      : 0x3fc9465e  
0x00000000 - ??
    at ??:??
0x3fca9079 - vflash_mem
    at ??:??
0x3fc94656 - s_temperature_sensor_power_cnt
    at ??:??
0x3fc9465e - s_phy_digital_regs_mem
    at ??:??
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x3c09417c  S3      : 0x3fca9140  
0x7a797877 - s_rtc_timer_retain_mem
    at ??:??
0x76757473 - s_rtc_timer_retain_mem
    at ??:??
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x3fca9140 - vflash_mem
    at ??:??
S4      : 0x00000001  S5      : 0x00000000  S6      : 0x00000001  S7      : 0x00000000  
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
0x6e6d6c6b - s_rtc_timer_retain_mem
    at ??:??
0x6a696867 - s_rtc_timer_retain_mem
    at ??:??
0x66656463 - s_rtc_timer_retain_mem
    at ??:??
0x62613938 - s_rtc_timer_retain_mem
    at ??:??
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
0x00001801 - ??
    at ??:??
0x40380001 - _vector_table
    at ??:??
0x00000007 - ??
    at ??:??
0x00000000 - ??
    at ??:??
MHARTID : 0x00000000  
0x00000000 - ??
    at ??:??

Stack memory:
3fca9010: 0x00000004 0x00000000 0x3fca902c 0x4038fa20 0x00000000 0x00000000 0x3fca9e0c 0x40380030
0x00000004 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca902c - vflash_mem
    at ??:??
0x4038fa20 - __assert_func
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/newlib/assert.c:34
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca9e0c - vflash_mem
    at ??:??
0x40380030 - _vector_table
    at ??:??
3fca9030: 0x32303234 0x31663162 0x3fca9e00 0x3fc92948 0x3fca9030 0x3fc92964 0x3fca902c 0x726f6261
0x32303234 - ??
    at ??:??
0x31663162 - ??
    at ??:??
0x3fca9e00 - vflash_mem
    at ??:??
0x3fc92948 - __func__.0
    at ??:??
0x3fca9030 - vflash_mem
    at ??:??
0x3fc92964 - __func__.0
    at ??:??
0x3fca902c - vflash_mem
    at ??:??
0x726f6261 - s_rtc_timer_retain_mem
    at ??:??
3fca9050: 0x20292874 0x20736177 0x6c6c6163 0x61206465 0x43502074 0x34783020 0x62323032 0x20316631
0x20292874 - ??
    at ??:??
0x20736177 - ??
    at ??:??
0x6c6c6163 - s_rtc_timer_retain_mem
    at ??:??
0x61206465 - s_rtc_timer_retain_mem
    at ??:??
0x43502074 - intr_handler_set
    at ??:??
0x34783020 - ??
    at ??:??
0x62323032 - s_rtc_timer_retain_mem
    at ??:??
0x20316631 - ??
    at ??:??
3fca9070: 0x63206e6f 0x2065726f 0x00000030 0x40380000 0x3fca9df0 0x00000000 0x3fc9347c 0x4202b1f4
0x63206e6f - s_rtc_timer_retain_mem
    at ??:??
0x2065726f - ??
    at ??:??
0x00000030 - ??
    at ??:??
0x40380000 - _vector_table
    at ??:??
0x3fca9df0 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc9347c - _ZN3std9panicking4HOOK17h6e4fedcdb04c639dE
    at ??:??
0x4202b1f4 - panic_abort::__rust_start_panic::abort
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort/src/lib.rs:43
3fca9090: 0x3c09417c 0x00000000 0x00000000 0x42011aba 0x3fca9ecc 0x000000ac 0x00000000 0x42011668
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x42011aba - std::sys::unix::thread_local_key::get
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/sys/unix/thread_local_key.rs:22
0x3fca9ecc - vflash_mem
    at ??:??
0x000000ac - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x42011668 - std::sys::common::thread_local::os_local::Key<T>::get
    at ??:??
3fca90b0: 0x3c09417c 0x00000000 0x3fc9347c 0x42025bd4 0x3c09417c 0x00000000 0x3fc9347c 0x42024e3c
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc9347c - _ZN3std9panicking4HOOK17h6e4fedcdb04c639dE
    at ??:??
0x42025bd4 - std::thread::local::LocalKey<T>::try_with
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/thread/local.rs:269
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc9347c - _ZN3std9panicking4HOOK17h6e4fedcdb04c639dE
    at ??:??
0x42024e3c - std::panicking::rust_panic_with_hook
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/panicking.rs:753
3fca90d0: 0x00000000 0x00000000 0x3fca8360 0x4038aaea 0x3fca9144 0x3c09b2c0 0x3fca91b8 0x3c09027c
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038aaea - xQueueGenericSend
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:908
0x3fca9144 - vflash_mem
    at ??:??
0x3c09b2c0 - anon.a0b825c23b6c5bceab56088a2140e816.75.llvm.4102161038622529759
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
3fca90f0: 0x00000001 0x00000000 0x3fca8360 0x4038b208 0x00000000 0x00000000 0x00000000 0x3fc94a88
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038b208 - xQueueTakeMutexRecursive
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:788
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc94a88 - ble_gap_slave
    at ??:??
3fca9110: 0x00000000 0x3fca93bc 0x3fca8360 0x4038ac9c 0x00000000 0x00000000 0x00000000 0x3fca92bc
0x00000000 - ??
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038ac9c - xQueueGiveMutexRecursive
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:737
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca92bc - vflash_mem
    at ??:??
3fca9130: 0x3c09027c 0x3fca9188 0x3fca91b8 0x42007ab8 0x3fca91b8 0x3fca9ecc 0x000000ac 0x00000059
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3fca9188 - vflash_mem
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x42007ab8 - std::panicking::begin_panic_handler::{{closure}}
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x3fca9ecc - vflash_mem
    at ??:??
0x000000ac - ??
    at ??:??
0x00000059 - ??
    at ??:??
3fca9150: 0x3c09027c 0x3fca91b8 0x3fca9188 0x4200791a 0x3fca91b8 0x3fca9188 0x3c09027c 0x15000016
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x3fca9188 - vflash_mem
    at ??:??
0x4200791a - std::sys_common::backtrace::__rust_end_short_backtrace
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:173
0x3fca91b8 - vflash_mem
    at ??:??
0x3fca9188 - vflash_mem
    at ??:??
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x15000016 - ??
    at ??:??
3fca9170: 0x3fc9138c 0x3fc91354 0x00000001 0x4203aa1c 0x00000013 0x00000000 0x3c0a5684 0x3c0a5728
0x3fc9138c - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x3fc91354 - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x00000001 - ??
    at ??:??
0x4203aa1c - core::panicking::panic_fmt
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/panicking.rs:72
0x00000013 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3c0a5684 - anon.eafa7363aa718ec270aba380d2bec196.62.llvm.3332932360389494246
    at ??:??
0x3c0a5728 - anon.eafa7363aa718ec270aba380d2bec196.89.llvm.3332932360389494246
    at ??:??
3fca9190: 0x3fca91b8 0x3c09027c 0x3fc90001 0x42004390 0x00000000 0x00000000 0x3c0901b1 0x0000002b
0x3fca91b8 - vflash_mem
    at ??:??
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3fc90001 - esp_system_init_fn_init_components0
    at ??:??
0x42004390 - esp32_nimble::server::ble_advertising::BLEAdvertising::start_with_duration
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3c0901b1 - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x0000002b - ??
    at ??:??
3fca91b0: 0x3fca91ec 0x3c0901dc 0x3c0a58dc 0x00000002 0x3fca91d0 0x00000002 0x00000000 0x00000000
0x3fca91ec - vflash_mem
    at ??:??
0x3c0901dc - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3c0a58dc - anon.eafa7363aa718ec270aba380d2bec196.89.llvm.3332932360389494246
    at ??:??
0x00000002 - ??
    at ??:??
0x3fca91d0 - vflash_mem
    at ??:??
0x00000002 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca91d0: 0x3fca91a8 0x42038364 0x3fca91b0 0x4203835c 0x3fc9138c 0x3fc91354 0x00000001 0x00000006
0x3fca91a8 - vflash_mem
    at ??:??
0x42038364 - <&T as core::fmt::Display>::fmt
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:2288
0x3fca91b0 - vflash_mem
    at ??:??
0x4203835c - <&T as core::fmt::Debug>::fmt
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:2288
0x3fc9138c - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x3fc91354 - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x00000001 - ??
    at ??:??
0x00000006 - ??
    at ??:??
3fca91f0: 0x3fca96a0 0x00000000 0x3fca8360 0x4038a558 0x00000000 0x00000000 0x3fca8360 0x4038aaea
0x3fca96a0 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038a558 - prvCopyDataToQueue
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:2415
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038aaea - xQueueGenericSend
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:908
3fca9210: 0x00000001 0xfff00000 0x00000000 0x356e1a00 0x00ecda3b 0xc58895ae 0x1a004851 0xda3b356e
0x00000001 - ??
    at ??:??
0xfff00000 - s_rtc_timer_retain_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x356e1a00 - ??
    at ??:??
0x00ecda3b - ??
    at ??:??
0xc58895ae - s_rtc_timer_retain_mem
    at ??:??
0x1a004851 - ??
    at ??:??
0xda3b356e - s_rtc_timer_retain_mem
    at ??:??
3fca9230: 0x95ae00ec 0x4851c588 0x00300001 0x003c0000 0x3fca0101 0x3fca93bc 0x00000000 0x00000000
0x95ae00ec - s_rtc_timer_retain_mem
    at ??:??
0x4851c588 - intr_handler_set
    at ??:??
0x00300001 - ??
    at ??:??
0x003c0000 - ??
    at ??:??
0x3fca0101 - vflash_mem
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca9250: 0x356e1a00 0x00ecda3b 0xc58895ae 0x1a004851 0xda3b356e 0x95ae00ec 0x4851c588 0x00300001
0x356e1a00 - ??
    at ??:??
0x00ecda3b - ??
    at ??:??
0xc58895ae - s_rtc_timer_retain_mem
    at ??:??
0x1a004851 - ??
    at ??:??
0xda3b356e - s_rtc_timer_retain_mem
    at ??:??
0x95ae00ec - s_rtc_timer_retain_mem
    at ??:??
0x4851c588 - intr_handler_set
    at ??:??
0x00300001 - ??
    at ??:??
3fca9270: 0x003c0000 0x3fca0101 0x3fc913a8 0x00000000 0x00000001 0x3fca9310 0x3fc958c0 0x4205147c
0x003c0000 - ??
    at ??:??
0x3fca0101 - vflash_mem
    at ??:??
0x3fc913a8 - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h728d982ebf14b211E.llvm.9177407296607108776
    at ??:??
0x00000000 - ??
    at ??:??
0x00000001 - ??
    at ??:??
0x3fca9310 - vflash_mem
    at ??:??
0x3fc958c0 - ble_hs_conn_elem_mem
    at ??:??
0x4205147c - ble_gap_rd_rem_sup_feat_tx
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:1975
3fca9290: 0x420544b0 0x48400000 0x3fca9338 0x3fca9329 0x00000000 0x00000000 0x00000000 0x00000000
0x420544b0 - ble_gatts_chr_def_access
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_gatts.c:243
0x48400000 - intr_handler_set
    at ??:??
0x3fca9338 - vflash_mem
    at ??:??
0x3fca9329 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca92b0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca92d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca92f0: 0x3fca6420 0x00000000 0x00000000 0x3fc945ec 0x3fc945e8 0x3fc945fc 0x3fca5862 0x4204d9fc
0x3fca6420 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc945ec - g_eventq_dflt
    at ??:??
0x3fc945e8 - ble_hs_ev_stop
    at ??:??
0x3fc945fc - npl_funcs
    at ??:??
0x3fca5862 - vflash_mem
    at ??:??
0x4204d9fc - ble_hs_hci_evt_le_enh_conn_complete
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:469
3fca9310: 0x00010000 0x95ae0001 0x4851c588 0x00000030 0x0001003c 0x00000000 0x00000000 0x00000000
0x00010000 - ??
    at ??:??
0x95ae0001 - s_rtc_timer_retain_mem
    at ??:??
0x4851c588 - intr_handler_set
    at ??:??
0x00000030 - ??
    at ??:??
0x0001003c - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca9330: 0x3fc945fc 0x3fca5860 0x3fca5860 0x4204db16 0x3fc945e8 0x3fc945fc 0x3fc94870 0x40382d00
0x3fc945fc - npl_funcs
    at ??:??
0x3fca5860 - vflash_mem
    at ??:??
0x3fca5860 - vflash_mem
    at ??:??
0x4204db16 - ble_hs_hci_evt_process
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:1023
0x3fc945e8 - ble_hs_ev_stop
    at ??:??
0x3fc945fc - npl_funcs
    at ??:??
0x3fc94870 - ble_hs_hci_os_event_buf
    at ??:??
0x40382d00 - nimble_port_run
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/porting/nimble/src/nimble_port.c:256
3fca9350: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x42005c3e
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x42005c3e - esp32_nimble::ble_device::BLEDevice::blecent_host_task
    at /var/home/rajas/Documents/esp32-nimble/src/ble_device.rs:300
3fca9370: 0x3c0929bc 0x00000001 0x3c09288c 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x3c0929bc - str.1.llvm.12882497722226090508
    at ??:??
0x00000001 - ??
    at ??:??
0x3c09288c - str.1.llvm.12882497722226090508
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca9390: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
3fca93b0: 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x3fca8e50 0x3fc95ee4 0x3fc9381c 0x3fc9381c 0x3fca93bc
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0x00000154 - ??
    at ??:??
0x3fca8e50 - vflash_mem
    at ??:??
0x3fc95ee4 - vflash_mem
    at ??:??
0x3fc9381c - pxReadyTasksLists
    at ??:??
0x3fc9381c - pxReadyTasksLists
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
3fca93d0: 0x3fc93814 0x00000004 0x3fca80c8 0x3fca80c8 0x3fca93bc 0x00000000 0x00000015 0x3fca83b8
0x3fc93814 - pxReadyTasksLists
    at ??:??
0x00000004 - ??
    at ??:??
0x3fca80c8 - vflash_mem
    at ??:??
0x3fca80c8 - vflash_mem
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000015 - ??
    at ??:??
0x3fca83b8 - vflash_mem
    at ??:??
3fca93f0: 0x626d696e 0x685f656c 0x0074736f 0x00c968d0 0x00000000 0x3fca93b0 0x00000015 0x00000000
0x626d696e - s_rtc_timer_retain_mem
    at ??:??
0x685f656c - s_rtc_timer_retain_mem
    at ??:??
0x0074736f - ??
    at ??:??
0x00c968d0 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca93b0 - vflash_mem
    at ??:??
0x00000015 - ??
    at ??:??
0x00000000 - ??
    at ??:??



ELF file SHA256: 0000000000000000

Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x40048b82
0x40048b82 - vflash_mem
    at ??:??
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x171c
0x3fcd5820 - vflash_mem
    at ??:??
load:0x403cc710,len:0x968
0x403cc710 - spi_flash_chip_winbond_page_program
    at ??:??
load:0x403ce710,len:0x2f68
0x403ce710 - spi_flash_chip_winbond_page_program
    at ??:??
SHA-256 comparison failed:
Calculated: 1d06b938c0222bf626e0bdf46178b1b37ab24d03f0360fc8fcf7153c2571deaf
Expected: 68d7bdf643ba446b8ed7ae8423241d442fd052b2bc77091100ba06fd65dcf8d5
Attempting to boot anyway...
entry 0x403cc710
0x403cc710 - spi_flash_chip_winbond_page_program
    at ??:??
I (42) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (42) boot: compile time Jun  7 2023 07:59:10
I (43) boot: chip revision: v0.4
I (47) boot.esp32c3: SPI Speed      : 40MHz
I (52) boot.esp32c3: SPI Mode       : DIO
I (57) boot.esp32c3: SPI Flash Size : 4MB
I (62) boot: Enabling RNG early entropy source...
I (67) boot: Partition Table:
I (71) boot: ## Label            Usage          Type ST Offset   Length
I (78) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (85) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (93) boot:  2 factory          factory app      00 00 00010000 003f0000
I (100) boot: End of partition table
I (105) esp_image: segment 0: paddr=00010020 vaddr=3c090020 size=2f650h (194128) map
I (156) esp_image: segment 1: paddr=0003f678 vaddr=3fc91200 size=009a0h (  2464) load
I (157) esp_image: segment 2: paddr=00040020 vaddr=42000020 size=8836ch (557932) map
I (283) esp_image: segment 3: paddr=000c8394 vaddr=3fc91ba0 size=01894h (  6292) load
I (285) esp_image: segment 4: paddr=000c9c30 vaddr=40380000 size=11198h ( 70040) load
I (312) boot: Loaded app from partition at offset 0x10000
I (312) boot: Disabling RNG early entropy source...
I (323) cpu_start: Unicore app
I (323) cpu_start: Pro cpu up.
I (332) cpu_start: Pro cpu start user code
I (332) cpu_start: cpu freq: 160000000 Hz
I (333) cpu_start: Application information:
I (335) cpu_start: Project name:     libespidf
I (341) cpu_start: App version:      v0.4.0-25-g75bb3e8-dirty
I (347) cpu_start: Compile time:     Jan  3 2024 13:10:34
I (353) cpu_start: ELF file SHA256:  0000000000000000...
I (359) cpu_start: ESP-IDF:          v5.1.1
I (364) cpu_start: Min chip rev:     v0.3
I (369) cpu_start: Max chip rev:     v0.99 
I (373) cpu_start: Chip rev:         v0.4
I (378) heap_init: Initializing. RAM available for dynamic allocation:
I (386) heap_init: At 3FC95ED0 len 00046840 (282 KiB): DRAM
I (392) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (398) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (406) spi_flash: detected chip: generic
I (409) spi_flash: flash io: dio
W (414) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
W (424) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`
I (433) sleep: Configure to isolate all GPIO pins in sleep state
I (439) sleep: Enable automatic switching of GPIO sleep configuration
I (447) coexist: coex firmware version: 80b0d89
I (452) coexist: coexist rom version 9387209
I (457) app_start: Starting scheduler on CPU0
I (462) main_task: Started on CPU0
I (462) main_task: Calling app_main()
I (472) BLE_INIT: BT controller compile version [963cad4]
I (472) phy_init: phy_version 970,1856f88,May 10 2023,17:44:12
I (522) BLE_INIT: Bluetooth MAC: ec:da:3b:35:6e:1a

I (522) esp32_nimble::ble_device: BLE Host Task Started
I (532) NimBLE: GAP procedure initiated: stop advertising.

I (532) esp32_nimble::ble_device: Device Address: EC:DA:3B:35:6E:1A
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid fafafafa-fafa-fafa-fafa-fafafafafafa
         handle 10
     end_handle 17
characteristic
           uuid d4e0e0d0-1a2b-11e9-ab14-d663bd873d93
     def_handle 11
     val_handle 12
   min_key_size 0
          flags [READ]
characteristic
           uuid a3c87500-8ed3-4bdf-8a39-a01bebede295
     def_handle 13
     val_handle 14
   min_key_size 0
          flags [READ|NOTIFY]
ccc descriptor
           uuid 0x2902
         handle 15
   min_key_size 0
          flags [READ|WRITE]
characteristic
           uuid 3c9a3f00-8ed3-4bdf-8a39-a01bebede295
     def_handle 16
     val_handle 17
   min_key_size 0
          flags [READ|WRITE]
I (652) NimBLE: GAP procedure initiated: advertise; 
I (652) NimBLE: disc_mode=2
I (662) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (672) NimBLE: 

I (732) ble_server: Client connected
I (732) NimBLE: GAP procedure initiated: 
I (732) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (742) NimBLE: 

I (752) ble_server: Multi-connect support: start advertising
I (762) NimBLE: GAP procedure initiated: advertise; 
I (762) NimBLE: disc_mode=2
I (762) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (772) NimBLE: 

Bonding issue

I'm not terribly familiar with BTLE pairing processes, so please forgive my ignorance, but I'm not able to get a connection to persist across resets. It looks like the process I need is called "bonding", which I have enabled (it is also enabled in the keyboard example, which is what I'm primarily interested in).

I have tried a significant number of things, going so far as manually adding extern blocks to pull in functionality from ESP-IDF that the crate doesn't expose. I have tried enabling RPD by patching the library, using CONFIG_BT_NIMBLE_NVS_PERSIST=y in my sdkconfig.defaults file, and much more. It looked like I almost got it with RPD enabled, but I got some error about a resolve list being missing and couldn't find any information on the topic.

When I use the NimBLE library in Arduino, it works, but not here. I'd very much like to rewrite that code in Rust so I can get a more reliable and high-level system working. Any help would be greatly appreciated.

I'm hoping someone else who has had this issue can lead me in the right direction? How can I get a bonded connection to persist across resets?

Unable to use ESP32 as both BLE client and server simultaneously

I'm trying to use my ESP32 as a BLE client and server simultaneously, but I've encountered some problems on the way.

The goal is:

  1. ESP32 connects to Bluetooth buttons via BLE (acting as a client).
  2. Registers for BLE events.
  3. Remaps these events and send them over BLE to a secondary device using the keyboard example provided in this repository (acting as a server).

While I can successfully receive notifications from the BLE buttons, I cannot send them to the keyboard. I have a working solution in C++ using NimBLE-Arduino & ESP32-BLE-Keyboard but am facing difficulties with this library.

I've tried the following versions of ESP IDF:

  • 4.4.6
  • 5.0
  • 5.1.0

Hardware & Software:

  • Tested on both ESP32 (dual core) and ESP32-C3.
  • Utilized the following libraries and versions from my Cargo.toml:
[dependencies]
esp-idf-svc = { version = "0.47", ... }
esp-idf-hal = { version = "0.42", ... }
esp-idf-sys = { version = "0.33", ... }
esp32-nimble = { git = "https://github.com/taks/esp32-nimble.git", branch = "develop" }
...

For the ESP32-C3, my .cargo/config.toml target configuration is:

[build]
target = "riscv32imc-esp-espidf"

Failed Attempts:

1. Starting the keyboard (server) after connecting to the BLE buttons (client)

Code:

client.on_connect(move |_client| {
  info!("Connected to device");
  let keyboard = Keyboard::new();
  *keyboard_ref_clone.lock() = Some(keyboard);
});

Error:

assert failed: ble_svc_gap_init ble_svc_gap.c:297 (rc == 0)
...

2. Creating the keyboard after the setup is complete, after subscribing to the client for notifications

Code:

characteristic.on_notify(move |_data| {
 info!("Received notification from device");
}).subscribe_notify(false).await.unwrap();

let keyboard_ref_clone = Arc::clone(&keyboard_ref);
let keyboard = Keyboard::new();
*keyboard_ref_clone.lock() = Some(keyboard);

Error:

assert failed: ble_svc_gap_init ble_svc_gap.c:297 (rc == 0)
...

3. Using lazy_static for the keyboard

Code:

lazy_static! {
  static ref KEYBOARD: Mutex<Keyboard> = Mutex::new(Keyboard::new());
}

// in main
characteristic.on_notify(move |data| {
  let mut keyboard = KEYBOARD.lock();
  keyboard.write("Message");
});

Error:

assert failed: ble_svc_gap_init ble_svc_gap.c:297 (rc == 0)
...

4. Just using the Keyboard example without connecting to the client

This works!

#[no_mangle]
fn app_main() {
  esp_idf_sys::link_patches();
  esp_idf_svc::log::EspLogger::initialize_default();
  esp_idf_svc::timer::embassy_time::driver::link();

  info!("Setup connection to BLE buttons");

  block_on(async {
    let mut keyboard = Keyboard::new();
    loop {
      keyboard.write("Hello world");
      Timer::after(Duration::from_secs(1)).await;
    }
  });
}

5. Initialising the keyboard before scanning for devices

Code:

#[no_mangle]
fn app_main() {
  esp_idf_sys::link_patches();
  esp_idf_svc::log::EspLogger::initialize_default();
  esp_idf_svc::timer::embassy_time::driver::link();

  KEYBOARD.lock().write("Hello world");
  block_on(async {
	// ...
  });

Error:

No error, but the ESP can no longer receive notifications.

Full Code:

I've attached the full code for you to look at, but without the failing examples above.

#![no_main]
#![feature(never_type)]

extern crate esp_idf_hal;
extern crate lazy_static;
extern crate log;

mod keyboard;

use embassy_time::Duration;
use embassy_time::Timer;
use esp32_nimble::utilities::{mutex::Mutex, BleUuid, BleUuid::Uuid16};
use esp32_nimble::{BLEClient, BLEDevice};
use esp_idf_hal::task::block_on;
use keyboard::Keyboard;
use log::{info, warn};
use std::sync::Arc;

const SERVICE_UUID: BleUuid = Uuid16(0x1812);
const CHAR_UUID: BleUuid = Uuid16(0x2A4D);
const BLE_BUTTONS_NAME: &str = "tob";

#[no_mangle]
fn app_main() {
  esp_idf_sys::link_patches();
  esp_idf_svc::log::EspLogger::initialize_default();
  esp_idf_svc::timer::embassy_time::driver::link();

  info!("Setup connection to BLE buttons");
  block_on(async {
    let device = BLEDevice::take();
    let scan = device.get_scan();

    let connect_device = Arc::new(Mutex::new(None));
    let connect_device_clone = Arc::clone(&connect_device);

    scan.active_scan(true).interval(490).window(450).on_result(move |found_device| {
      if !found_device.is_advertising_service(&SERVICE_UUID) {
        return;
      }

      if !found_device.name().starts_with(BLE_BUTTONS_NAME) {
        return;
      }

      info!("Found device: {:?}", found_device.name());
      *connect_device_clone.lock() = Some(found_device.clone());
      BLEDevice::take().get_scan().stop().expect("Failed to stop scan");
    });

    scan.start(i32::MAX).await.expect("Failed to start scan");

    let Some(device) = &*connect_device.lock() else {
      return warn!("No device found");
    };

    let mut client = BLEClient::new();

    client.connect(device.addr()).await.expect("Failed to connect to device");

    let service = client.get_service(SERVICE_UUID).await.expect("Failed to get service");
    let characteristic = service.get_characteristic(CHAR_UUID).await.expect("Failed to get characteristic");

    characteristic
      .on_notify(move |_data| {
        info!("Received notification from device");
      })
      .subscribe_notify(false)
      .await
      .expect("Failed to subscribe to notifications");

    info!("Waiting for notifications ...");

    loop {
      Timer::after(Duration::from_secs(1)).await;
    }
  });
}

Here's the complete stack trace (IDF = 4.4.6):

ble_svc_gap_init ble_svc_gap.c:297
I (50) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (50) boot: compile time Jun  7 2023 07:59:10
I (51) boot: chip revision: v0.4
I (55) boot.esp32c3: SPI Speed      : 40MHz
I (60) boot.esp32c3: SPI Mode       : DIO
I (65) boot.esp32c3: SPI Flash Size : 4MB
I (69) boot: Enabling RNG early entropy source...
I (75) boot: Partition Table:
I (78) boot: ## Label            Usage          Type ST Offset   Length
I (86) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (93) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (101) boot:  2 factory          factory app      00 00 00010000 003f0000
I (108) boot: End of partition table
I (112) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1ad50h (109904) map
I (145) esp_image: segment 1: paddr=0002ad78 vaddr=3fc91a00 size=02b90h ( 11152) load
I (148) esp_image: segment 2: paddr=0002d910 vaddr=40380000 size=02708h (  9992) load
I (153) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=92ad8h (600792) map
I (290) esp_image: segment 4: paddr=000c2b00 vaddr=40382708 size=0f120h ( 61728) load
I (311) boot: Loaded app from partition at offset 0x10000
I (312) boot: Disabling RNG early entropy source...
I (323) cpu_start: Unicore app
I (323) cpu_start: Pro cpu up.
I (332) cpu_start: Pro cpu start user code
I (332) cpu_start: cpu freq: 160000000
I (332) cpu_start: Application information:
I (335) cpu_start: Project name:     libespidf
I (340) cpu_start: App version:      v1.1.1-9-g40f8558-dirty
I (347) cpu_start: Compile time:     Oct 24 2023 00:40:10
I (353) cpu_start: ELF file SHA256:  0000000000000000...
I (359) cpu_start: ESP-IDF:          v4.4.6-dirty
I (364) cpu_start: Min chip rev:     v0.3
I (369) cpu_start: Max chip rev:     v0.99
I (374) cpu_start: Chip rev:         v0.4
I (378) heap_init: Initializing. RAM available for dynamic allocation:
I (386) heap_init: At 3FC96E60 len 000458B0 (278 KiB): DRAM
I (392) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (398) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
I (406) spi_flash: detected chip: generic
I (410) spi_flash: flash io: dio
I (414) sleep: Configure to isolate all GPIO pins in sleep state
I (420) sleep: Enable automatic switching of GPIO sleep configuration
I (427) coexist: coexist rom version 9387209
I (432) cpu_start: Starting scheduler.
I (437) u701: Setup connection to BLE buttons
I (447) BLE_INIT: BT controller compile version [59725b5]
I (447) system_api: Base MAC address is not set
I (447) system_api: read default base MAC address from EFUSE
I (457) BLE_INIT: Bluetooth MAC: ec:da:3b:15:fc:1e

I (457) phy_init: phy_version 1110,9c20f0a,Jul 27 2023,10:42:54
I (517) esp32_nimble::ble_device: BLE Host Task Started
I (517) NimBLE: GAP procedure initiated: stop advertising.

I (527) esp32_nimble::ble_device: Device Address: EC:DA:3B:15:FC:1E
I (527) NimBLE: GAP procedure initiated: discovery;
I (527) NimBLE: own_addr_type=0 filter_policy=0 passive=0 limited=0 filter_duplicates=1
I (537) NimBLE: duration=forever
I (547) NimBLE:

I (587) u701: Found device: "tob"
I (597) NimBLE: GAP procedure initiated: connect;
I (597) NimBLE: peer_addr_type=0 peer_addr=
I (597) NimBLE: 60:55:f9:ca:d6:0a
I (597) NimBLE:  scan_itvl=16 scan_window=16 itvl_min=24 itvl_max=40 latency=0 supervision_timeout=256 min_ce_len=0 max_ce_len=0 own_addr_type=0
I (607) NimBLE:

I (657) NimBLE: GATT procedure initiated: exchange mtu

I (747) esp32_nimble::client::ble_client: mtu update event; conn_handle=1 mtu=256
I (747) NimBLE: GATT procedure initiated: discover all services

I (847) NimBLE: GATT procedure initiated: discover all characteristics;
I (847) NimBLE: start_handle=15 end_handle=34

I (1047) NimBLE: GATT procedure initiated: discover all characteristics;
I (1047) NimBLE: start_handle=25 end_handle=34

I (1147) NimBLE: GATT procedure initiated: discover all descriptors;
I (1147) NimBLE: chr_val_handle=25 end_handle=30

I (1247) NimBLE: GATT procedure initiated: write no rsp;
I (1247) NimBLE: att_handle=26 len=2

I (1247) u701: Waiting for notifications ...

assert failed: ble_svc_gap_init ble_svc_gap.c:297 (rc == 0)
Core  0 register dump:
MEPC    : 0x40381f40  RA      : 0x40389904  SP      : 0x3fca72a0  GP      : 0x3fc92200
0x40381f40 - panic_abort
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/esp_system/panic.c:408
0x40389904 - __ubsan_include
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/esp_system/ubsan.c:294
0x3fca72a0 - _heap_start
    at ??:??
0x3fc92200 - __global_pointer$
    at ??:??
TP      : 0x3fc8cab8  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130
0x3fc8cab8 - __eh_frame_hdr
    at ??:??
0x37363534 -
    at ??:??
0x7271706f - USB_SERIAL_JTAG
    at ??:??
0x33323130 -
    at ??:??
S0/FP   : 0x0000008c  S1      : 0x00000001  A0      : 0x3fca72dc  A1      : 0x3fc9396d
0x0000008c - RV_STK_MTVAL
    at ??:??
0x00000001 -
    at ??:??
0x3fca72dc - _heap_start
    at ??:??
0x3fc9396d - _btdm_data_end
    at ??:??
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x3fc94f30  A5      : 0x3fc94f38
0x00000001 -
    at ??:??
0x00000029 - RV_STK_A0
    at ??:??
0x3fc94f30 - xIsrStack
    at ??:??
0x3fc94f38 - xIsrStack
    at ??:??
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000009  S3      : 0x3fca73eb
0x7a797877 - USB_SERIAL_JTAG
    at ??:??
0x76757473 - USB_SERIAL_JTAG
    at ??:??
0x00000009 - RV_STK_SP
    at ??:??
0x3fca73eb - _heap_start
    at ??:??
S4      : 0x3fc9396c  S5      : 0x3fc927e8  S6      : 0x3fc9283c  S7      : 0x3fca74a8
0x3fc9396c - _btdm_data_end
    at ??:??
0x3fc927e8 - _ZN12esp32_nimble10ble_device10BLE_SERVER17ha606c21abf767d10E
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x3fca74a8 - _heap_start
    at ??:??
S8      : 0x00000001  S9      : 0x3fc927e8  S10     : 0x3fc95610  S11     : 0x00000000
0x00000001 -
    at ??:??
0x3fc927e8 - _ZN12esp32_nimble10ble_device10BLE_SERVER17ha606c21abf767d10E
    at ??:??
0x3fc95610 - _ZN3std6thread8ThreadId3new7COUNTER17h53a6e9131d7b68c7E.llvm.15977218726786850347
    at ??:??
0x00000000 -
    at ??:??
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938
0x6e6d6c6b - USB_SERIAL_JTAG
    at ??:??
0x6a696867 - USB_SERIAL_JTAG
    at ??:??
0x66656463 - USB_SERIAL_JTAG
    at ??:??
0x62613938 - USB_SERIAL_JTAG
    at ??:??
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000
0x00001881 -
    at ??:??
0x40380001 - _vector_table
    at ??:??
0x00000007 - RV_STK_RA
    at ??:??
0x00000000 -
    at ??:??
MHARTID : 0x00000000
0x00000000 -
    at ??:??

Stack memory:
3fca72a0: 0x4038c8da 0x4038c908 0x3c0b32e0 0x40390032 0x3fc93a54 0x3c0b32e0 0x3fc93e6c 0x3c0b3363
0x4038c8da - vPortClearInterruptMask
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/port/riscv/port.c:308
0x4038c908 - vPortExitCritical
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/port/riscv/port.c:262
0x3c0b32e0 - __func__.7414
    at ??:??
0x40390032 - newlib_include_assert_impl
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/newlib/assert.c:97
0x3fc93a54 - __func__.2605
    at ??:??
0x3c0b32e0 - __func__.7414
    at ??:??
0x3fc93e6c - CSWTCH.170
    at ??:??
0x3c0b3363 - ble_svc_gap_defs
    at ??:??
3fca72c0: 0x3fc93a64 0x3fca72d4 0x3fc93a68 0x3c0b3278 0x3fc9396c 0x00373932 0x00000000 0x65737361
0x3fc93a64 - __func__.2605
    at ??:??
0x3fca72d4 - _heap_start
    at ??:??
0x3fc93a68 - __func__.2605
    at ??:??
0x3c0b3278 - ble_svc_gatt_defs
    at ??:??
0x3fc9396c - _btdm_data_end
    at ??:??
0x00373932 -
    at ??:??
0x00000000 -
    at ??:??
0x65737361 - USB_SERIAL_JTAG
    at ??:??
3fca72e0: 0x66207472 0x656c6961 0x62203a64 0x735f656c 0x675f6376 0x695f7061 0x2074696e 0x5f656c62
0x66207472 - USB_SERIAL_JTAG
    at ??:??
0x656c6961 - USB_SERIAL_JTAG
    at ??:??
0x62203a64 - USB_SERIAL_JTAG
    at ??:??
0x735f656c - USB_SERIAL_JTAG
    at ??:??
0x675f6376 - USB_SERIAL_JTAG
    at ??:??
0x695f7061 - USB_SERIAL_JTAG
    at ??:??
0x2074696e -
    at ??:??
0x5f656c62 - _rtc_force_slow_start
    at ??:??
3fca7300: 0x5f637673 0x2e706167 0x39323a63 0x72282037 0x3d3d2063 0x00293020 0x00000000 0x4038bd84
0x5f637673 - _rtc_force_slow_start
    at ??:??
0x2e706167 -
    at ??:??
0x39323a63 -
    at ??:??
0x72282037 - USB_SERIAL_JTAG
    at ??:??
0x3d3d2063 - __eh_frame_hdr
    at ??:??
0x00293020 -
    at ??:??
0x00000000 -
    at ??:??
0x4038bd84 - xTaskPriorityDisinherit
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/tasks.c:4807
3fca7320: 0x00000000 0x00000000 0x3fca6740 0x40389ba4 0x00000000 0x00000000 0x3fca6740 0x4038a194
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x40389ba4 - prvCopyDataToQueue
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:2246
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x4038a194 - xQueueGenericSend
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:1043
3fca7340: 0x00000000 0x00000000 0x3fca6740 0x00000000 0x00000000 0x00001800 0x3fc97570 0xffffffff
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00001800 -
    at ??:??
0x3fc97570 - _heap_start
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
3fca7360: 0x00000000 0x00000001 0x3fca94b4 0x3fca9304 0x3fca779c 0x3fca6740 0x00000001 0x4038a344
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x3fca94b4 - _heap_start
    at ??:??
0x3fca9304 - _heap_start
    at ??:??
0x3fca779c - _heap_start
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x4038a344 - xQueueGiveMutexRecursive
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:685
3fca7380: 0x3c0b3300 0x00000001 0x3fc957b4 0x4205ecf8 0x3fc9283c 0x00000001 0x0000000f 0x42052888
0x3c0b3300 - ble_svc_gap_defs
    at ??:??
0x00000001 -
    at ??:??
0x3fc957b4 - ble_hs_mutex
    at ??:??
0x4205ecf8 - npl_freertos_mutex_release
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:212
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000001 -
    at ??:??
0x0000000f - RV_STK_GP
    at ??:??
0x42052888 - ble_hs_unlock_nested
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:195
3fca73a0: 0x3fca9140 0x00000000 0x00000000 0x42000000 0x3fc92904 0x00000001 0x3fca94b4 0x3fca9304
0x3fca9140 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x42000000 - _iram_end
    at ??:??
0x3fc92904 - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000001 -
    at ??:??
0x3fca94b4 - _heap_start
    at ??:??
0x3fca9304 - _heap_start
    at ??:??
3fca73c0: 0x3fca9140 0x00000001 0x3fc9283c 0x4204fd7e 0x00000000 0x00000000 0x3fc9283c 0x4200b6f0
0x3fca9140 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x4204fd7e - ble_store_util_iter_count
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_store_util.c:194
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x4200b6f0 - esp32_nimble::server::ble_server::BLEServer::start
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/server/ble_server.rs:88
3fca73e0: 0x0000000f 0x3fc9290c 0x3fc9283c 0x00000000 0x3fc95610 0x3fc9283c 0x00000001 0x3fca74a8
0x0000000f - RV_STK_GP
    at ??:??
0x3fc9290c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000000 -
    at ??:??
0x3fc95610 - _ZN3std6thread8ThreadId3new7COUNTER17h53a6e9131d7b68c7E.llvm.15977218726786850347
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000001 -
    at ??:??
0x3fca74a8 - _heap_start
    at ??:??
3fca7400: 0x3fc9283c 0x3fc927e8 0x3fca94b4 0x3fca9304 0x3fca9140 0x00000001 0x3fc9283c 0x4200acde
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x3fc927e8 - _ZN12esp32_nimble10ble_device10BLE_SERVER17ha606c21abf767d10E
    at ??:??
0x3fca94b4 - _heap_start
    at ??:??
0x3fca9304 - _heap_start
    at ??:??
0x3fca9140 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x4200acde - esp32_nimble::server::ble_advertising::BLEAdvertising::start_with_duration
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/server/ble_advertising.rs:222
3fca7420: 0x3fca9140 0x3fca8bf8 0x3fca8bf0 0x420028ce 0x3fca8aa8 0x3fca8b64 0x3fca8bf0 0x3fca8cbc
0x3fca9140 - _heap_start
    at ??:??
0x3fca8bf8 - _heap_start
    at ??:??
0x3fca8bf0 - _heap_start
    at ??:??
0x420028ce - core::result::Result<T,E>::unwrap
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/result.rs:1075
0x3fca8aa8 - _heap_start
    at ??:??
0x3fca8b64 - _heap_start
    at ??:??
0x3fca8bf0 - _heap_start
    at ??:??
0x3fca8cbc - _heap_start
    at ??:??
3fca7440: 0x3fca8d48 0x3fca8dc0 0x3fca8e38 0x3fca8eb0 0x3fca8f7c 0x3fca9070 0x3fca9664 0x4205f202
0x3fca8d48 - _heap_start
    at ??:??
0x3fca8dc0 - _heap_start
    at ??:??
0x3fca8e38 - _heap_start
    at ??:??
0x3fca8eb0 - _heap_start
    at ??:??
0x3fca8f7c - _heap_start
    at ??:??
0x3fca9070 - _heap_start
    at ??:??
0x3fca9664 - _heap_start
    at ??:??
0x4205f202 - os_memblock_put_from_cb
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/nimble/src/os_mempool.c:287
3fca7460: 0x18120000 0x00000000 0x00000000 0x4205f22c 0x00000000 0x3fc945b0 0x3fc91a24 0x3fca7502
0x18120000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x4205f22c - os_memblock_put
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/nimble/src/os_mempool.c:328
0x00000000 -
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x3fc91a24 - _ZN3std10sys_common11thread_info11THREAD_INFO7__getit5__KEY17h81085a841406b003E.llvm.13851875188132569457
    at ??:??
0x3fca7502 - _heap_start
    at ??:??
3fca7480: 0xffffffff 0xffffffff 0x00000001 0x00000002 0x00000000 0x3fc94590 0x3fc945b0 0x420012f4
0xffffffff - USB_SERIAL_JTAG
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
0x00000001 -
    at ??:??
0x00000002 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc94590 - _noinit_start
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x420012f4 - core::ptr::read
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1180
3fca74a0: 0x0f000102 0x06000b00 0xaa490700 0x15f641f9 0xfbec0ca5 0x00000000 0x3fca0494 0x4038a194
0x0f000102 -
    at ??:??
0x06000b00 -
    at ??:??
0xaa490700 - USB_SERIAL_JTAG
    at ??:??
0x15f641f9 -
    at ??:??
0xfbec0ca5 - USB_SERIAL_JTAG
    at ??:??
0x00000000 -
    at ??:??
0x3fca0494 - _heap_start
    at ??:??
0x4038a194 - xQueueGenericSend
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:1043
3fca74c0: 0x00000003 0xff000fff 0x00000025 0x00000000 0x00000000 0x00000000 0x3fca0494 0x4038bd84
0x00000003 -
    at ??:??
0xff000fff - USB_SERIAL_JTAG
    at ??:??
0x00000025 - RV_STK_S1
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca0494 - _heap_start
    at ??:??
0x4038bd84 - xTaskPriorityDisinherit
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/tasks.c:4807
3fca74e0: 0x00000000 0x00000019 0x3fc945b0 0x4200d3ae 0x3c0a0a5c 0x3c0a0884 0x3fca7560 0x00000000
0x00000000 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x4200d3ae - core::cell::Cell<T>::get
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/cell.rs:500
0x3c0a0a5c - anon.c4c334a0304349482020d54e395477f7.20.llvm.3730123182963330635
    at ??:??
0x3c0a0884 - anon.c4c334a0304349482020d54e395477f7.1.llvm.3730123182963330635
    at ??:??
0x3fca7560 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
3fca7500: 0x3fc945b0 0x00000000 0x3fce0000 0x00000000 0x00000003 0x4204ed00 0x00000000 0xffffffff
0x3fc945b0 - _bss_start
    at ??:??
0x00000000 -
    at ??:??
0x3fce0000 - ets_ops_table_ptr
    at ??:??
0x00000000 -
    at ??:??
0x00000003 -
    at ??:??
0x4204ed00 - semphr_take_wrapper
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/controller/esp32c3/bt.c:580
0x00000000 -
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
3fca7520: 0x00000000 0x00000001 0x3fc9a248 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x3fc9a248 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
3fca7540: 0x00000000 0x00000000 0x3fc9a248 0x00000001 0x00000000 0x00000019 0x3fc945b0 0x42002d12
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc9a248 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x00000000 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x42002d12 - std::sync::once::Once::call_once
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/sync/once.rs:149
3fca7560: 0x3fca7580 0x00000001 0x3fca763c 0x4200588e 0x00000000 0x00000000 0x3fca6740 0x3fc94590
0x3fca7580 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x3fca763c - _heap_start
    at ??:??
0x4200588e - esp32_nimble::client::ble_client::BLEClient::handle_gap_event
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/client/ble_client.rs:391
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x3fc94590 - _noinit_start
    at ??:??
3fca7580: 0x00000000 0x00000019 0x3fca765c 0x4200585c 0x00000000 0x00000000 0x3fca6740 0x4038a194
0x00000000 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x3fca765c - _heap_start
    at ??:??
0x4200585c - <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x4038a194 - xQueueGenericSend
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:1043
3fca75a0: 0x00000000 0x00000001 0x3fc96224 0x00000000 0x3fca779c 0x3fca6740 0x00000001 0xffffffff
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x3fc96224 - ble_hs_conn_elem_mem
    at ??:??
0x00000000 -
    at ??:??
0x3fca779c - _heap_start
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
3fca75c0: 0x00000000 0x00000001 0x0000001b 0x00000001 0x3fca779c 0x3fca6740 0x00000001 0x4038a344
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x0000001b - RV_STK_T1
    at ??:??
0x00000001 -
    at ??:??
0x3fca779c - _heap_start
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x4038a344 - xQueueGiveMutexRecursive
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:685
3fca75e0: 0x3fca763c 0x3fca7638 0x3fc957b4 0x4205ecf8 0x00000000 0x3fca7638 0x3fc96224 0x42052888
0x3fca763c - _heap_start
    at ??:??
0x3fca7638 - _heap_start
    at ??:??
0x3fc957b4 - ble_hs_mutex
    at ??:??
0x4205ecf8 - npl_freertos_mutex_release
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:212
0x00000000 -
    at ??:??
0x3fca7638 - _heap_start
    at ??:??
0x3fc96224 - ble_hs_conn_elem_mem
    at ??:??
0x42052888 - ble_hs_unlock_nested
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:195
3fca7600: 0x00000000 0x00000000 0x0000001b 0x00000001 0x00000000 0x3fc95ee8 0x3fca765c 0x420577a6
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x0000001b - RV_STK_T1
    at ??:??
0x00000001 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc95ee8 - ble_l2cap_chan_mem
    at ??:??
0x3fca765c - _heap_start
    at ??:??
0x420577a6 - ble_gap_call_event_cb
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:735
3fca7620: 0x00000000 0x3fc95ee8 0x3fca765c 0x42057a9c 0x00000000 0x00000000 0x3fc9a248 0x42005404
0x00000000 -
    at ??:??
0x3fc95ee8 - ble_l2cap_chan_mem
    at ??:??
0x3fca765c - _heap_start
    at ??:??
0x42057a9c - ble_gap_call_conn_event_cb
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:751
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc9a248 - _heap_start
    at ??:??
0x42005404 - esp32_nimble::client::ble_client::BLEClient::handle_gap_event
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/client/ble_client.rs:237
3fca7640: 0x00000000 0x3fc95ee8 0x00000001 0x4205a00c 0x00000000 0x00000000 0x3fca6740 0x0000000c
0x00000000 -
    at ??:??
0x3fc95ee8 - ble_l2cap_chan_mem
    at ??:??
0x00000001 -
    at ??:??
0x4205a00c - ble_gap_notify_rx_event
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:6142
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x0000000c - RV_STK_GP
    at ??:??
3fca7660: 0x3fca4d70 0x00010019 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x3fca4d70 - _heap_start
    at ??:??
0x00010019 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
3fca7680: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000001 0x00000019 0x42062928
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x42062928 - ble_att_svr_rx_notify
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_att_svr.c:2484



ELF file SHA256: 0000000000000000

Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40381ad0
0x40381ad0 - esp_restart_noos_dig
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/esp_system/esp_system.c:53
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x171c
0x3fcd5820 - _heap_start
    at ??:??
load:0x403cc710,len:0x968
0x403cc710 - _iram_end
    at ??:??
load:0x403ce710,len:0x2f68
0x403ce710 - _iram_end
    at ??:??
SHA-256 comparison failed:
Calculated: 1d06b938c0222bf626e0bdf46178b1b37ab24d03f0360fc8fcf7153c2571deaf
Expected: 68d7bdf643ba446b8ed7ae8423241d442fd052b2bc77091100ba06fd65dcf8d5
Attempting to boot anyway...
entry 0x403cc710
0x403cc710 - _iram_end
    at ??:??
I (53) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (53) boot: compile time Jun  7 2023 07:59:10
I (55) boot: chip revision: v0.4
I (59) boot.esp32c3: SPI Speed      : 40MHz
I (63) boot.esp32c3: SPI Mode       : DIO
I (68) boot.esp32c3: SPI Flash Size : 4MB
I (73) boot: Enabling RNG early entropy source...
I (78) boot: Partition Table:
I (82) boot: ## Label            Usage          Type ST Offset   Length
I (89) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (97) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (104) boot:  2 factory          factory app      00 00 00010000 003f0000
I (112) boot: End of partition table
I (116) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1b550h (111952) map
I (149) esp_image: segment 1: paddr=0002b578 vaddr=3fc91a00 size=02b90h ( 11152) load
I (152) esp_image: segment 2: paddr=0002e110 vaddr=40380000 size=01f08h (  7944) load
I (157) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=93dach (605612) map
I (295) esp_image: segment 4: paddr=000c3dd4 vaddr=40381f08 size=0f920h ( 63776) load
I (317) boot: Loaded app from partition at offset 0x10000
I (317) boot: Disabling RNG early entropy source...
I (329) cpu_start: Unicore app
I (329) cpu_start: Pro cpu up.
I (338) cpu_start: Pro cpu start user code
I (338) cpu_start: cpu freq: 160000000
I (338) cpu_start: Application information:
I (341) cpu_start: Project name:     libespidf
I (346) cpu_start: App version:      v1.1.1-9-g40f8558-dirty
I (352) cpu_start: Compile time:     Oct 24 2023 00:02:27
I (358) cpu_start: ELF file SHA256:  0000000000000000...
I (364) cpu_start: ESP-IDF:          v4.4.6-dirty
I (370) cpu_start: Min chip rev:     v0.3
I (374) cpu_start: Max chip rev:     v0.99
I (379) cpu_start: Chip rev:         v0.4
I (384) heap_init: Initializing. RAM available for dynamic allocation:
I (391) heap_init: At 3FC96E80 len 00045890 (278 KiB): DRAM
I (397) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (404) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
I (411) spi_flash: detected chip: generic
I (415) spi_flash: flash io: dio
I (420) sleep: Configure to isolate all GPIO pins in sleep state
I (426) sleep: Enable automatic switching of GPIO sleep configuration
I (433) coexist: coexist rom version 9387209
I (438) cpu_start: Starting scheduler.
I (443) u701: Setup connection to BLE buttons
I (453) BLE_INIT: BT controller compile version [59725b5]
I (453) system_api: Base MAC address is not set
I (453) system_api: read default base MAC address from EFUSE
I (463) BLE_INIT: Bluetooth MAC: ec:da:3b:15:fc:1e

I (463) phy_init: phy_version 1110,9c20f0a,Jul 27 2023,10:42:54
I (513) esp32_nimble::ble_device: BLE Host Task Started
I (523) NimBLE: GAP procedure initiated: stop advertising.

I (523) esp32_nimble::ble_device: Device Address: EC:DA:3B:15:FC:1E
I (523) NimBLE: GAP procedure initiated: discovery;
I (533) NimBLE: own_addr_type=0 filter_policy=0 passive=0 limited=0 filter_duplicates=1
I (543) NimBLE: duration=forever
I (543) NimBLE:

I (2153) u701: Found device: "tob"
I (2153) NimBLE: GAP procedure initiated: connect;
I (2153) NimBLE: peer_addr_type=0 peer_addr=
I (2153) NimBLE: 60:55:f9:ca:d6:0a
I (2163) NimBLE:  scan_itvl=16 scan_window=16 itvl_min=24 itvl_max=40 latency=0 supervision_timeout=256 min_ce_len=0 max_ce_len=0 own_addr_type=0
I (2173) NimBLE:

I (2223) NimBLE: GATT procedure initiated: exchange mtu

I (2303) esp32_nimble::client::ble_client: mtu update event; conn_handle=1 mtu=256
I (2303) NimBLE: GATT procedure initiated: discover all services

I (2403) NimBLE: GATT procedure initiated: discover all characteristics;
I (2403) NimBLE: start_handle=15 end_handle=34

I (2603) NimBLE: GATT procedure initiated: discover all characteristics;
I (2603) NimBLE: start_handle=25 end_handle=34

I (2703) NimBLE: GATT procedure initiated: discover all descriptors;
I (2703) NimBLE: chr_val_handle=25 end_handle=30

I (2803) NimBLE: GATT procedure initiated: write no rsp;
I (2803) NimBLE: att_handle=26 len=2

I (2803) u701: Waiting for notifications ...

assert failed: ble_svc_gap_init ble_svc_gap.c:297 (rc == 0)
Core  0 register dump:
MEPC    : 0x40381f40  RA      : 0x40389904  SP      : 0x3fca72a0  GP      : 0x3fc92200
0x40381f40 - panic_abort
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/esp_system/panic.c:408
0x40389904 - __ubsan_include
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/esp_system/ubsan.c:294
0x3fca72a0 - _heap_start
    at ??:??
0x3fc92200 - __global_pointer$
    at ??:??
TP      : 0x3fc8cab8  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130
0x3fc8cab8 - __eh_frame_hdr
    at ??:??
0x37363534 -
    at ??:??
0x7271706f - USB_SERIAL_JTAG
    at ??:??
0x33323130 -
    at ??:??
S0/FP   : 0x0000008c  S1      : 0x00000001  A0      : 0x3fca72dc  A1      : 0x3fc9396d
0x0000008c - RV_STK_MTVAL
    at ??:??
0x00000001 -
    at ??:??
0x3fca72dc - _heap_start
    at ??:??
0x3fc9396d - _btdm_data_end
    at ??:??
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x3fc94f30  A5      : 0x3fc94f38
0x00000001 -
    at ??:??
0x00000029 - RV_STK_A0
    at ??:??
0x3fc94f30 - xIsrStack
    at ??:??
0x3fc94f38 - xIsrStack
    at ??:??
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x00000009  S3      : 0x3fca73eb
0x7a797877 - USB_SERIAL_JTAG
    at ??:??
0x76757473 - USB_SERIAL_JTAG
    at ??:??
0x00000009 - RV_STK_SP
    at ??:??
0x3fca73eb - _heap_start
    at ??:??
S4      : 0x3fc9396c  S5      : 0x3fc927e8  S6      : 0x3fc9283c  S7      : 0x3fca74a8
0x3fc9396c - _btdm_data_end
    at ??:??
0x3fc927e8 - _ZN12esp32_nimble10ble_device10BLE_SERVER17ha606c21abf767d10E
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x3fca74a8 - _heap_start
    at ??:??
S8      : 0x00000001  S9      : 0x3fc927e8  S10     : 0x3fc95610  S11     : 0x00000000
0x00000001 -
    at ??:??
0x3fc927e8 - _ZN12esp32_nimble10ble_device10BLE_SERVER17ha606c21abf767d10E
    at ??:??
0x3fc95610 - _ZN3std6thread8ThreadId3new7COUNTER17h53a6e9131d7b68c7E.llvm.15977218726786850347
    at ??:??
0x00000000 -
    at ??:??
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938
0x6e6d6c6b - USB_SERIAL_JTAG
    at ??:??
0x6a696867 - USB_SERIAL_JTAG
    at ??:??
0x66656463 - USB_SERIAL_JTAG
    at ??:??
0x62613938 - USB_SERIAL_JTAG
    at ??:??
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000
0x00001881 -
    at ??:??
0x40380001 - _vector_table
    at ??:??
0x00000007 - RV_STK_RA
    at ??:??
0x00000000 -
    at ??:??
MHARTID : 0x00000000
0x00000000 -
    at ??:??

Stack memory:
3fca72a0: 0x4038c8da 0x4038c908 0x3c0b32e0 0x40390032 0x3fc93a54 0x3c0b32e0 0x3fc93e6c 0x3c0b3363
0x4038c8da - vPortClearInterruptMask
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/port/riscv/port.c:308
0x4038c908 - vPortExitCritical
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/port/riscv/port.c:262
0x3c0b32e0 - __func__.7414
    at ??:??
0x40390032 - newlib_include_assert_impl
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/newlib/assert.c:97
0x3fc93a54 - __func__.2605
    at ??:??
0x3c0b32e0 - __func__.7414
    at ??:??
0x3fc93e6c - CSWTCH.170
    at ??:??
0x3c0b3363 - ble_svc_gap_defs
    at ??:??
3fca72c0: 0x3fc93a64 0x3fca72d4 0x3fc93a68 0x3c0b3278 0x3fc9396c 0x00373932 0x00000000 0x65737361
0x3fc93a64 - __func__.2605
    at ??:??
0x3fca72d4 - _heap_start
    at ??:??
0x3fc93a68 - __func__.2605
    at ??:??
0x3c0b3278 - ble_svc_gatt_defs
    at ??:??
0x3fc9396c - _btdm_data_end
    at ??:??
0x00373932 -
    at ??:??
0x00000000 -
    at ??:??
0x65737361 - USB_SERIAL_JTAG
    at ??:??
3fca72e0: 0x66207472 0x656c6961 0x62203a64 0x735f656c 0x675f6376 0x695f7061 0x2074696e 0x5f656c62
0x66207472 - USB_SERIAL_JTAG
    at ??:??
0x656c6961 - USB_SERIAL_JTAG
    at ??:??
0x62203a64 - USB_SERIAL_JTAG
    at ??:??
0x735f656c - USB_SERIAL_JTAG
    at ??:??
0x675f6376 - USB_SERIAL_JTAG
    at ??:??
0x695f7061 - USB_SERIAL_JTAG
    at ??:??
0x2074696e -
    at ??:??
0x5f656c62 - _rtc_force_slow_start
    at ??:??
3fca7300: 0x5f637673 0x2e706167 0x39323a63 0x72282037 0x3d3d2063 0x00293020 0x00000000 0x4038bd84
0x5f637673 - _rtc_force_slow_start
    at ??:??
0x2e706167 -
    at ??:??
0x39323a63 -
    at ??:??
0x72282037 - USB_SERIAL_JTAG
    at ??:??
0x3d3d2063 - __eh_frame_hdr
    at ??:??
0x00293020 -
    at ??:??
0x00000000 -
    at ??:??
0x4038bd84 - xTaskPriorityDisinherit
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/tasks.c:4807
3fca7320: 0x00000000 0x00000000 0x3fca6740 0x40389ba4 0x00000000 0x00000000 0x3fca6740 0x4038a194
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x40389ba4 - prvCopyDataToQueue
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:2246
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x4038a194 - xQueueGenericSend
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:1043
3fca7340: 0x00000000 0x00000000 0x3fca6740 0x00000000 0x00000000 0x00001800 0x3fc97570 0xffffffff
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00001800 -
    at ??:??
0x3fc97570 - _heap_start
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
3fca7360: 0x00000000 0x00000001 0x3fca9470 0x3fca92c0 0x3fca779c 0x3fca6740 0x00000001 0x4038a344
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x3fca9470 - _heap_start
    at ??:??
0x3fca92c0 - _heap_start
    at ??:??
0x3fca779c - _heap_start
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x4038a344 - xQueueGiveMutexRecursive
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:685
3fca7380: 0x3c0b3300 0x00000001 0x3fc957b4 0x4205ecf8 0x3fc9283c 0x00000001 0x0000000f 0x42052888
0x3c0b3300 - ble_svc_gap_defs
    at ??:??
0x00000001 -
    at ??:??
0x3fc957b4 - ble_hs_mutex
    at ??:??
0x4205ecf8 - npl_freertos_mutex_release
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:212
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000001 -
    at ??:??
0x0000000f - RV_STK_GP
    at ??:??
0x42052888 - ble_hs_unlock_nested
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:195
3fca73a0: 0x3fca90fc 0x00000000 0x00000000 0x42000000 0x3fc92904 0x00000001 0x3fca9470 0x3fca92c0
0x3fca90fc - _heap_start
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x42000000 - _iram_end
    at ??:??
0x3fc92904 - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000001 -
    at ??:??
0x3fca9470 - _heap_start
    at ??:??
0x3fca92c0 - _heap_start
    at ??:??
3fca73c0: 0x3fca90fc 0x00000001 0x3fc9283c 0x4204fd7e 0x00000000 0x00000000 0x3fc9283c 0x4200b6f0
0x3fca90fc - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x4204fd7e - ble_store_util_iter_count
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_store_util.c:194
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x4200b6f0 - esp32_nimble::server::ble_server::BLEServer::start
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/server/ble_server.rs:88
3fca73e0: 0x0000000f 0x3fc9290c 0x3fc9283c 0x00000000 0x3fc95610 0x3fc9283c 0x00000001 0x3fca74a8
0x0000000f - RV_STK_GP
    at ??:??
0x3fc9290c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000000 -
    at ??:??
0x3fc95610 - _ZN3std6thread8ThreadId3new7COUNTER17h53a6e9131d7b68c7E.llvm.15977218726786850347
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x00000001 -
    at ??:??
0x3fca74a8 - _heap_start
    at ??:??
3fca7400: 0x3fc9283c 0x3fc927e8 0x3fca9470 0x3fca92c0 0x3fca90fc 0x00000001 0x3fc9283c 0x4200acde
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x3fc927e8 - _ZN12esp32_nimble10ble_device10BLE_SERVER17ha606c21abf767d10E
    at ??:??
0x3fca9470 - _heap_start
    at ??:??
0x3fca92c0 - _heap_start
    at ??:??
0x3fca90fc - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x3fc9283c - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h8776a8e1a8464ad4E.llvm.4422737608252036301
    at ??:??
0x4200acde - esp32_nimble::server::ble_advertising::BLEAdvertising::start_with_duration
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/server/ble_advertising.rs:222
3fca7420: 0x3fca90fc 0x3fca8bb4 0x3fca8bac 0x420028ce 0x3fca8a64 0x3fca8b20 0x3fca8bac 0x3fca8c78
0x3fca90fc - _heap_start
    at ??:??
0x3fca8bb4 - _heap_start
    at ??:??
0x3fca8bac - _heap_start
    at ??:??
0x420028ce - core::result::Result<T,E>::unwrap
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/result.rs:1075
0x3fca8a64 - _heap_start
    at ??:??
0x3fca8b20 - _heap_start
    at ??:??
0x3fca8bac - _heap_start
    at ??:??
0x3fca8c78 - _heap_start
    at ??:??
3fca7440: 0x3fca8d04 0x3fca8d7c 0x3fca8df4 0x3fca8e6c 0x3fca8f38 0x3fca902c 0x3fca9620 0x4205f202
0x3fca8d04 - _heap_start
    at ??:??
0x3fca8d7c - _heap_start
    at ??:??
0x3fca8df4 - _heap_start
    at ??:??
0x3fca8e6c - _heap_start
    at ??:??
0x3fca8f38 - _heap_start
    at ??:??
0x3fca902c - _heap_start
    at ??:??
0x3fca9620 - _heap_start
    at ??:??
0x4205f202 - os_memblock_put_from_cb
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/nimble/src/os_mempool.c:287
3fca7460: 0x18120000 0x00000000 0x00000000 0x4205f22c 0x00000000 0x3fc945b0 0x3fc91a24 0x3fca7502
0x18120000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x4205f22c - os_memblock_put
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/nimble/src/os_mempool.c:328
0x00000000 -
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x3fc91a24 - _ZN3std10sys_common11thread_info11THREAD_INFO7__getit5__KEY17h81085a841406b003E.llvm.13851875188132569457
    at ??:??
0x3fca7502 - _heap_start
    at ??:??
3fca7480: 0xffffffff 0xffffffff 0x00000001 0x00000002 0x00000000 0x3fc94590 0x3fc945b0 0x420012f4
0xffffffff - USB_SERIAL_JTAG
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
0x00000001 -
    at ??:??
0x00000002 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc94590 - _noinit_start
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x420012f4 - core::ptr::read
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1180
3fca74a0: 0x0f000102 0x06000b00 0x16aa0700 0x2fb1e34b 0xa3eb235a 0x00000000 0x3fca0494 0x4038a194
0x0f000102 -
    at ??:??
0x06000b00 -
    at ??:??
0x16aa0700 -
    at ??:??
0x2fb1e34b -
    at ??:??
0xa3eb235a - USB_SERIAL_JTAG
    at ??:??
0x00000000 -
    at ??:??
0x3fca0494 - _heap_start
    at ??:??
0x4038a194 - xQueueGenericSend
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:1043
3fca74c0: 0x00000003 0xff000fff 0x00000025 0x00000000 0x00000000 0x00000000 0x3fca0494 0x4038bd84
0x00000003 -
    at ??:??
0xff000fff - USB_SERIAL_JTAG
    at ??:??
0x00000025 - RV_STK_S1
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca0494 - _heap_start
    at ??:??
0x4038bd84 - xTaskPriorityDisinherit
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/tasks.c:4807
3fca74e0: 0x00000000 0x00000019 0x3fc945b0 0x4200d3ae 0x3c0a0a5c 0x3c0a0884 0x3fca7560 0x00000000
0x00000000 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x4200d3ae - core::cell::Cell<T>::get
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/cell.rs:500
0x3c0a0a5c - anon.c4c334a0304349482020d54e395477f7.20.llvm.3730123182963330635
    at ??:??
0x3c0a0884 - anon.c4c334a0304349482020d54e395477f7.1.llvm.3730123182963330635
    at ??:??
0x3fca7560 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
3fca7500: 0x3fc945b0 0x00000000 0x3fce0000 0x00000000 0x00000003 0x4204ed00 0x00000000 0xffffffff
0x3fc945b0 - _bss_start
    at ??:??
0x00000000 -
    at ??:??
0x3fce0000 - ets_ops_table_ptr
    at ??:??
0x00000000 -
    at ??:??
0x00000003 -
    at ??:??
0x4204ed00 - semphr_take_wrapper
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/controller/esp32c3/bt.c:580
0x00000000 -
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
3fca7520: 0x00000000 0x00000001 0x3fc9a248 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x3fc9a248 - _heap_start
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
3fca7540: 0x00000000 0x00000000 0x3fc9a248 0x00000001 0x00000000 0x00000019 0x3fc945b0 0x42002d12
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc9a248 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x00000000 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x3fc945b0 - _bss_start
    at ??:??
0x42002d12 - std::sync::once::Once::call_once
    at ~/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/sync/once.rs:149
3fca7560: 0x3fca7580 0x00000001 0x3fca763c 0x4200588e 0x00000000 0x00000000 0x3fca6740 0x3fc94590
0x3fca7580 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x3fca763c - _heap_start
    at ??:??
0x4200588e - esp32_nimble::client::ble_client::BLEClient::handle_gap_event
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/client/ble_client.rs:391
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x3fc94590 - _noinit_start
    at ??:??
3fca7580: 0x00000000 0x00000019 0x3fca765c 0x4200585c 0x00000000 0x00000000 0x3fca6740 0x4038a194
0x00000000 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x3fca765c - _heap_start
    at ??:??
0x4200585c - <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x4038a194 - xQueueGenericSend
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:1043
3fca75a0: 0x00000000 0x00000001 0x3fc96224 0x00000000 0x3fca779c 0x3fca6740 0x00000001 0xffffffff
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x3fc96224 - ble_hs_conn_elem_mem
    at ??:??
0x00000000 -
    at ??:??
0x3fca779c - _heap_start
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0xffffffff - USB_SERIAL_JTAG
    at ??:??
3fca75c0: 0x00000000 0x00000001 0x0000001b 0x00000001 0x3fca779c 0x3fca6740 0x00000001 0x4038a344
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x0000001b - RV_STK_T1
    at ??:??
0x00000001 -
    at ??:??
0x3fca779c - _heap_start
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x00000001 -
    at ??:??
0x4038a344 - xQueueGiveMutexRecursive
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/freertos/queue.c:685
3fca75e0: 0x3fca763c 0x3fca7638 0x3fc957b4 0x4205ecf8 0x00000000 0x3fca7638 0x3fc96224 0x42052888
0x3fca763c - _heap_start
    at ??:??
0x3fca7638 - _heap_start
    at ??:??
0x3fc957b4 - ble_hs_mutex
    at ??:??
0x4205ecf8 - npl_freertos_mutex_release
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c:212
0x00000000 -
    at ??:??
0x3fca7638 - _heap_start
    at ??:??
0x3fc96224 - ble_hs_conn_elem_mem
    at ??:??
0x42052888 - ble_hs_unlock_nested
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_hs.c:195
3fca7600: 0x00000000 0x00000000 0x0000001b 0x00000001 0x00000000 0x3fc95ee8 0x3fca765c 0x420577a6
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x0000001b - RV_STK_T1
    at ??:??
0x00000001 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc95ee8 - ble_l2cap_chan_mem
    at ??:??
0x3fca765c - _heap_start
    at ??:??
0x420577a6 - ble_gap_call_event_cb
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:735
3fca7620: 0x00000000 0x3fc95ee8 0x3fca765c 0x42057a9c 0x00000000 0x00000000 0x3fc9a248 0x42005404
0x00000000 -
    at ??:??
0x3fc95ee8 - ble_l2cap_chan_mem
    at ??:??
0x3fca765c - _heap_start
    at ??:??
0x42057a9c - ble_gap_call_conn_event_cb
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:751
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fc9a248 - _heap_start
    at ??:??
0x42005404 - esp32_nimble::client::ble_client::BLEClient::handle_gap_event
    at ~/.cargo/git/checkouts/esp32-nimble-fc9d2c54a3bfa7fe/87fdceb/src/client/ble_client.rs:237
3fca7640: 0x00000000 0x3fc95ee8 0x00000001 0x4205a00c 0x00000000 0x00000000 0x3fca6740 0x0000000c
0x00000000 -
    at ??:??
0x3fc95ee8 - ble_l2cap_chan_mem
    at ??:??
0x00000001 -
    at ??:??
0x4205a00c - ble_gap_notify_rx_event
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:6142
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x3fca6740 - _heap_start
    at ??:??
0x0000000c - RV_STK_GP
    at ??:??
3fca7660: 0x3fca4d70 0x00010019 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x3fca4d70 - _heap_start
    at ??:??
0x00010019 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
3fca7680: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000001 0x00000019 0x42062928
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000000 -
    at ??:??
0x00000001 -
    at ??:??
0x00000019 - RV_STK_T1
    at ??:??
0x42062928 - ble_att_svr_rx_notify
    at ~/Code/u701-rs/.embuild/espressif/esp-idf/v4.4.6/components/bt/host/nimble/nimble/nimble/host/src/ble_att_svr.c:2484

Any guidance or assistance would be greatly appreciated. Thank you!

Direct call "start" on service, stop processing subscription and notifications/indications

First of all, thanks for the great job you did migrating nimble to rust.

I am moving project which used nimble-arduino, and found odd thing:

I we directly call start on BleService, we didn't receive any updates about subscription and notifications/indications, here example:

use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use log::*;
use esp32_nimble::{uuid128, BLEDevice, NimbleProperties};

fn main() {
    // It is necessary to call this function once. Otherwise some patches to the runtime
    // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
    esp_idf_sys::link_patches();
    // Bind the log crate to the ESP Logging facilities
    esp_idf_svc::log::EspLogger::initialize_default();

    info!("Hello, world!");
    let ble_device = BLEDevice::take();

    ble_device
        .security()
        .set_auth(false, false, false);

    let server = ble_device.get_server();
    server.on_connect(|server, desc| {
        ::log::info!("Client connected");

        server
            .update_conn_params(desc.conn_handle, 24, 48, 0, 60)
            .unwrap();

        ::log::info!("Multi-connect support: start advertising");
        ble_device.get_advertising().start().unwrap();
    });
    let service = server.create_service(uuid128!("fafafafa-fafa-fafa-fafa-fafafafafafa"));

    // A characteristic that notifies every second.
    let notifying_characteristic = service.lock().create_characteristic(
        uuid128!("a3c87500-8ed3-4bdf-8a39-a01bebede295"),
        NimbleProperties::WRITE
            | NimbleProperties::WRITE_NO_RSP
            | NimbleProperties::WRITE_ENC
            | NimbleProperties::NOTIFY,
    );

    notifying_characteristic.lock()
        .on_read(move |_, _| {
            ::log::info!("Read from writable characteristic.");
        })
        .on_write(move |args| {
            ::log::info!("Wrote to writable characteristic: {:?}", args.recv_data);
        })
        .on_subscribe(move |desc, sub_value| {
            ::log::info!("Client ID: {:?} sub_value: {:?}", desc.conn_handle, sub_value);
        })
        .on_notify_tx(move |args| {
            ::log::info!("on_notify_tx {:?}", args.status());
        });

    notifying_characteristic.lock().set_value(b"Initial value.");

    service.lock().start().unwrap();


    let ble_advertising = ble_device.get_advertising();
    ble_advertising
        .name("ESP32-GATT-Server")
        .add_service_uuid(uuid128!("fafafafa-fafa-fafa-fafa-fafafafafafa"));

    ble_advertising.start().unwrap();

    let mut counter = 0;
    loop {
        esp_idf_hal::delay::FreeRtos::delay_ms(1000);
        notifying_characteristic
            .lock()
            .set_value(format!("Counter: {counter}").as_bytes())
            .notify();

        counter += 1;
    }
}

After connect via any ble scanner and subsribe on notifications on notifying_characteristic, I don't see any logs.

If I comment service.lock().start().unwrap(); everthing work as expected, and I see in logs:

....
I (81692) test_ble_2: Client ID: 1 sub_value: NOTIFY
I (82652) NimBLE: GATT procedure initiated: notify; 
I (82652) NimBLE: att_handle=12

I (82652) test_ble_2: on_notify_tx SuccessNotify
I (83652) NimBLE: GATT procedure initiated: notify; 
I (83652) NimBLE: att_handle=12
....

I found that on server start we have calls "start" for every ble services, and seems we have issue when we call "start" two times. As I see nimble-arduino contains logic to handle multiple calls of start on services.

manufacturer data

I really like your project and your work in this.
But the only thing I am missing is an access to the manufacturer data.
There is just a getter function missing for the manufacturer data.

Add missing return codes for security manager

Add missing return codes for security manager to BLEReturnCode

pub fn return_code_to_string(rc: u32) -> Option<&'static str> {

https://mynewt.apache.org/latest/network/ble_hs/ble_hs_return_codes.html#return-codes-security-manager-us

As a secondary point might be useful to consider returning BLEReturnCode in some additional places. i.e.

callback: impl Fn(&BLEConnDesc, c_int) + Send + Sync + 'static,

instead of c_int, which then begs the question should BLEReturnCode inner be a i32 or is u32 correct.

pub struct BLEReturnCode(pub u32);

Reading connection strength

Not really an issue but rather a question, so if this is not the right place for that, I'd be happy to post where it should be.

I've been using esp32-nimble crate a for a small DIY project (basically doing https://www.thingiverse.com/thing:2146425 but with esp32-c3, Rust, and over Bluetooth). One thing I would like to add to my remote controller is connection strength information.

There's a get_power on BLEDevice https://taks.github.io/esp32-nimble/esp32_nimble/struct.BLEDevice.html#method.get_power but I suspect it just returns the configured power transmit, and not the actual signal level ?

There is also rssi exposed on BLEAdvertisedDevice https://taks.github.io/esp32-nimble/esp32_nimble/struct.BLEAdvertisedDevice.html#method.rssi ; does it means one need to keep track of the BLEAdvertisedDevice after connection to keep the signal information, or this is only valid after sanning for bluetooth devices ? (I suspect it is the latter).

Searching for RSSI on Espressif's docs yields only https://docs.espressif.com/projects/esp-idf/en/v5.1.1/esp32c3/api-reference/bluetooth/esp_gap_ble.html?highlight=read_rssi#_CPPv421esp_ble_gap_read_rssi13esp_bd_addr_t which I suspect is what is exposed by BLEAdverisedDevice::rssi() ?

So, question is: is there a way to get signal strength on a live connection ? Or one of the above is the right solution ?

How to not stop advertising when a device is bonded?

I am using a characteristic that needs authentication to read. Once I connect to it with one device, the advertising stops, making me unable to detect the ESP32-C3 from a different device. Is there a way to make the advertising not stop or to immediately start advertising again?

W (2928) esp32_nimble::server::ble_server: unhandled event: 18
I (15698) esp32_nimble::server::ble_server: AuthenticationComplete
W (15698) esp32_nimble::server::ble_server: unhandled event: 16
I (15698) NimBLE: GAP procedure initiated: stop advertising.

Can't add more than one 128 uuid to an BLEAdvertising

When I add more than one service id to a BLEAdvertising using the add_service_uuid() method, the program panics with the following error message:
thread 'main' panicked at 'called Result::unwrap() on an Err value: The provided buffer is too small.
This is the code I have:
`
let ble_advertising = ble_device_unlocked.get_advertising();
ble_advertising
.name("Torrot Kids");

ble_advertising.add_service_uuid(BleUuid::from_uuid128_string(SETTINGS_CHARACTERISTIC_UUID).unwrap());
ble_advertising.add_service_uuid(BleUuid::from_uuid128_string(BATTERY_SERVICE_UUID).unwrap());

ble_advertising.start().unwrap();

`

The panic occurs in the "ble_advertising.start().unwrap();"

If I add just one service id to a BLEAdvertising it works but when I try to add more than one, the program start to panic.

I'm using a ESP32C3 chip.

Is there any solution for this?

Thanks and I'm sorry for not be able to find the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.