Skip to content
Draft
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ default-features = false
optional = true
features = [ "derive" ]

[dependencies.heapless]
version = "0.9.1"
default-features = false

[dev-dependencies]
rand = "0.8.3"

Expand Down
6 changes: 6 additions & 0 deletions src/mac/mlme/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! Partial implementation of the IEEE 802.15.4 MAC Layer Management Entity (MLME)
//!
//! The main types in this module provide structures and functions for handling
//! MLME service primitives, managing MAC layer state, and coordinating
//! MAC management operations such as association, scanning, and synchronization.
pub mod scan;
64 changes: 64 additions & 0 deletions src/mac/mlme/scan.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//! This contains MLME-Scan.request, .confirm and .indication
use heapless::Vec;

/// 7.1.11.1 - MLME-SCAN.request
/// is used to initiate a channel scan over a given list of channels.
pub struct MlmeScanRequest {
/// Indicates the type of scan performed
pub scan_type: ScanType,
/// indicate which channels are to be scanne
pub channels: u32,
/// value used to calculate the length of time to spend scanning each channel for ED, active, and passive scans.
pub scan_duration: u8,
}

/// 7.1.11.2 - MLME-SCAN.confirm
/// defines the scan primitive
pub struct MlmeScanConfirm {
/// The status of the scan request.
pub status: ScanStatus,
/// Indicates if the type of scan performed
pub scan_type: ScanType,
/// Channels not scanned (bitmask)
pub unscanned_channels: u32,
/// Number of results in lists
pub result_list_size: u8,
/// list of energy measurements, one for each channel searched during an ED scan.
pub energy_detect_list: Option<Vec<u8, 255>>,
/// Beacons found during scan
pub pan_descriptor_list: Option<Vec<PanDescriptor, 255>>,
}

/// 7.1.11.2.1
pub enum ScanType {
/// FFD only
EnergyDetection = 0x00,
/// FFD only
Active = 0x01,
/// passive scan
Passive = 0x02,
/// orphan scan
Orphan = 0x03,
}

/// 7.1.11.1.3
pub enum ScanStatus {
/// requested scan was successful
Success,
/// limit reached
LimitReached,
/// primitive is not supported or is out of range
InvalidParameter,
}

/// Table 41
pub struct PanDescriptor {
/// The address of the coordinator as specified in the received beacon frame.
pub coord_addr: u64,
/// The PAN identifier of the coordinator as specified in the received beacon frame.
pub coord_pan_id: u16,
/// The current logical channel occupied by the network.
pub channel: u8,
/// The LQ at which the network beacon was received.
pub link_quality: u8,
}
1 change: 1 addition & 0 deletions src/mac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod beacon;
pub mod command;
pub mod frame;
pub mod mlme;

pub use frame::header::{
Address, AddressMode, ExtendedAddress, FrameType, FrameVersion, Header,
Expand Down
Loading