Skip to content

Implement IEEE 802.11s meshing. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rust-analyzer.check.allTargets": false,
"rust-analyzer.cargo.target": "xtensa-esp32-none-elf",
"rust-analyzer.cargo.features": [
"esp32"
],
"editor.formatOnSave": true
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# Ferris on Air
Ferris on Air (FoA) is an open source 802.11 stack for the ESP32 written in async rust, with the work of the [esp32-open-mac](https://esp32-open-mac.be/) project. The stack is intended to be used with [embassy](https://embassy.dev/) and is still in very early stages of development. We do not claim to be Wi-Fi certified, but implement the features specified by IEEE 802.11 to our best knowledge.

## Design
The main FoA crate acts as a multiplexer, that divides access to the hardware up into a number of virtual interfaces (VIF's). These can then be passed to interface implementations, like `foa_sta` or [`foa_dswifi`](https://github.com/mjwells2002/foa_dswifi). These interface implementations can coexist, enabling things like AP/STA operation in the future.

## Structure
The `foa` crate contains the LMAC, TX buffer management and RX ARC buffer management.
`foa_sta` contains a rudimentary implementation of a station interface.
`examples` contain a set of examples showing how to use different parts of the stack.

## Usage
For a concrete usage example, see `examples`. These examples can be run with `./run_example.sh <EXAMPLE_NAME> <CHIP> [SSID] [LOG_LEVEL]`.

- Install the ESP32 rust toolchain, by following https://docs.esp-rs.org/book/installation/index.html; for now we only support Xtensa targets, so follow those steps. We're using `no_std`, so you don't need to follow the `std` steps.
- Install `espflash` by running `cargo install espflash`
- CHIP can be esp32 or esp32s2
- DEFMT_LOG accepts the following logging levels: error, warn, info, debug, trace. Enabling a logging level also enables higher severity logging levels

## License
This project is licensed under Apache 2.0 or MIT at your option.
7 changes: 5 additions & 2 deletions examples/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"rust-analyzer.check.allTargets": false,
"rust-analyzer.cargo.target": "xtensa-esp32-none-elf",
"editor.formatOnSave": true
}
"editor.formatOnSave": true,
"rust-analyzer.cargo.features": [
"esp32"
],
}
81 changes: 33 additions & 48 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Frostie314159 <frostie.neuenhausen@gmail.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
rust-version = "1.65.0"

[dependencies]
esp-hal = "1.0.0-beta.0"
Expand All @@ -23,13 +24,14 @@ embassy-executor = { version = "0.7.0", features = ["task-arena-size-32768", "de
foa = { path = "../foa", features = ["defmt"] }
foa_sta = { path = "../foa_sta", features = ["defmt"] }
foa_awdl = { path = "../foa_awdl", features = ["defmt"] }
foa_mesh = { path = "../foa_mesh", features = ["defmt"] }

static_cell = "2.1.0"
heapless = "0.8.0"
embedded-io-async = "0.6.1"

defmt = "0.3.10"
reqwless = { path = "../../../rust/reqwless/", default-features = false, features = ["defmt"] }
reqwless = { git = "https://github.com/Frostie314159/reqwless.git", branch = "ipv6-url", default-features = false, features = ["defmt"] }
# esp-mbedtls = { git = "https://github.com/esp-rs/esp-mbedtls.git", default-features = false, }
rand_core = "0.9.3"
embedded-io = "0.6.1"
Expand Down
73 changes: 73 additions & 0 deletions examples/src/bin/mesh_single.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#![no_std]
#![no_main]

use defmt::{debug, info};
use embassy_executor::Spawner;
use embassy_time::Timer;
use esp_backtrace as _;
use esp_hal::{rng::Rng, timer::timg::TimerGroup};
use esp_println as _;
use foa::{FoAResources, FoARunner, VirtualInterface};
use foa_mesh::state::MeshResources;
use foa_mesh::MeshRunner;
use heapless::String;

macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
x
}};
}

#[embassy_executor::task]
async fn foa_task(mut runner: FoARunner<'static>) -> ! {
runner.run().await;
}
#[embassy_executor::task]
async fn mesh_task(mut runner: MeshRunner<'static, 'static, Rng>) -> ! {
runner.run().await
}

#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
info!("Welcome!");
let peripherals = esp_hal::init(esp_hal::Config::default());

let timg0 = TimerGroup::new(peripherals.TIMG0);
info!("Embassy!");
esp_hal_embassy::init(timg0.timer0);
info!("After embassy!");

let foa_resources = mk_static!(FoAResources, FoAResources::new());
let ([mesh_vif, ..], foa_runner) = foa::init(
foa_resources,
peripherals.WIFI,
peripherals.RADIO_CLK,
peripherals.ADC2,
);
spawner.spawn(foa_task(foa_runner)).unwrap();
let mesh_vif = mk_static!(VirtualInterface<'static>, mesh_vif);
let mesh_resources = mk_static!(MeshResources, MeshResources::new());

let (mut mesh_control, mesh_runner, _mesh_net_device) = foa_mesh::new_mesh_interface(
mesh_resources,
mesh_vif,
2,
String::try_from("meshtest").unwrap(),
Rng::new(peripherals.RNG),
);
info!("Before spawn!");
spawner.spawn(mesh_task(mesh_runner)).unwrap();
info!("Starting!");

mesh_control
.start()
.await
.expect("Failed to start Mesh interface.");
loop {
Timer::after_millis(1000).await;
debug!("still alive!");
}
}
16 changes: 8 additions & 8 deletions foa/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions foa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ embassy-sync = "0.6.0"
embassy-futures = "0.1.1"

esp-hal = "1.0.0-beta.0"
esp-wifi-hal = "0.1.0-alpha.3"
esp-wifi-hal = "0.1.0-alpha.4"
static_cell = "2.1.0"
critical-section = "1.2.0"
portable-atomic = "1.10.0"
esp-config= "0.3.0"
defmt-or-log = { version = "0.2.1", default-features = false }
defmt = { version = "0.3.10", optional = true }
embassy-time = "0.4.0"
ieee80211 = { version = "0.5.4", default-features = false }
ieee80211 = { version = "0.5.5", default-features = false}
heapless = "0.8.0"

[build-dependencies]
Expand Down
Loading