Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Jan 28, 2025
1 parent 1c5effb commit d829f94
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
26 changes: 21 additions & 5 deletions examples/rp/src/bin/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ use rs_matter_embassy::matter::data_model::system_model::descriptor;
use rs_matter_embassy::matter::utils::init::InitMaybeUninit;
use rs_matter_embassy::matter::utils::select::Coalesce;
use rs_matter_embassy::nal::net::driver::{Driver as _, HardwareAddress};
use rs_matter_embassy::nal::{create_link_local_ipv6, multicast_mac_for_link_local_ipv6, MDNS_MULTICAST_MAC_IPV4, MDNS_MULTICAST_MAC_IPV6};
use rs_matter_embassy::nal::{
create_link_local_ipv6, multicast_mac_for_link_local_ipv6, MDNS_MULTICAST_MAC_IPV4,
MDNS_MULTICAST_MAC_IPV6,
};
use rs_matter_embassy::rand::rp::rp_rand;
use rs_matter_embassy::stack::persist::DummyPersist;
use rs_matter_embassy::stack::test_device::{
Expand Down Expand Up @@ -144,10 +147,23 @@ async fn main(spawner: Spawner) {
// cyw43 is a bit special in that it needs to have allowlisted all multicast MAC addresses
// it should listen on. Therefore, add the mDNS ipv4 and ipv6 multicast MACs to the list,
// as well as the ipv6 neightbour solicitation requests' MAC to the list
let HardwareAddress::Ethernet(mac) = net_device.hardware_address() else { unreachable!() };
control.add_multicast_address(MDNS_MULTICAST_MAC_IPV4).await.unwrap();
control.add_multicast_address(MDNS_MULTICAST_MAC_IPV6).await.unwrap();
control.add_multicast_address(multicast_mac_for_link_local_ipv6(&create_link_local_ipv6(&mac))).await.unwrap();
let HardwareAddress::Ethernet(mac) = net_device.hardware_address() else {
unreachable!()
};
control
.add_multicast_address(MDNS_MULTICAST_MAC_IPV4)
.await
.unwrap();
control
.add_multicast_address(MDNS_MULTICAST_MAC_IPV6)
.await
.unwrap();
control
.add_multicast_address(multicast_mac_for_link_local_ipv6(&create_link_local_ipv6(
&mac,
)))
.await
.unwrap();

let controller: ExternalController<_, 20> = ExternalController::new(bt_device);

Expand Down
14 changes: 7 additions & 7 deletions rs-matter-embassy/src/nal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ pub fn create_net_stack<const N: usize, D: Driver>(
}

/// The MAC address used for mDNS multicast queries over IPv4
///
/// Useful with wifi stack implementations (i.e. cyw43) that require explicit
///
/// Useful with wifi stack implementations (i.e. cyw43) that require explicit
/// allowlisting of the multicast MAC addresses they should be listening on.
pub const MDNS_MULTICAST_MAC_IPV4: [u8; 6] = [0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb];

/// The MAC address used for mDNS multicast queries over IPv6
///
/// Useful with wifi stack implementations (i.e. cyw43) that require explicit
///
/// Useful with wifi stack implementations (i.e. cyw43) that require explicit
/// allowlisting of the multicast MAC addresses they should be listening on.
pub const MDNS_MULTICAST_MAC_IPV6: [u8; 6] = [0x33, 0x33, 0x00, 0x00, 0x00, 0xfb];

Expand Down Expand Up @@ -93,10 +93,10 @@ pub fn create_link_local_ipv6(mac: &[u8; 6]) -> Ipv6Addr {

/// Get the multicast MAC address corresponding to the given IPv6 link-local address.
///
/// Useful with Wifi stack implementations (i.e. cyw43) that require explicit
/// Useful with Wifi stack implementations (i.e. cyw43) that require explicit
/// allowlisting of the multicast MAC addresses they should be listening on.
///
/// Note that the provided IP should be a link-local IP (fe80::/10) or else this
///
/// Note that the provided IP should be a link-local IP (fe80::/10) or else this
/// function would return a bogus result.
pub fn multicast_mac_for_link_local_ipv6(ip: &Ipv6Addr) -> [u8; 6] {
let mut mac = [0x33, 0x33, 0xff, 0, 0, 0];
Expand Down

0 comments on commit d829f94

Please sign in to comment.