mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
wip: added MAC responses
This commit is contained in:
parent
6f4172fbc1
commit
67b14e6e7a
@ -11,6 +11,7 @@ pub trait MacCommand {
|
||||
}
|
||||
|
||||
/// MLME ASSOCIATE Request used to request an association
|
||||
#[repr(C)]
|
||||
pub struct AssociateRequest {
|
||||
/// the logical channel on which to attempt association
|
||||
pub channel_number: u8,
|
||||
@ -40,6 +41,7 @@ impl MacCommand for AssociateRequest {
|
||||
}
|
||||
|
||||
/// MLME DISASSOCIATE Request sed to request a disassociation
|
||||
#[repr(C)]
|
||||
pub struct DisassociateRequest {
|
||||
/// device addressing mode used
|
||||
pub device_addr_mode: AddressMode,
|
||||
@ -67,6 +69,7 @@ impl MacCommand for DisassociateRequest {
|
||||
}
|
||||
|
||||
/// MLME GET Request used to request a PIB value
|
||||
#[repr(C)]
|
||||
pub struct GetRequest {
|
||||
/// the name of the PIB attribute to read
|
||||
pub pib_attribute: PibId,
|
||||
@ -78,6 +81,7 @@ impl MacCommand for GetRequest {
|
||||
}
|
||||
|
||||
/// MLME GTS Request used to request and maintain GTSs
|
||||
#[repr(C)]
|
||||
pub struct GtsRequest {
|
||||
/// the characteristics of the GTS
|
||||
pub characteristics: GtsCharacteristics,
|
||||
@ -96,6 +100,7 @@ impl MacCommand for GtsRequest {
|
||||
const SIZE: usize = 12;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ResetRequest {
|
||||
/// MAC PIB attributes are set to their default values or not during reset
|
||||
pub set_default_pib: bool,
|
||||
@ -108,6 +113,7 @@ impl MacCommand for ResetRequest {
|
||||
|
||||
/// MLME RX ENABLE Request used to request that the receiver is either enabled
|
||||
/// for a finite period of time or disabled
|
||||
#[repr(C)]
|
||||
pub struct RxEnableRequest {
|
||||
/// the request operation can be deferred or not
|
||||
pub defer_permit: bool,
|
||||
@ -138,6 +144,7 @@ impl MacCommand for RxEnableRequest {
|
||||
}
|
||||
|
||||
/// MLME SCAN Request used to initiate a channel scan over a given list of channels
|
||||
#[repr(C)]
|
||||
pub struct ScanRequest {
|
||||
/// the type of scan to be performed
|
||||
pub scan_type: u8,
|
||||
@ -179,6 +186,7 @@ impl MacCommand for SetRequest {
|
||||
/// MLME START Request used by the FFDs to intiate a new PAN or to begin using a new superframe
|
||||
/// configuration
|
||||
#[derive(Default)]
|
||||
#[repr(C)]
|
||||
pub struct StartRequest {
|
||||
/// PAN indentifier to used by the device
|
||||
pub pan_id: [u8; 2],
|
||||
@ -221,6 +229,7 @@ impl MacCommand for StartRequest {
|
||||
|
||||
/// MLME SYNC Request used to synchronize with the coordinator by acquiring and, if
|
||||
/// specified, tracking its beacons
|
||||
#[repr(C)]
|
||||
pub struct SyncRequest {
|
||||
/// the channel number on which to attempt coordinator synchronization
|
||||
pub channel_number: u8,
|
||||
@ -239,6 +248,7 @@ impl MacCommand for SyncRequest {
|
||||
}
|
||||
|
||||
/// MLME POLL Request propmts the device to request data from the coordinator
|
||||
#[repr(C)]
|
||||
pub struct PollRequest {
|
||||
/// addressing mode of the coordinator
|
||||
pub coord_addr_mode: AddressMode,
|
||||
@ -263,6 +273,7 @@ impl MacCommand for PollRequest {
|
||||
|
||||
/// MLME DPS Request allows the next higher layer to request that the PHY utilize a
|
||||
/// given pair of preamble codes for a single use pending expiration of the DPSIndexDuration
|
||||
#[repr(C)]
|
||||
pub struct DpsRequest {
|
||||
/// the index value for the transmitter
|
||||
tx_dps_index: u8,
|
||||
@ -280,6 +291,7 @@ impl MacCommand for DpsRequest {
|
||||
|
||||
/// MLME SOUNDING request primitive which is used by the next higher layer to request that
|
||||
/// the PHY respond with channel sounding information
|
||||
#[repr(C)]
|
||||
pub struct SoundingRequest;
|
||||
|
||||
impl MacCommand for SoundingRequest {
|
||||
@ -289,6 +301,7 @@ impl MacCommand for SoundingRequest {
|
||||
|
||||
/// MLME CALIBRATE request primitive which used to obtain the results of a ranging
|
||||
/// calibration request from an RDEV
|
||||
#[repr(C)]
|
||||
pub struct CalibrateRequest;
|
||||
|
||||
impl MacCommand for CalibrateRequest {
|
||||
@ -297,6 +310,7 @@ impl MacCommand for CalibrateRequest {
|
||||
}
|
||||
|
||||
/// MCPS DATA Request used for MAC data related requests from the application
|
||||
#[repr(C)]
|
||||
pub struct DataRequest {
|
||||
/// the handle assocated with the MSDU to be transmitted
|
||||
pub msdu_ptr: *const u8,
|
||||
@ -344,6 +358,7 @@ impl MacCommand for DataRequest {
|
||||
}
|
||||
|
||||
/// for MCPS PURGE Request used to purge an MSDU from the transaction queue
|
||||
#[repr(C)]
|
||||
pub struct PurgeRequest {
|
||||
/// the handle associated with the MSDU to be purged from the transaction
|
||||
/// queue
|
||||
@ -356,6 +371,7 @@ impl MacCommand for PurgeRequest {
|
||||
}
|
||||
|
||||
/// MLME ASSOCIATE Response used to initiate a response to an MLME-ASSOCIATE.indication
|
||||
#[repr(C)]
|
||||
pub struct AssociateResponse {
|
||||
/// extended address of the device requesting association
|
||||
pub device_address: [u8; 8],
|
||||
@ -380,6 +396,7 @@ impl MacCommand for AssociateResponse {
|
||||
}
|
||||
|
||||
/// MLME ORPHAN Response used to respond to the MLME ORPHAN Indication
|
||||
#[repr(C)]
|
||||
pub struct OrphanResponse {
|
||||
/// extended address of the orphaned device
|
||||
pub orphan_address: [u8; 8],
|
||||
|
3
embassy-stm32-wpan/src/sub/mac/consts.rs
Normal file
3
embassy-stm32-wpan/src/sub/mac/consts.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub const MAX_ED_SCAN_RESULTS_SUPPORTED: usize = 16;
|
||||
pub const MAX_PAN_DESC_SUPPORTED: usize = 6;
|
||||
pub const MAX_SOUNDING_LIST_SUPPORTED: usize = 6;
|
@ -16,8 +16,9 @@ use crate::evt::{EvtBox, EvtPacket};
|
||||
use crate::tables::{MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER};
|
||||
use crate::{channels, evt};
|
||||
|
||||
mod opcodes;
|
||||
pub mod commands;
|
||||
mod consts;
|
||||
mod opcodes;
|
||||
pub mod responses;
|
||||
pub mod typedefs;
|
||||
|
||||
|
@ -0,0 +1,168 @@
|
||||
use super::consts::{MAX_ED_SCAN_RESULTS_SUPPORTED, MAX_PAN_DESC_SUPPORTED, MAX_SOUNDING_LIST_SUPPORTED};
|
||||
use super::typedefs::{AddressMode, MacAddress, PanDescriptor};
|
||||
|
||||
pub trait MacResponse {
|
||||
const SIZE: usize;
|
||||
|
||||
fn parse(buf: &[u8]) -> Self;
|
||||
}
|
||||
|
||||
/// MLME ASSOCIATE Confirm used to inform of the initiating device whether
|
||||
/// its request to associate was successful or unsuccessful
|
||||
pub struct AssociateConfirm {
|
||||
/// short address allocated by the coordinator on successful association
|
||||
pub assoc_short_address: [u8; 2],
|
||||
/// status of the association request
|
||||
pub status: u8,
|
||||
/// security level to be used
|
||||
pub security_level: u8,
|
||||
/// the originator of the key to be used
|
||||
pub key_source: [u8; 8],
|
||||
/// the mode used to identify the key to be used
|
||||
pub key_id_mode: u8,
|
||||
/// the index of the key to be used
|
||||
pub key_index: u8,
|
||||
}
|
||||
|
||||
/// MLME DISASSOCIATE Confirm used to send disassociation Confirmation to the application.
|
||||
pub struct DisassociateConfirm {
|
||||
/// status of the disassociation attempt
|
||||
pub status: u8,
|
||||
/// device addressing mode used
|
||||
pub device_addr_mode: AddressMode,
|
||||
/// the identifier of the PAN of the device
|
||||
pub device_pan_id: [u8; 2],
|
||||
/// device address
|
||||
pub device_address: MacAddress,
|
||||
}
|
||||
|
||||
/// MLME GET Confirm which requests information about a given PIB attribute
|
||||
pub struct GetConfirm {
|
||||
/// The pointer to the value of the PIB attribute attempted to read
|
||||
pub pib_attribute_value_ptr: *const u8,
|
||||
/// Status of the GET attempt
|
||||
pub status: u8,
|
||||
/// The name of the PIB attribute attempted to read
|
||||
pub pib_attribute: u8,
|
||||
/// The lenght of the PIB attribute Value return
|
||||
pub pib_attribute_value_len: u8,
|
||||
}
|
||||
|
||||
/// MLME GTS Confirm which eports the results of a request to allocate a new GTS
|
||||
/// or to deallocate an existing GTS
|
||||
pub struct GtsConfirm {
|
||||
/// The characteristics of the GTS
|
||||
pub gts_characteristics: u8,
|
||||
/// The status of the GTS reques
|
||||
pub status: u8,
|
||||
}
|
||||
|
||||
/// MLME RESET Confirm which is used to report the results of the reset operation
|
||||
pub struct ResetConfirm {
|
||||
/// The result of the reset operation
|
||||
status: u8,
|
||||
}
|
||||
|
||||
/// MLME RX ENABLE Confirm which is used to report the results of the attempt
|
||||
/// to enable or disable the receiver
|
||||
pub struct RxEnableConfirm {
|
||||
/// Result of the request to enable or disable the receiver
|
||||
status: u8,
|
||||
}
|
||||
|
||||
/// MLME SCAN Confirm which is used to report the result of the channel scan request
|
||||
pub struct ScanConfirm {
|
||||
/// Status of the scan request
|
||||
pub status: u8,
|
||||
/// The type of scan performed
|
||||
pub scan_type: u8,
|
||||
/// Channel page on which the scan was performed
|
||||
pub channel_page: u8,
|
||||
/// Channels given in the request which were not scanned
|
||||
pub unscanned_channels: [u8; 4],
|
||||
/// Number of elements returned in the appropriate result lists
|
||||
pub result_list_size: u8,
|
||||
/// List of energy measurements
|
||||
pub energy_detect_list: [u8; MAX_ED_SCAN_RESULTS_SUPPORTED],
|
||||
/// List of PAN descriptors
|
||||
pub pan_descriptor_list: [PanDescriptor; MAX_PAN_DESC_SUPPORTED],
|
||||
/// Categorization of energy detected in channel
|
||||
pub detected_category: u8,
|
||||
/// For UWB PHYs, the list of energy measurements taken
|
||||
pub uwb_energy_detect_list: [u8; MAX_ED_SCAN_RESULTS_SUPPORTED],
|
||||
}
|
||||
|
||||
/// MLME SET Confirm which reports the result of an attempt to write a value to a PIB attribute
|
||||
pub struct SetConfirm {
|
||||
/// The result of the set operation
|
||||
pub status: u8,
|
||||
/// The name of the PIB attribute that was written
|
||||
pub pin_attribute: u8,
|
||||
}
|
||||
|
||||
/// MLME START Confirm which is used to report the results of the attempt to
|
||||
/// start using a new superframe configuration
|
||||
pub struct StartConfirm {
|
||||
/// Result of the attempt to start using an updated superframe configuration
|
||||
pub status: u8,
|
||||
}
|
||||
|
||||
/// MLME POLL Confirm which is used to report the result of a request to poll the coordinator for data
|
||||
pub struct PollConfirm {
|
||||
/// The status of the data request
|
||||
pub status: u8,
|
||||
}
|
||||
|
||||
/// MLME SOUNDING Confirm which reports the result of a request to the PHY to provide
|
||||
/// channel sounding information
|
||||
pub struct SoundingConfirm {
|
||||
/// Results of the sounding measurement
|
||||
sounding_list: [u8; MAX_SOUNDING_LIST_SUPPORTED],
|
||||
}
|
||||
|
||||
/// MLME CALIBRATE Confirm which reports the result of a request to the PHY
|
||||
/// to provide internal propagation path information
|
||||
pub struct CalibrateConfirm {
|
||||
/// The status of the attempt to return sounding data
|
||||
pub status: u8,
|
||||
/// A count of the propagation time from the ranging counter
|
||||
/// to the transmit antenna
|
||||
pub cal_tx_rmaker_offset: u32,
|
||||
/// A count of the propagation time from the receive antenna
|
||||
/// to the ranging counter
|
||||
pub cal_rx_rmaker_offset: u32,
|
||||
}
|
||||
|
||||
/// MCPS DATA Confirm which will be used for reporting the results of
|
||||
/// MAC data related requests from the application
|
||||
pub struct DataConfirm {
|
||||
/// The handle associated with the MSDU being confirmed
|
||||
pub msdu_handle: u8,
|
||||
/// The time, in symbols, at which the data were transmitted
|
||||
pub a_time_stamp: [u8; 4],
|
||||
/// ranging status
|
||||
pub ranging_received: u8,
|
||||
/// The status of the last MSDU transmission
|
||||
pub status: u8,
|
||||
/// time units corresponding to an RMARKER at the antenna at
|
||||
/// the beginning of a ranging exchange
|
||||
pub ranging_counter_start: u32,
|
||||
/// time units corresponding to an RMARKER at the antenna
|
||||
/// at the end of a ranging exchange
|
||||
pub ranging_counter_stop: u32,
|
||||
/// time units in a message exchange over which the tracking offset was measured
|
||||
pub ranging_tracking_interval: u32,
|
||||
/// time units slipped or advanced by the radio tracking system
|
||||
pub ranging_offset: u32,
|
||||
/// The FoM characterizing the ranging measurement
|
||||
pub ranging_fom: u8,
|
||||
}
|
||||
|
||||
/// MCPS PURGE Confirm which will be used by the MAC to notify the application of
|
||||
/// the status of its request to purge an MSDU from the transaction queue
|
||||
pub struct PurgeConfirm {
|
||||
/// Handle associated with the MSDU requested to be purged from the transaction queue
|
||||
pub msdu_handle: u8,
|
||||
/// The status of the request
|
||||
pub status: u8,
|
||||
}
|
@ -95,3 +95,30 @@ pub union MacAddress {
|
||||
pub struct GtsCharacteristics {
|
||||
pub fields: u8,
|
||||
}
|
||||
|
||||
/// MAC PAN Descriptor which contains the network details of the device from
|
||||
/// which the beacon is received
|
||||
pub struct PanDescriptor {
|
||||
/// PAN identifier of the coordinator
|
||||
pub a_coord_pan_id: [u8; 2],
|
||||
/// Coordinator addressing mode
|
||||
pub coord_addr_mode: AddressMode,
|
||||
/// The current logical channel occupied by the network
|
||||
pub logical_channel: u8,
|
||||
/// Coordinator address
|
||||
pub coord_addr: MacAddress,
|
||||
/// The current channel page occupied by the network
|
||||
pub channel_page: u8,
|
||||
/// PAN coordinator is accepting GTS requests or not
|
||||
pub gts_permit: bool,
|
||||
/// Superframe specification as specified in the received beacon frame
|
||||
pub a_superframe_spec: [u8; 2],
|
||||
/// The time at which the beacon frame was received, in symbols
|
||||
pub a_time_stamp: [u8; 4],
|
||||
/// The LQI at which the network beacon was received
|
||||
pub link_quality: u8,
|
||||
/// Security level purportedly used by the received beacon frame
|
||||
pub security_level: u8,
|
||||
/// Byte Stuffing to keep 32 bit alignment
|
||||
pub a_stuffing: [u8; 2],
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user