Skip to content

Commit a0ad048

Browse files
authored
Merge branch 'master' into add-mqtt-v5-protocol
2 parents 7f52e84 + d33fd0c commit a0ad048

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6691
-1091
lines changed

.cargo/config.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[build]
22
target = "riscv32imc-esp-espidf"
3+
#target = "riscv32imac-esp-espidf"
34
#target = "xtensa-esp32-espidf"
45

56
[target.xtensa-esp32-espidf]
@@ -24,7 +25,8 @@ rustflags = ["--cfg", "espidf_time64"]
2425

2526
[env]
2627
ESP_IDF_SDKCONFIG_DEFAULTS = ".github/configs/sdkconfig.defaults"
27-
ESP_IDF_VERSION = "v5.3.2"
28+
ESP_IDF_VERSION = "v5.4.2"
29+
#ESP_IDF_VERSION = "release/v5.3" Necessary for `Thread::stop`
2830

2931
[unstable]
3032
build-std = ["std", "panic_abort"]

.github/configs/sdkconfig.defaults

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
22
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
33

44
# Examples often require a larger than the default stack size for the main thread and for the sysloop event task.
5-
CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 # Necessary when the `embassy-time-driver` feature is enabled
5+
# Necessary when the `embassy-time-driver` feature is enabled
6+
CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096
67
CONFIG_ESP_MAIN_TASK_STACK_SIZE=20000
78
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192
89
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=8192
@@ -18,22 +19,26 @@ CONFIG_ETH_SPI_ETHERNET_DM9051=y
1819
CONFIG_ETH_SPI_ETHERNET_W5500=y
1920
CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y
2021

21-
# We don't have an example for classic BT - yet - we need to enable class BT
22-
# specifically to workaround this bug in ESP IDF v5.2 (fixed in ESP IDF v5.2.1+):
22+
# We need to enable class specifically to workaround this bug in ESP IDF v5.2 (fixed in ESP IDF v5.2.1+):
2323
# https://github.com/espressif/esp-idf/issues/13113
24+
# And, required for BT Classic examples
2425
CONFIG_BT_CLASSIC_ENABLED=y
2526

2627
# BLE with Bluedroid
2728
CONFIG_BT_ENABLED=y
2829
CONFIG_BT_BLUEDROID_ENABLED=y
29-
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
30+
# Dual mode needed for SPP demo
31+
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=n
3032
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
31-
CONFIG_BTDM_CTRL_MODE_BTDM=n
33+
CONFIG_BTDM_CTRL_MODE_BTDM=y
3234
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
3335
CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n
3436
CONFIG_BT_BTC_TASK_STACK_SIZE=15000
3537
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y
3638

39+
# BT Classic SPP demo
40+
CONFIG_BT_SPP_ENABLED=y
41+
3742
# Support for TLS with a pre-shared key.
3843
#CONFIG_ESP_TLS_PSK_VERIFICATION=y
3944

@@ -68,5 +73,8 @@ CONFIG_OPENTHREAD_ENABLED=y
6873
# Border Router again, mDNS
6974
#CONFIG_MDNS_MULTIPLE_INSTANCE=y
7075

76+
# Border Router again, Wifi/IEEE802.15.4 software co-exist
77+
#CONFIG_ESP_COEX_SW_COEXIST_ENABLE=y
78+
7179
# Littlefs on SD cards example
7280
#CONFIG_LITTLEFS_SDMMC_SUPPORT=y

.github/workflows/ci-esp-idf-next.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
- xtensa-esp32s2-espidf
2626
- xtensa-esp32s3-espidf
2727
idf-version:
28-
- release/v5.3
29-
- release/v5.4
28+
- v5.3.4
29+
- v5.4.3
30+
- v5.5.1
3031
- master
3132
steps:
3233
- name: Setup | Checkout
@@ -54,28 +55,28 @@ jobs:
5455
ESP_IDF_VERSION: ${{ matrix.idf-version }}
5556
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
5657
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
57-
run: cargo clippy --features nightly,experimental --no-deps --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort -- -Dwarnings
58+
run: cargo clippy --features nightly,experimental --no-deps --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -- -Dwarnings
5859

