Skip to content

Commit

Permalink
fix(examples): set a static IP address in the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories authored and kaspar030 committed Jan 29, 2024
1 parent e2c8ddb commit 074c51b
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ riot-wrappers = { version = "^0.8", default-features = false, features = [
"with_riot_rs",
] }

heapless = { version = "0.8.0", default-features = false }
static_cell = { version = "2.0.0", features = [ "nightly" ] }
ld-memory = { version = "0.2.9" }
konst = { version = "0.3.8", default_features = false }
Expand Down
3 changes: 2 additions & 1 deletion examples/embassy-http-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ edition.workspace = true
publish = false

[dependencies]
riot-rs = { path = "../../src/riot-rs", features = [ "time" ] }
riot-rs = { path = "../../src/riot-rs", features = ["time", "override-network-config"] }
riot-rs-boards = { path = "../../src/riot-rs-boards" }
embassy-executor = { workspace = true, default-features = false }
embassy-nrf = { workspace = true }
embassy-sync = { workspace = true }
embassy-time = { workspace = true, default-features = false }
embassy-net = { workspace = true, features = ["tcp"] }
embedded-io-async = "0.6.0"
heapless = { workspace = true }
httparse = { version = "1.8.0", default-features = false }
picoserve = "0.3.0"
static_cell = { workspace = true }
Expand Down
11 changes: 11 additions & 0 deletions examples/embassy-http-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,14 @@ impl Application for WebServer {
}

riot_rs::embassy::riot_initialize!(WebServer);

#[no_mangle]
fn riot_rs_network_config() -> embassy_net::Config {
use embassy_net::Ipv4Address;

embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
dns_servers: heapless::Vec::new(),
gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
})
}
3 changes: 2 additions & 1 deletion examples/embassy-net-tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ edition.workspace = true
publish = false

[dependencies]
riot-rs = { path = "../../src/riot-rs", features = [ "time" ] }
riot-rs = { path = "../../src/riot-rs", features = ["time", "override-network-config"] }
riot-rs-boards = { path = "../../src/riot-rs-boards" }
embassy-executor = { workspace = true, default-features = false }
embassy-time = { workspace = true, default-features = false }
embassy-net = { workspace = true, features = ["tcp" ] }
embedded-io-async = "0.6.1"
heapless = { workspace = true }
11 changes: 11 additions & 0 deletions examples/embassy-net-tcp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ impl Application for TcpEcho {
}

riot_rs::embassy::riot_initialize!(TcpEcho);

#[no_mangle]
fn riot_rs_network_config() -> embassy_net::Config {
use embassy_net::Ipv4Address;

embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
dns_servers: heapless::Vec::new(),
gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
})
}
3 changes: 2 additions & 1 deletion examples/embassy-net-udp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ edition.workspace = true
publish = false

[dependencies]
riot-rs = { path = "../../src/riot-rs", features = [ "time" ] }
riot-rs = { path = "../../src/riot-rs", features = ["time", "override-network-config"] }
riot-rs-boards = { path = "../../src/riot-rs-boards" }
embassy-executor = { workspace = true, default-features = false }
embassy-time = { workspace = true, default-features = false }
embassy-net = { workspace = true, features = ["udp"] }
embedded-io-async = "0.6.1"
heapless = { workspace = true }
11 changes: 11 additions & 0 deletions examples/embassy-net-udp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,14 @@ impl Application for UdpEcho {
}

riot_rs::embassy::riot_initialize!(UdpEcho);

#[no_mangle]
fn riot_rs_network_config() -> embassy_net::Config {
use embassy_net::Ipv4Address;

embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
dns_servers: heapless::Vec::new(),
gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
})
}
2 changes: 1 addition & 1 deletion src/riot-rs-embassy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ usb_ethernet = [ "usb", "net" ]
wifi_cyw43 = [ "dep:cyw43", "dep:cyw43-pio", "dep:embassy-net-driver-channel", "net" ]

threading = ["dep:riot-rs-core"]
override_network_config = []
override-network-config = []
override_usb_config = []
10 changes: 2 additions & 8 deletions src/riot-rs-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,11 @@ fn usb_config() -> embassy_usb::Config<'static> {

#[cfg(feature = "net")]
fn network_config() -> embassy_net::Config {
#[cfg(not(feature = "override_network_config"))]
#[cfg(not(feature = "override-network-config"))]
{
//use embassy_net::{Ipv4Address, Ipv4Cidr};
// embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 {
// address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
// dns_servers: heapless::Vec::new(),
// gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
// })
embassy_net::Config::dhcpv4(Default::default())
}
#[cfg(feature = "override_network_config")]
#[cfg(feature = "override-network-config")]
{
extern "Rust" {
fn riot_rs_network_config() -> embassy_net::Config;
Expand Down
1 change: 1 addition & 0 deletions src/riot-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ usb = [ "riot-rs-embassy/usb" ]
net = [ "riot-rs-embassy/net" ]
usb_ethernet = [ "riot-rs-embassy/usb_ethernet" ]
wifi_cyw43 = [ "riot-rs-embassy/wifi_cyw43" ]
override-network-config = ["riot-rs-embassy/override-network-config"]

0 comments on commit 074c51b

Please sign in to comment.