tasks: ble: use const init of client predictions pipe
This commit is contained in:
@@ -3,7 +3,7 @@ use embassy_executor::Spawner;
|
||||
use embassy_futures::select::Either;
|
||||
use embassy_sync::{blocking_mutex::raw::NoopRawMutex, pubsub::{DynSubscriber, PubSubChannel, Publisher}};
|
||||
use esp_radio::ble::controller::BleConnector;
|
||||
use static_cell::StaticCell;
|
||||
use static_cell::{ConstStaticCell, StaticCell};
|
||||
use trouble_host::{prelude::*, types::gatt_traits::FromGattError};
|
||||
use log::*;
|
||||
|
||||
@@ -96,7 +96,7 @@ async fn client_prediction_task(mut src: DynSubscriber<'static, Prediction>, sin
|
||||
static STATIC_RESOURCES: StaticCell<HostResources<DefaultPacketPool, 1, 1>> = StaticCell::new();
|
||||
static STATIC_STACK: StaticCell<Stack<'static, ExternalController<BleConnector<'static>, 1>, DefaultPacketPool>> = StaticCell::new();
|
||||
static STATIC_SERVER: StaticCell<SerialServer> = StaticCell::new();
|
||||
static STATIC_CLIENT_PREDICTIONS: StaticCell<PubSubChannel<NoopRawMutex, Prediction, 5, 1, 1>> = StaticCell::new();
|
||||
static STATIC_CLIENT_PREDICTIONS: ConstStaticCell<PubSubChannel<NoopRawMutex, Prediction, 5, 1, 1>> = ConstStaticCell::new(PubSubChannel::new());
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn ble_task(ble: BleConnector<'static>, predictions: DynSubscriber<'static, Prediction>, spawner: Spawner) {
|
||||
@@ -106,7 +106,7 @@ pub async fn ble_task(ble: BleConnector<'static>, predictions: DynSubscriber<'st
|
||||
let stack = STATIC_STACK.init(trouble_host::new(control, STATIC_RESOURCES.init(HostResources::new())));
|
||||
let Host { mut peripheral, mut runner, .. } = stack.build();
|
||||
|
||||
let client_predictions = STATIC_CLIENT_PREDICTIONS.init(PubSubChannel::new());
|
||||
let client_predictions = STATIC_CLIENT_PREDICTIONS.take();
|
||||
spawner.must_spawn(client_prediction_task(predictions, client_predictions.publisher().unwrap()));
|
||||
|
||||
// The host task must be started and ticking beore we can start advertising, so we use a join() here instead of a separate task
|
||||
|
||||
Reference in New Issue
Block a user