Skip to content
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

Make embedded svc really optional #429

Merged
merged 3 commits into from
Feb 5, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

### Changed
- Users don't need embedded-svc to control wifi anymore. The wifi trait is optionally implemented now. (#429)

### Removed

Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ portable-atomic = { version = "1.5", default-features = false }
portable_atomic_enum = { version = "0.3.0", features = ["portable-atomic"] }
log = "0.4.20"
embedded-svc = { version = "0.27.0", default-features = false, features = [] }
no-std-net = "0.6.0"
enumset = { version = "1.1.3", default-features = false }
linked_list_allocator = { version = "0.10.5", default-features = false, features = [
"const_mut_refs",
Expand All @@ -51,7 +52,7 @@ embassy-net = { version = "0.4.0", features = [
"dhcpv4",
"medium-ethernet",
] }
bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "0db8fcb", features = [
bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "be90de7", features = [
"macros",
] }
embassy-executor = { version = "0.5.0", package = "embassy-executor", features = [
Expand Down
4 changes: 3 additions & 1 deletion esp-wifi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fugit.workspace = true
heapless = { workspace = true, default-features = false }
num-derive = { workspace = true }
num-traits = { workspace = true, default-features = false }
no-std-net = { workspace = true, optional = true }
esp-wifi-sys = { version = "0.3.0", path = "../esp-wifi-sys" }
embassy-sync = { workspace = true, optional = true }
embassy-futures = { workspace = true, optional = true }
Expand Down Expand Up @@ -115,7 +116,8 @@ dump-packets = []
smoltcp = [ "dep:smoltcp" ]
utils = [ "smoltcp" ]
enumset = []
wifi = [ "dep:enumset", "dep:embedded-svc" ]
wifi = [ "dep:enumset", "dep:no-std-net" ]
embedded-svc = [ "dep:embedded-svc" ]
ble = [ "esp32-hal?/bluetooth" ]
phy-enable-usb = []
ps-min-modem = []
Expand Down
1 change: 1 addition & 0 deletions esp-wifi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Don't use this feature if you are _not_ using USB-SERIAL-JTAG as it might reduce
| ps-max-modem | Enable maximum modem sleep. Only affects STA mode |
| log | Route log output to the `log` crate |
| defmt | Add `defmt::Format` implementation and output logs via `defmt` |
| embedded-svc | Implement the embedded-svc Wifi trait |

Note that not all features are available on every MCU. For example, `ble` (and thus, `coex`) is not available on ESP32-S2.

Expand Down
23 changes: 12 additions & 11 deletions esp-wifi/automated-tests/open_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::println;
Expand Down Expand Up @@ -64,16 +63,18 @@ fn main() -> ! {
println!("{:?}", controller.get_capabilities());

wifi_stack
.set_iface_configuration(&embedded_svc::ipv4::Configuration::Client(
embedded_svc::ipv4::ClientConfiguration::Fixed(embedded_svc::ipv4::ClientSettings {
ip: embedded_svc::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
subnet: embedded_svc::ipv4::Subnet {
gateway: embedded_svc::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
mask: embedded_svc::ipv4::Mask(24),
.set_iface_configuration(&esp_wifi::wifi::ipv4::Configuration::Client(
esp_wifi::wifi::ipv4::ClientConfiguration::Fixed(
esp_wifi::wifi::ipv4::ClientSettings {
ip: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
subnet: esp_wifi::wifi::ipv4::Subnet {
gateway: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
mask: esp_wifi::wifi::ipv4::Mask(24),
},
dns: None,
secondary_dns: None,
},
dns: None,
secondary_dns: None,
}),
),
))
.unwrap();

Expand Down
3 changes: 2 additions & 1 deletion esp-wifi/automated-tests/test_ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ fn main() -> ! {
},],
},]);

let mut srv = AttributeServer::new(&mut ble, &mut gatt_attributes);
let mut rng = bleps::no_rng::NoRng;
let mut srv = AttributeServer::new(&mut ble, &mut gatt_attributes, &mut rng);

loop {
match srv.do_work_with_notification(None) {
Expand Down
23 changes: 12 additions & 11 deletions esp-wifi/automated-tests/test_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointInfo, AuthMethod, ClientConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointInfo, AuthMethod, ClientConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::println;
Expand Down Expand Up @@ -136,16 +135,18 @@ fn main() -> ! {
println!("Setting static IP {}", STATIC_IP);

wifi_stack
.set_iface_configuration(&embedded_svc::ipv4::Configuration::Client(
embedded_svc::ipv4::ClientConfiguration::Fixed(embedded_svc::ipv4::ClientSettings {
ip: embedded_svc::ipv4::Ipv4Addr::from(parse_ip(STATIC_IP)),
subnet: embedded_svc::ipv4::Subnet {
gateway: embedded_svc::ipv4::Ipv4Addr::from(parse_ip(GATEWAY_IP)),
mask: embedded_svc::ipv4::Mask(24),
.set_iface_configuration(&esp_wifi::wifi::ipv4::Configuration::Client(
esp_wifi::wifi::ipv4::ClientConfiguration::Fixed(
esp_wifi::wifi::ipv4::ClientSettings {
ip: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip(STATIC_IP)),
subnet: esp_wifi::wifi::ipv4::Subnet {
gateway: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip(GATEWAY_IP)),
mask: esp_wifi::wifi::ipv4::Mask(24),
},
dns: None,
secondary_dns: None,
},
dns: None,
secondary_dns: None,
}),
),
))
.unwrap();

Expand Down
23 changes: 12 additions & 11 deletions esp-wifi/examples/access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::{print, println};
Expand Down Expand Up @@ -64,16 +63,18 @@ fn main() -> ! {
println!("{:?}", controller.get_capabilities());

wifi_stack
.set_iface_configuration(&embedded_svc::ipv4::Configuration::Client(
embedded_svc::ipv4::ClientConfiguration::Fixed(embedded_svc::ipv4::ClientSettings {
ip: embedded_svc::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
subnet: embedded_svc::ipv4::Subnet {
gateway: embedded_svc::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
mask: embedded_svc::ipv4::Mask(24),
.set_iface_configuration(&esp_wifi::wifi::ipv4::Configuration::Client(
esp_wifi::wifi::ipv4::ClientConfiguration::Fixed(
esp_wifi::wifi::ipv4::ClientSettings {
ip: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
subnet: esp_wifi::wifi::ipv4::Subnet {
gateway: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
mask: esp_wifi::wifi::ipv4::Mask(24),
},
dns: None,
secondary_dns: None,
},
dns: None,
secondary_dns: None,
}),
),
))
.unwrap();

Expand Down
23 changes: 12 additions & 11 deletions esp-wifi/examples/access_point_with_sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointConfiguration, ClientConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointConfiguration, ClientConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::{print, println};
Expand Down Expand Up @@ -93,16 +92,18 @@ fn main() -> ! {
println!("{:?}", controller.get_capabilities());

wifi_ap_stack
.set_iface_configuration(&embedded_svc::ipv4::Configuration::Client(
embedded_svc::ipv4::ClientConfiguration::Fixed(embedded_svc::ipv4::ClientSettings {
ip: embedded_svc::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
subnet: embedded_svc::ipv4::Subnet {
gateway: embedded_svc::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
mask: embedded_svc::ipv4::Mask(24),
.set_iface_configuration(&esp_wifi::wifi::ipv4::Configuration::Client(
esp_wifi::wifi::ipv4::ClientConfiguration::Fixed(
esp_wifi::wifi::ipv4::ClientSettings {
ip: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
subnet: esp_wifi::wifi::ipv4::Subnet {
gateway: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip("192.168.2.1")),
mask: esp_wifi::wifi::ipv4::Mask(24),
},
dns: None,
secondary_dns: None,
},
dns: None,
secondary_dns: None,
}),
),
))
.unwrap();

Expand Down
3 changes: 1 addition & 2 deletions esp-wifi/examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointInfo, ClientConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointInfo, ClientConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::println;
Expand Down
3 changes: 2 additions & 1 deletion esp-wifi/examples/ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ fn main() -> ! {
],
},]);

let mut srv = AttributeServer::new(&mut ble, &mut gatt_attributes);
let mut rng = bleps::no_rng::NoRng;
let mut srv = AttributeServer::new(&mut ble, &mut gatt_attributes, &mut rng);

loop {
let mut notification = None;
Expand Down
3 changes: 1 addition & 2 deletions esp-wifi/examples/coex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use esp_wifi::{
};

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{ClientConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{ClientConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::{print, println};
Expand Down
3 changes: 1 addition & 2 deletions esp-wifi/examples/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointInfo, ClientConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointInfo, ClientConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::{print, println};
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use examples_util::hal;

use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use embedded_svc::wifi::{AccessPointConfiguration, Configuration, Wifi};
use esp_backtrace as _;
use esp_println::{print, println};
use esp_wifi::wifi::{AccessPointConfiguration, Configuration};
use esp_wifi::wifi::{WifiApDevice, WifiController, WifiDevice, WifiEvent, WifiState};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_access_point_with_sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use examples_util::hal;

use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use embedded_svc::wifi::{AccessPointConfiguration, ClientConfiguration, Configuration, Wifi};
use esp_backtrace as _;
use esp_println::{print, println};
use esp_wifi::wifi::{AccessPointConfiguration, ClientConfiguration, Configuration};
use esp_wifi::wifi::{
WifiApDevice, WifiController, WifiDevice, WifiEvent, WifiStaDevice, WifiState,
};
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ mod examples_util;
use examples_util::hal;

use embassy_time::{with_timeout, Duration, Timer};
use embedded_svc::wifi::{ClientConfiguration, Configuration, Wifi};
use esp_backtrace as _;
use esp_println::println;
use esp_wifi::wifi::{ClientConfiguration, Configuration};
use esp_wifi::wifi::{WifiApDevice, WifiController, WifiDevice, WifiEvent, WifiState};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
Expand Down
6 changes: 5 additions & 1 deletion esp-wifi/examples/embassy_ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ async fn main(_spawner: Spawner) -> ! {
println!("Connector created");

let pin_ref = RefCell::new(button);
let pin_ref = &pin_ref;

loop {
println!("{:?}", ble.init().await);
Expand Down Expand Up @@ -137,9 +138,12 @@ async fn main(_spawner: Spawner) -> ! {
],
},]);

let mut srv = AttributeServer::new(&mut ble, &mut gatt_attributes);
let mut rng = bleps::no_rng::NoRng;
let mut srv = AttributeServer::new(&mut ble, &mut gatt_attributes, &mut rng);

let counter = RefCell::new(0u8);
let counter = &counter;

let mut notifier = async || {
// TODO how to check if notifications are enabled for the characteristic?
// maybe pass something into the closure which just can query the characterisic value
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ mod examples_util;
use examples_util::hal;

use embassy_time::{Duration, Timer};
use embedded_svc::wifi::{ClientConfiguration, Configuration, Wifi};
use esp_backtrace as _;
use esp_println::println;
use esp_wifi::wifi::{ClientConfiguration, Configuration};
use esp_wifi::wifi::{WifiController, WifiDevice, WifiEvent, WifiStaDevice, WifiState};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
Expand Down
23 changes: 12 additions & 11 deletions esp-wifi/examples/static_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ mod examples_util;
use examples_util::hal;

use embedded_io::*;
use embedded_svc::ipv4::Interface;
use embedded_svc::wifi::{AccessPointInfo, ClientConfiguration, Configuration, Wifi};
use esp_wifi::wifi::{AccessPointInfo, ClientConfiguration, Configuration};

use esp_backtrace as _;
use esp_println::{print, println};
Expand Down Expand Up @@ -99,16 +98,18 @@ fn main() -> ! {
println!("Setting static IP {}", STATIC_IP);

wifi_stack
.set_iface_configuration(&embedded_svc::ipv4::Configuration::Client(
embedded_svc::ipv4::ClientConfiguration::Fixed(embedded_svc::ipv4::ClientSettings {
ip: embedded_svc::ipv4::Ipv4Addr::from(parse_ip(STATIC_IP)),
subnet: embedded_svc::ipv4::Subnet {
gateway: embedded_svc::ipv4::Ipv4Addr::from(parse_ip(GATEWAY_IP)),
mask: embedded_svc::ipv4::Mask(24),
.set_iface_configuration(&esp_wifi::wifi::ipv4::Configuration::Client(
esp_wifi::wifi::ipv4::ClientConfiguration::Fixed(
esp_wifi::wifi::ipv4::ClientSettings {
ip: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip(STATIC_IP)),
subnet: esp_wifi::wifi::ipv4::Subnet {
gateway: esp_wifi::wifi::ipv4::Ipv4Addr::from(parse_ip(GATEWAY_IP)),
mask: esp_wifi::wifi::ipv4::Mask(24),
},
dns: None,
secondary_dns: None,
},
dns: None,
secondary_dns: None,
}),
),
))
.unwrap();

Expand Down
Loading
Loading