5960
- name: Build | Compile
6061
env:
6162
ESP_IDF_VERSION: ${{ matrix.idf-version }}
6263
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
6364
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
64-
run: cargo build --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
65+
run: cargo build --target ${{ matrix.target }} -Zbuild-std=std,panic_abort
6566

6667
- name: Build | Compile, experimental, nightly, no_std
6768
env:
6869
ESP_IDF_VERSION: ${{ matrix.idf-version }}
6970
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
7071
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
71-
run: cargo build --no-default-features --features nightly,experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
72+
run: cargo build --no-default-features --features nightly,experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort
7273

7374
- name: Build | Compile, experimental, nightly, alloc
7475
env:
7576
ESP_IDF_VERSION: ${{ matrix.idf-version }}
7677
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
7778
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
78-
run: cargo build --no-default-features --features nightly,experimental,alloc --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
79+
run: cargo build --no-default-features --features nightly,experimental,alloc --target ${{ matrix.target }} -Zbuild-std=std,panic_abort
7980

8081
- name: Setup | ldproxy
8182
if: matrix.target == 'riscv32imc-esp-espidf'
@@ -94,7 +95,7 @@ jobs:
9495
ESP_DEVICE_IP: "192.168.1.250"
9596
GATEWAY_IP: "192.168.1.1"
9697
GATEWAY_NETMASK: "24"
97-
run: cargo clippy --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort -- -Dwarnings
98+
run: cargo clippy --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -- -Dwarnings
9899

99100
- name: Build | Examples
100101
env:
@@ -106,4 +107,4 @@ jobs:
106107
ESP_DEVICE_IP: "192.168.1.250"
107108
GATEWAY_IP: "192.168.1.1"
108109
GATEWAY_NETMASK: "24"
109-
run: cargo build --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
110+
run: cargo build --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort

.github/workflows/ci.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ jobs:
2727
- xtensa-esp32s2-espidf
2828
- xtensa-esp32s3-espidf
2929
idf-version:
30-
- v4.4.8
31-
- v5.1.2
32-
- v5.2.3
33-
- v5.3.2
30+
- v5.1.6
31+
- v5.2.5
32+
- v5.3.3
33+
- v5.4.2
34+
- v5.5
3435
steps:
3536
- name: Setup | Checkout
3637
uses: actions/checkout@v3
@@ -59,31 +60,31 @@ jobs:
5960
ESP_IDF_VERSION: ${{ matrix.idf-version }}
6061
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
6162
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
62-
run: cargo clippy --features nightly,experimental --no-deps --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort -- -Dwarnings
63+
run: cargo clippy --features nightly,experimental --no-deps --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -- -Dwarnings
6364

6465
- name: Build | Compile
6566
if: matrix.target != 'riscv32imac-esp-espidf' || matrix.idf-version != 'v4.4.8'
6667
env:
6768
ESP_IDF_VERSION: ${{ matrix.idf-version }}
6869
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
6970
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
70-
run: cargo build --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
71+
run: cargo build --target ${{ matrix.target }} -Zbuild-std=std,panic_abort
7172

7273
- name: Build | Compile, experimental, nightly, no_std
7374
if: matrix.target != 'riscv32imac-esp-espidf' || matrix.idf-version != 'v4.4.8'
7475
env:
7576
ESP_IDF_VERSION: ${{ matrix.idf-version }}
7677
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
7778
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
78-
run: cargo build --no-default-features --features nightly,experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
79+
run: cargo build --no-default-features --features nightly,experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort
7980

8081
- name: Build | Compile, experimental, nightly, alloc
8182
if: matrix.target != 'riscv32imac-esp-espidf' || matrix.idf-version != 'v4.4.8'
8283
env:
8384
ESP_IDF_VERSION: ${{ matrix.idf-version }}
8485
ESP_IDF_SDKCONFIG_DEFAULTS: "${{ github.workspace }}/.github/configs/sdkconfig.defaults"
8586
RUSTFLAGS: "${{ !startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time64' || startsWith(matrix.idf-version, 'v4') && '--cfg espidf_time32' }}"
86-
run: cargo build --no-default-features --features nightly,experimental,alloc --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
87+
run: cargo build --no-default-features --features nightly,experimental,alloc --target ${{ matrix.target }} -Zbuild-std=std,panic_abort
8788

