Skip to content

Commit fbad27f

Browse files
committed
fix: update wifimanager to fix "sticky" ble
1 parent 3a5cb51 commit fbad27f

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ embedded-storage = "0.3.1"
1919
static_cell = { version = "2.1.1", features = ["nightly"] }
2020
heapless = { version = "0.9.1", default-features = false }
2121
esp-alloc = "0.9.0"
22-
esp-hal-wifimanager = { version = "0.2.0", default-features = false, features = ["ap", "ble", "esp32c3"] }
22+
esp-hal-wifimanager = { version = "0.2.1", default-features = false, features = ["ap", "ble", "esp32c3"] }
2323
serde = { version = "1.0.228", features = ["alloc", "derive"], default-features = false }
2424
serde_json = { version = "1.0.145", default-features = false, features = ["alloc"] }
2525
adv-shift-registers = "0.2.5"

src/bluetooth.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::state::GlobalState;
12
use core::cell::RefCell;
23
use embassy_futures::join::join;
34
use embassy_time::{Duration, Timer};
@@ -8,6 +9,7 @@ use trouble_host::prelude::*;
89
pub async fn bluetooth_timer_task(
910
init: &'static RadioController<'static>,
1011
bt: esp_hal::peripherals::BT<'static>,
12+
state: GlobalState,
1113
) {
1214
let Ok(connector) = BleConnector::new(init, bt, esp_radio::ble::Config::default()) else {
1315
log::error!("Cannot init ble connector");
@@ -29,6 +31,7 @@ pub async fn bluetooth_timer_task(
2931

3032
let printer = Printer {
3133
seen: RefCell::new(heapless::Deque::new()),
34+
state: &state,
3235
};
3336
let mut scanner = Scanner::new(central);
3437
let _ = join(runner.run_with_handler(&printer), async {
@@ -45,11 +48,12 @@ pub async fn bluetooth_timer_task(
4548
}
4649

4750
#[allow(dead_code)]
48-
struct Printer {
51+
struct Printer<'a> {
4952
seen: RefCell<heapless::Deque<BdAddr, 128>>,
53+
state: &'a GlobalState,
5054
}
5155

52-
impl EventHandler for Printer {
56+
impl<'a> EventHandler for Printer<'a> {
5357
fn on_adv_reports(&self, mut it: LeAdvReportsIter<'_>) {
5458
let mut seen = self.seen.borrow_mut();
5559
while let Some(Ok(report)) = it.next() {

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,11 @@ async fn main(spawner: Spawner) {
309309
spawner.must_spawn(logger_task(global_state.clone()));
310310

311311
// BUG: this fails after wifi setup (its good if wifi is saved and ble isnt spawned)
312-
/*
313312
spawner.must_spawn(bluetooth::bluetooth_timer_task(
314313
wifi_res.wifi_init,
315314
board.bt,
315+
global_state.clone(),
316316
));
317-
*/
318317

319318
set_brownout_detection(true);
320319
global_state.state.lock().await.scene = Scene::WaitingForCompetitor;

0 commit comments

Comments
 (0)