Skip to content

Commit

Permalink
Remove redundant example, update esp-now examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Sep 7, 2023
1 parent 2760456 commit 6dbd105
Show file tree
Hide file tree
Showing 27 changed files with 331 additions and 1,174 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,11 @@ To build these ensure you are in the `examples-esp32XXX` directory matching your

`cargo run --example embassy_esp_now --release --features "async,esp-now"`

### esp_now_duplex

- broadcasts, sends and asynchronously receives messages via esp-now in multiple embassy tasks

`cargo run --example esp_now_duplex --release --features "async,esp-now"`

### esp_now_async_duplex
### embassy_esp_now_duplex

- asynchronously broadcasts, receives and sends messages via esp-now in multiple embassy tasks

`cargo run --example esp_now_async_duplex --release --features "async,esp-now"`
`cargo run --example embassy_esp_now_duplex --release --features "async,esp-now"`

### embassy_dhcp

Expand Down
3 changes: 0 additions & 3 deletions examples-esp32/examples/embassy_dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ use hal::clock::ClockControl;
use hal::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};

#[cfg(any(feature = "esp32c3", feature = "esp32c2", feature = "esp32c6"))]
use hal::system::SystemExt;

const SSID: &str = env!("SSID");
const PASSWORD: &str = env!("PASSWORD");

Expand Down
3 changes: 0 additions & 3 deletions examples-esp32/examples/embassy_esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ use hal::clock::ClockControl;
use hal::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};

#[cfg(any(feature = "esp32c3", feature = "esp32c2", feature = "esp32c6"))]
use hal::system::SystemExt;

#[embassy_executor::task]
async fn run(mut esp_now: EspNow<'static>) {
let mut ticker = Ticker::every(Duration::from_secs(5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use embassy_executor::_export::StaticCell;
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::mutex::Mutex;
#[path = "../../examples-util/util.rs"]
mod examples_util;
use examples_util::hal;

use embassy_executor::Executor;
Expand All @@ -14,12 +16,9 @@ use esp_backtrace as _;
use esp_println::println;
use esp_wifi::esp_now::{EspNowManager, EspNowReceiver, EspNowSender, PeerInfo, BROADCAST_ADDRESS};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::{ClockControl, CpuClock};
use hal::clock::ClockControl;
use hal::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc};

#[cfg(any(feature = "esp32c3", feature = "esp32c2", feature = "esp32c6"))]
use hal::system::SystemExt;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};

#[embassy_executor::task]
async fn broadcaster(sender: &'static Mutex<NoopRawMutex, EspNowSender<'static>>) {
Expand Down Expand Up @@ -92,12 +91,15 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = examples_util::system!(peripherals);
let mut peripheral_clock_control = system.peripheral_clock_control;
let clocks = examples_util::clocks!(system);
examples_util::rtc!(peripherals);
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = hal::timer::TimerGroup::new(
peripherals.TIMG1,
&clocks,
&mut system.peripheral_clock_control,
)
.timer0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand All @@ -107,11 +109,15 @@ fn main() -> ! {
)
.unwrap();

let wifi = examples_util::get_wifi!(peripherals);
let (wifi, ..) = peripherals.RADIO.split();
let esp_now = esp_wifi::esp_now::EspNow::new(&init, wifi).unwrap();
println!("esp-now version {}", esp_now.get_version().unwrap());

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);
let executor = EXECUTOR.init(Executor::new());

Expand Down
138 changes: 0 additions & 138 deletions examples-esp32/examples/esp_now_duplex.rs

This file was deleted.

3 changes: 0 additions & 3 deletions examples-esp32c2/examples/embassy_dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ use hal::clock::ClockControl;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};
use hal::{systimer::SystemTimer, Rng};

#[cfg(any(feature = "esp32c3", feature = "esp32c2", feature = "esp32c6"))]
use hal::system::SystemExt;

const SSID: &str = env!("SSID");
const PASSWORD: &str = env!("PASSWORD");

Expand Down
3 changes: 0 additions & 3 deletions examples-esp32c2/examples/embassy_esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ use hal::clock::ClockControl;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};
use hal::{systimer::SystemTimer, Rng};

#[cfg(any(feature = "esp32c3", feature = "esp32c2", feature = "esp32c6"))]
use hal::system::SystemExt;

#[embassy_executor::task]
async fn run(mut esp_now: EspNow<'static>) {
let mut ticker = Ticker::every(Duration::from_secs(5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use embassy_executor::_export::StaticCell;
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::mutex::Mutex;
#[path = "../../examples-util/util.rs"]
mod examples_util;
use examples_util::hal;

use embassy_executor::Executor;
Expand All @@ -14,12 +16,11 @@ use esp_backtrace as _;
use esp_println::println;
use esp_wifi::esp_now::{EspNowManager, EspNowReceiver, EspNowSender, PeerInfo, BROADCAST_ADDRESS};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::{ClockControl, CpuClock};
use hal::clock::ClockControl;
use hal::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc};

#[cfg(any(feature = "esp32c3", feature = "esp32c2", feature = "esp32c6"))]
use hal::system::SystemExt;
use hal::{
embassy, peripherals::Peripherals, prelude::*, systimer::SystemTimer, timer::TimerGroup,
};

#[embassy_executor::task]
async fn broadcaster(sender: &'static Mutex<NoopRawMutex, EspNowSender<'static>>) {
Expand Down Expand Up @@ -92,12 +93,10 @@ fn main() -> ! {

let peripherals = Peripherals::take();

let system = examples_util::system!(peripherals);
let mut peripheral_clock_control = system.peripheral_clock_control;
let clocks = examples_util::clocks!(system);
examples_util::rtc!(peripherals);
let mut system = peripherals.SYSTEM.split();
let clocks = ClockControl::max(system.clock_control).freeze();

let timer = examples_util::timer!(peripherals, clocks, peripheral_clock_control);
let timer = SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
EspWifiInitFor::Wifi,
timer,
Expand All @@ -107,11 +106,15 @@ fn main() -> ! {
)
.unwrap();

let wifi = examples_util::get_wifi!(peripherals);
let (wifi, ..) = peripherals.RADIO.split();
let esp_now = esp_wifi::esp_now::EspNow::new(&init, wifi).unwrap();
println!("esp-now version {}", esp_now.get_version().unwrap());

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks, &mut peripheral_clock_control);
let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
embassy::init(&clocks, timer_group0.timer0);
let executor = EXECUTOR.init(Executor::new());

Expand Down
Loading

0 comments on commit 6dbd105

Please sign in to comment.