8889
- name: Setup | ldproxy
8990
if: matrix.target == 'riscv32imc-esp-espidf'
@@ -103,7 +104,7 @@ jobs:
103104
ESP_DEVICE_IP: "192.168.1.250"
104105
GATEWAY_IP: "192.168.1.1"
105106
GATEWAY_NETMASK: "24"
106-
run: cargo clippy --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort -- -Dwarnings
107+
run: cargo clippy --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -- -Dwarnings
107108

108109
- name: Build | Examples
109110
if: matrix.target != 'riscv32imac-esp-espidf' || matrix.idf-version != 'v4.4.8'
@@ -116,4 +117,4 @@ jobs:
116117
ESP_DEVICE_IP: "192.168.1.250"
117118
GATEWAY_IP: "192.168.1.1"
118119
GATEWAY_NETMASK: "24"
119-
run: cargo build --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
120+
run: cargo build --examples --features experimental --target ${{ matrix.target }} -Zbuild-std=std,panic_abort

.github/workflows/publish-dry-run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
toolchain: ${{ env.rust_toolchain }}
2020
components: rust-src
2121
- name: Build | Publish Dry Run
22-
run: export ESP_IDF_TOOLS_INSTALL_DIR=out; export ESP_IDF_SDKCONFIG_DEFAULTS=$(pwd)/.github/configs/sdkconfig.defaults; cargo publish --dry-run --target riscv32imc-esp-espidf -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
22+
run: export ESP_IDF_TOOLS_INSTALL_DIR=out; export ESP_IDF_SDKCONFIG_DEFAULTS=$(pwd)/.github/configs/sdkconfig.defaults; cargo publish --dry-run --target riscv32imc-esp-espidf -Zbuild-std=std,panic_abort

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
- name: Login
2222
run: cargo login ${{ secrets.crates_io_token }}
2323
- name: Build | Publish
24-
run: export ESP_IDF_TOOLS_INSTALL_DIR=out; export ESP_IDF_SDKCONFIG_DEFAULTS=$(pwd)/.github/configs/sdkconfig.defaults; cargo publish --target riscv32imc-esp-espidf -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
24+
run: export ESP_IDF_TOOLS_INSTALL_DIR=out; export ESP_IDF_SDKCONFIG_DEFAULTS=$(pwd)/.github/configs/sdkconfig.defaults; cargo publish --target riscv32imc-esp-espidf -Zbuild-std=std,panic_abort
2525
- name: Build Documentation
26-
run: cargo doc --target riscv32imc-esp-espidf -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort; echo "<meta http-equiv=\"refresh\" content=\"0; url=esp_idf_svc\">" > target/riscv32imc-esp-espidf/doc/index.html; mv target/riscv32imc-esp-espidf/doc ./docs
26+
run: cargo doc --target riscv32imc-esp-espidf -Zbuild-std=std,panic_abort; echo "<meta http-equiv=\"refresh\" content=\"0; url=esp_idf_svc\">" > target/riscv32imc-esp-espidf/doc/index.html; mv target/riscv32imc-esp-espidf/doc ./docs
2727
- name: Deploy Documentation
2828
if: ${{ github.ref == 'refs/heads/master' }}
2929
uses: peaceiris/actions-gh-pages@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.vscode
2+
/.zed
23
/.espressif
34
/.embuild
45
/target

