refactor: make all the services started in the same way with a start_ func and a handler task
This commit is contained in:
+3
-21
@@ -7,7 +7,7 @@
|
||||
)]
|
||||
#![deny(clippy::large_stack_frames)]
|
||||
|
||||
use cover_theif::wifi::start_wifi;
|
||||
use cover_theif::{clock::start_ntp_sync, http_api::start_http_api, wifi::start_wifi};
|
||||
use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Duration, Timer};
|
||||
@@ -16,11 +16,6 @@ use esp_hal::clock::CpuClock;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_println as _;
|
||||
|
||||
use cover_theif::{
|
||||
clock,
|
||||
http_api::{HttpApiProps, HttpApiService},
|
||||
};
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
// This creates a default app-descriptor required by the esp-idf bootloader.
|
||||
@@ -50,16 +45,8 @@ async fn main(spawner: Spawner) -> ! {
|
||||
|
||||
let net_stack = start_wifi(spawner, peripherals.WIFI);
|
||||
|
||||
spawner.spawn(clock::ntp_upkeep_service(net_stack).unwrap());
|
||||
|
||||
spawner.spawn(
|
||||
http_api_serve_task(HttpApiService::new(
|
||||
net_stack,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
))
|
||||
.unwrap(),
|
||||
);
|
||||
start_ntp_sync(spawner, net_stack);
|
||||
start_http_api(spawner, net_stack);
|
||||
|
||||
loop {
|
||||
info!("Hello world");
|
||||
@@ -68,8 +55,3 @@ async fn main(spawner: Spawner) -> ! {
|
||||
|
||||
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.1.0/examples
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn http_api_serve_task(mut service: HttpApiService<'static, HttpApiProps>) {
|
||||
service.run().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user