CHANGELOG.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Breaking
11+
- Added custom server certificate to `http::client::Configuration`
12+
- BT: `BtDriver::set_device_name` deprecated and not available with ESP-IDF 6.0+. Use the new `EspGap::set_device_name` instead
13+
or the existing `EspBleGap::set_device_name`
14+
- BT: `BleGapEvent::ScanResult` is now a struct instead of a wrapper around esp_ble_gap_cb_param_t_ble_scan_result_evt_param
1115
- Implement MQTT outbox limit and get_outbox_size()
1216
- Added argument `subprotocol_list` to `ws_handler` to allow subprotocols to be supported by WebSockets
17+
- Thread enhancements (#592). Specifically:
18+
- Thread SRP (Thread-specific mDNS) is now supported and has a new API so that the user can register/unregister SRP services
19+
- Option to start/stop the Thread stack (methods `Thread::start` / `Thread::stop` in place of the previous `Thread::run`)
20+
- Several callbacks where actually unsound, as they were not `Send + 'static`. Now fixed
21+
- Simplifications:
22+
- `Thread::init` and `Thread::deinit` are now gone
23+
- No option to swap the Thread Netif with a custom one, as it complicates the implementation, and I don't see the use-case (unlike with Wifi)
24+
- Compatibility with ESP-IDF 5.1.6+, 5.2.4+, 5.3.2+ and 5.4+ in that the new DatasetChanged event is properly handled and does not cause the event code to panic
25+
- MSRV raised to 1.82
26+
- NVS: Removed `NvsDataType::Any` and replaced `From<nvs_type_t>` with `NvsDataType:from_nvs_type`
27+
- (#529) `Peripheral` and `PeripheralRef` removed and replaced with a simple pattern similar to the `esp-hal` one.
28+
- Check https://github.com/esp-rs/esp-idf-hal/pull/529 for details on that change
1329

1430
### Fixed
31+
- `WifiDriver::get_ap_info` not takes `&self` instead of `&mut self`. Convenience method `EspWifi::get_ap_info` that delegates
32+
to `WifiDriver::get_ap_info`
33+
- BT: Fix BLE not working on the s3 and with ESP-IDF 5.3+
34+
- BT: Fix `bt_gatt_server` example not allowing reconnect after client connect (#553) and handle sububscribe/unsubscribe to indications
35+
- BT: Fix `EspBleGap::set_security_conf` not setting auth_req_mode, and returning ESP_ERR_INVALID_ARG when setting key sizes
1536
- Fix wrong conversion from `ScanType` to `u32` in Wi-Fi configuration
1637
- Fix wrong BT configuration version on the c6 (issue #556)
1738
- Fix inconsistent mutability in NVS (#567)
1839
- Fix #570 (c_char vs i8 mismatch on newer rustc toolchains)
40+
- ESP-IDF partitions support is no longer behind the `experimental` feature
41+
- Filesystems support is no longer behind the `experimental` feature
42+
- Bluetooth support is no longer behind the `experimental` feature
43+
- Thread support is no longer behind the `experimental` feature
44+
- MQTT: Fix a crash when the LWT payload is empty (#597)
1945

2046
### Added
47+
- Compatibility with ESP-IDF V5.4.x and V5.5.x
48+
- Logging configuration enhanced with a simpler setup where Rust logs can be configured to have a verbosity which is
49+
disconnected from the verbosity of the ESP-IDF native C logging (#593)
2150
- OTA: New method - `EspFirmwareInfoLoad::fetch_native` - returning the full native ESP-IDF image descriptor structures
2251
- Added `use_serde` feature, which enables the `use_serde` feature of `embedded-svc` crate, allowing to deserialize configuration structs.
2352
- OTA: Allow specifying image size to speed up erase
24-
- Bluetooth: New methods `EspBleGap::start_scanning` and `EspBleGap::stop_scanning`
53+
- Bluetooth: New methods `EspBleGap::set_scan_params`, `EspBleGap::start_scanning`, `EspBleGap::stop_scanning`,
54+
`EspBleGap::resolve_adv_data_by_type`, `EspBleGap::disconnect` and `gatt::set_local_mtu`
55+
- Bluetooth: New BLE Gatt Client `EspGattc`
56+
- Bluetooth Classic: Added Serial Port Profile, `spp`
57+
- New example, `bt_spp_acceptor` to demonstrate usage of bt classic spp profile
2558
- New example, `bt_ble_gap_scanner` to demonstrate usage of added ble scanning methods
59+
- New example, `bt_gatt_client` to demonstrate usage of added ble gatt client
2660
- New example, `mdns_advertise` to demonstrate mDNS service advertisement
61+
- NVS: Implemented `RawHandle` for `EspNvs<NvsDefault>`
62+
- NVS: Added `EspNvs::erase_all` to remove all data stored in an nvs namespace
63+
- NVS: Added `EspNvs::keys` to iterate over all stored keys
2764

2865
## [0.51.0] - 2025-01-15
2966

Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = "README.md"
1313
links = "esp_idf_svc"
1414
build = "build.rs"
1515
documentation = "https://docs.esp-rs.org/esp-idf-svc/"
16-
rust-version = "1.77"
16+
rust-version = "1.82"
1717

1818
[patch.crates-io]
1919
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" }
@@ -62,11 +62,9 @@ uncased = { version = "0.9.7", default-features = false }
6262
embedded-hal-async = { version = "1", default-features = false }
6363
embedded-svc = { version = "0.28", default-features = false }
6464
esp-idf-hal = { version = "0.45", default-features = false }
65-
embassy-time-driver = { version = "0.2", optional = true, features = [
66-
"tick-hz-1_000_000",
67-
] }
68-
embassy-time-queue-utils = { version = "0.1", optional = true }
69-
embassy-futures = "0.1"
65+
embassy-time-driver = { version = "0.2.1", optional = true, features = ["tick-hz-1_000_000"] }
66+
embassy-time-queue-utils = { version = "0.3", optional = true }
67+
embassy-futures = "0.1.2"
7068
embedded-storage = { version = "0.3", optional = true }
7169
futures-io = { version = "0.3", optional = true }
7270

examples/bt_ble_gap_scanner.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Example of a BLE GAP scanner using the ESP IDF Bluedroid BLE bindings.
2-
//! Build with `--features experimental` (for now).
32
//!
43
//! The example prints discovered ble devices on the console.
54
//!
@@ -22,27 +21,23 @@
2221
#![allow(unknown_lints)]
2322
#![allow(unexpected_cfgs)]
2423

25-
#[cfg(all(not(esp32s2), feature = "experimental"))]
24+
#[cfg(not(esp32s2))]
2625
fn main() -> anyhow::Result<()> {
2726
example::main()
2827
}
2928

30-
#[cfg(any(esp32s2, not(feature = "experimental")))]
29+
#[cfg(esp32s2)]
3130
fn main() -> anyhow::Result<()> {
32-
#[cfg(esp32s2)]
3331
panic!("ESP32-S2 does not have a BLE radio");
34-
35-
#[cfg(not(feature = "experimental"))]
36-
panic!("Use `--features experimental` when building this example");
3732
}
3833

39-
#[cfg(all(not(esp32s2), feature = "experimental"))]
34+
#[cfg(not(esp32s2))]
4035
mod example {
4136
use core::fmt;
4237
use core::hash::{Hash, Hasher};
4338
use std::sync::{Arc, Mutex};
4439

45-
use esp_idf_svc::bt::ble::gap::{BleGapEvent, EspBleGap};
40+
use esp_idf_svc::bt::ble::gap::{BleGapEvent, EspBleGap, GapSearchEvent, GapSearchResult};
4641
use esp_idf_svc::bt::{BdAddr, Ble, BtDriver};
4742
use esp_idf_svc::hal::delay::FreeRtos;
4843
use esp_idf_svc::hal::peripherals::Peripherals;
@@ -140,9 +135,13 @@ mod example {
140135
fn on_gap_event(&self, event: BleGapEvent) -> Result<(), EspError> {
141136
trace!("Got event: {event:?}");
142137

143-
if let BleGapEvent::ScanResult(result) = event {
138+
if let BleGapEvent::ScanResult(GapSearchEvent::InquiryResult(GapSearchResult {
139+
bda,
140+
..
141+
})) = event
142+
{
144143
let mut state = self.state.lock().unwrap();
145-
let address = BluetoothAddress(BdAddr::from_bytes(result.bda));
144+
let address = BluetoothAddress(bda);
146145
match state.discovered.insert(address) {
147146
Ok(true) => info!("Discovered new device {address}"),
148147
Err(_) => warn!("Error while storing address: {address}"),

0 commit comments

Comments
 (0)