diff options
| author | goueslati <[email protected]> | 2023-07-11 17:19:32 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-07-11 17:19:32 +0100 |
| commit | fbddfcbfb7f732db593eecd5383742d9ce7308e7 (patch) | |
| tree | c3057ed72562cb4edd7572f9677c970661dccc36 /embassy-stm32-wpan/src | |
| parent | 67b14e6e7a98abc538adda45d6434ad44d700283 (diff) | |
wip: added MAC indications
Diffstat (limited to 'embassy-stm32-wpan/src')
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac/consts.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac/indications.rs | 205 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac/mod.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac/responses.rs | 14 |
4 files changed, 221 insertions, 0 deletions
diff --git a/embassy-stm32-wpan/src/sub/mac/consts.rs b/embassy-stm32-wpan/src/sub/mac/consts.rs index dfbbadc67..892d533b4 100644 --- a/embassy-stm32-wpan/src/sub/mac/consts.rs +++ b/embassy-stm32-wpan/src/sub/mac/consts.rs | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | pub const MAX_ED_SCAN_RESULTS_SUPPORTED: usize = 16; | 1 | pub const MAX_ED_SCAN_RESULTS_SUPPORTED: usize = 16; |
| 2 | pub const MAX_PAN_DESC_SUPPORTED: usize = 6; | 2 | pub const MAX_PAN_DESC_SUPPORTED: usize = 6; |
| 3 | pub const MAX_SOUNDING_LIST_SUPPORTED: usize = 6; | 3 | pub const MAX_SOUNDING_LIST_SUPPORTED: usize = 6; |
| 4 | pub const MAX_PENDING_ADDRESS: usize = 7; | ||
diff --git a/embassy-stm32-wpan/src/sub/mac/indications.rs b/embassy-stm32-wpan/src/sub/mac/indications.rs new file mode 100644 index 000000000..ebca16f72 --- /dev/null +++ b/embassy-stm32-wpan/src/sub/mac/indications.rs | |||
| @@ -0,0 +1,205 @@ | |||
| 1 | use super::consts::MAX_PENDING_ADDRESS; | ||
| 2 | use super::typedefs::{AddressMode, MacAddress, PanDescriptor}; | ||
| 3 | |||
| 4 | /// MLME ASSOCIATE Indication which will be used by the MAC | ||
| 5 | /// to indicate the reception of an association request command | ||
| 6 | #[repr(C)] | ||
| 7 | pub struct AssociateIndication { | ||
| 8 | /// Extended address of the device requesting association | ||
| 9 | pub device_address: [u8; 8], | ||
| 10 | /// Operational capabilities of the device requesting association | ||
| 11 | pub capability_information: u8, | ||
| 12 | /// Security level purportedly used by the received MAC command frame | ||
| 13 | pub security_level: u8, | ||
| 14 | /// The mode used to identify the key used by the originator of frame | ||
| 15 | pub key_id_mode: u8, | ||
| 16 | /// Index of the key used by the originator of the received frame | ||
| 17 | pub key_index: u8, | ||
| 18 | /// The originator of the key used by the originator of the received frame | ||
| 19 | pub key_source: [u8; 8], | ||
| 20 | } | ||
| 21 | |||
| 22 | /// MLME DISASSOCIATE indication which will be used to send | ||
| 23 | /// disassociation indication to the application. | ||
| 24 | #[repr(C)] | ||
| 25 | pub struct DisassociateIndication { | ||
| 26 | /// Extended address of the device requesting association | ||
| 27 | pub device_address: [u8; 8], | ||
| 28 | /// The reason for the disassociation | ||
| 29 | pub disassociate_reason: u8, | ||
| 30 | /// The security level to be used | ||
| 31 | pub security_level: u8, | ||
| 32 | /// The mode used to identify the key to be used | ||
| 33 | pub key_id_mode: u8, | ||
| 34 | /// The index of the key to be used | ||
| 35 | pub key_index: u8, | ||
| 36 | /// The originator of the key to be used | ||
| 37 | pub key_source: [u8; 8], | ||
| 38 | } | ||
| 39 | |||
| 40 | /// MLME BEACON NOTIIFY Indication which is used to send parameters contained | ||
| 41 | /// within a beacon frame received by the MAC to the application | ||
| 42 | #[repr(C)] | ||
| 43 | pub struct BeaconNotifyIndication { | ||
| 44 | /// he set of octets comprising the beacon payload to be transferred | ||
| 45 | /// from the MAC sublayer entity to the next higher layer | ||
| 46 | pub sdu_ptr: *const u8, | ||
| 47 | /// The PAN Descriptor for the received beacon | ||
| 48 | pub pan_descriptor: PanDescriptor, | ||
| 49 | /// The list of addresses of the devices | ||
| 50 | pub addr_list: [MacAddress; MAX_PENDING_ADDRESS], | ||
| 51 | /// Beacon Sequence Number | ||
| 52 | pub bsn: u8, | ||
| 53 | /// The beacon pending address specification | ||
| 54 | pub pend_addr_spec: u8, | ||
| 55 | /// Number of octets contained in the beacon payload of the beacon frame | ||
| 56 | pub sdu_length: u8, | ||
| 57 | } | ||
| 58 | |||
| 59 | /// MLME COMM STATUS Indication which is used by the MAC to indicate a communications status | ||
| 60 | #[repr(C)] | ||
| 61 | pub struct CommStatusIndication { | ||
| 62 | /// The 16-bit PAN identifier of the device from which the frame | ||
| 63 | /// was received or to which the frame was being sent | ||
| 64 | pub pan_id: [u8; 2], | ||
| 65 | /// Source addressing mode | ||
| 66 | pub src_addr_mode: AddressMode, | ||
| 67 | /// Destination addressing mode | ||
| 68 | pub dst_addr_mode: AddressMode, | ||
| 69 | /// Source address | ||
| 70 | pub src_address: MacAddress, | ||
| 71 | /// Destination address | ||
| 72 | pub dst_address: MacAddress, | ||
| 73 | /// The communications status | ||
| 74 | pub status: u8, | ||
| 75 | /// Security level to be used | ||
| 76 | pub security_level: u8, | ||
| 77 | /// Mode used to identify the key to be used | ||
| 78 | pub key_id_mode: u8, | ||
| 79 | /// Index of the key to be used | ||
| 80 | pub key_index: u8, | ||
| 81 | /// Originator of the key to be used | ||
| 82 | pub key_source: [u8; 8], | ||
| 83 | } | ||
| 84 | |||
| 85 | /// MLME GTS Indication indicates that a GTS has been allocated or that a | ||
| 86 | /// previously allocated GTS has been deallocated | ||
| 87 | #[repr(C)] | ||
| 88 | pub struct GtsIndication { | ||
| 89 | /// The short address of the device that has been allocated or deallocated a GTS | ||
| 90 | pub device_address: [u8; 2], | ||
| 91 | /// The characteristics of the GTS | ||
| 92 | pub gts_characteristics: u8, | ||
| 93 | /// Security level to be used | ||
| 94 | pub security_level: u8, | ||
| 95 | /// Mode used to identify the key to be used | ||
| 96 | pub key_id_mode: u8, | ||
| 97 | /// Index of the key to be used | ||
| 98 | pub key_index: u8, | ||
| 99 | /// Originator of the key to be used | ||
| 100 | pub key_source: [u8; 8], | ||
| 101 | } | ||
| 102 | |||
| 103 | /// MLME ORPHAN Indication which is used by the coordinator to notify the | ||
| 104 | /// application of the presence of an orphaned device | ||
| 105 | #[repr(C)] | ||
| 106 | pub struct OrphanIndication { | ||
| 107 | /// Extended address of the orphaned device | ||
| 108 | pub orphan_address: [u8; 8], | ||
| 109 | /// Originator of the key used by the originator of the received frame | ||
| 110 | pub key_source: [u8; 8], | ||
| 111 | /// Security level purportedly used by the received MAC command frame | ||
| 112 | pub security_level: u8, | ||
| 113 | /// Mode used to identify the key used by originator of received frame | ||
| 114 | pub key_id_mode: u8, | ||
| 115 | /// Index of the key used by the originator of the received frame | ||
| 116 | pub key_index: u8, | ||
| 117 | } | ||
| 118 | |||
| 119 | /// MLME SYNC LOSS Indication which is used by the MAC to indicate the loss | ||
| 120 | /// of synchronization with the coordinator | ||
| 121 | #[repr(C)] | ||
| 122 | pub struct SyncLossIndication { | ||
| 123 | /// The PAN identifier with which the device lost synchronization or to which it was realigned | ||
| 124 | pub pan_id: [u8; 2], | ||
| 125 | /// The reason that synchronization was lost | ||
| 126 | pub loss_reason: u8, | ||
| 127 | /// The logical channel on which the device lost synchronization or to whi | ||
| 128 | pub channel_number: u8, | ||
| 129 | /// The channel page on which the device lost synchronization or to which | ||
| 130 | pub channel_page: u8, | ||
| 131 | /// The security level used by the received MAC frame | ||
| 132 | pub security_level: u8, | ||
| 133 | /// Mode used to identify the key used by originator of received frame | ||
| 134 | pub key_id_mode: u8, | ||
| 135 | /// Index of the key used by the originator of the received frame | ||
| 136 | pub key_index: u8, | ||
| 137 | /// Originator of the key used by the originator of the received frame | ||
| 138 | pub key_source: [u8; 8], | ||
| 139 | } | ||
| 140 | |||
| 141 | /// MLME DPS Indication which indicates the expiration of the DPSIndexDuration | ||
| 142 | /// and the resetting of the DPS values in the PHY | ||
| 143 | pub struct DpsIndication; | ||
| 144 | |||
| 145 | #[repr(C)] | ||
| 146 | pub struct DataIndication { | ||
| 147 | /// Pointer to the set of octets forming the MSDU being indicated | ||
| 148 | pub msdu_ptr: *const u8, | ||
| 149 | /// Source addressing mode used | ||
| 150 | pub src_addr_mode: u8, | ||
| 151 | /// Source PAN ID | ||
| 152 | pub src_pan_id: [u8; 2], | ||
| 153 | /// Source address | ||
| 154 | pub src_address: MacAddress, | ||
| 155 | /// Destination addressing mode used | ||
| 156 | pub dst_addr_mode: AddressMode, | ||
| 157 | /// Destination PAN ID | ||
| 158 | pub dst_pan_id: [u8; 2], | ||
| 159 | /// Destination address | ||
| 160 | pub dst_address: MacAddress, | ||
| 161 | /// The number of octets contained in the MSDU being indicated | ||
| 162 | pub msdu_length: u8, | ||
| 163 | /// QI value measured during reception of the MPDU | ||
| 164 | pub mpdu_link_quality: u8, | ||
| 165 | /// The data sequence number of the received data frame | ||
| 166 | pub dsn: u8, | ||
| 167 | /// The time, in symbols, at which the data were received | ||
| 168 | pub time_stamp: [u8; 4], | ||
| 169 | /// The security level purportedly used by the received data frame | ||
| 170 | pub security_level: u8, | ||
| 171 | /// Mode used to identify the key used by originator of received frame | ||
| 172 | pub key_id_mode: u8, | ||
| 173 | /// The originator of the key | ||
| 174 | pub key_source: [u8; 8], | ||
| 175 | /// The index of the key | ||
| 176 | pub key_index: u8, | ||
| 177 | /// he pulse repetition value of the received PPDU | ||
| 178 | pub uwbprf: u8, | ||
| 179 | /// The preamble symbol repetitions of the UWB PHY frame | ||
| 180 | pub uwn_preamble_symbol_repetitions: u8, | ||
| 181 | /// Indicates the data rate | ||
| 182 | pub datrate: u8, | ||
| 183 | /// time units corresponding to an RMARKER at the antenna at the end of a ranging exchange, | ||
| 184 | pub ranging_received: u8, | ||
| 185 | pub ranging_counter_start: u32, | ||
| 186 | pub ranging_counter_stop: u32, | ||
| 187 | /// ime units in a message exchange over which the tracking offset was measured | ||
| 188 | pub ranging_tracking_interval: u32, | ||
| 189 | /// time units slipped or advanced by the radio tracking system | ||
| 190 | pub ranging_offset: u32, | ||
| 191 | /// The FoM characterizing the ranging measurement | ||
| 192 | pub ranging_fom: u8, | ||
| 193 | /// The Received Signal Strength Indicator measured | ||
| 194 | pub rssi: u8, | ||
| 195 | } | ||
| 196 | |||
| 197 | /// MLME POLL Indication which will be used for indicating the Data Request | ||
| 198 | /// reception to upper layer as defined in Zigbee r22 - D.8.2 | ||
| 199 | #[repr(C)] | ||
| 200 | pub struct PollIndication { | ||
| 201 | /// addressing mode used | ||
| 202 | pub addr_mode: u8, | ||
| 203 | /// Poll requester address | ||
| 204 | pub request_address: MacAddress, | ||
| 205 | } | ||
diff --git a/embassy-stm32-wpan/src/sub/mac/mod.rs b/embassy-stm32-wpan/src/sub/mac/mod.rs index 6a3a057f4..756d7d5b1 100644 --- a/embassy-stm32-wpan/src/sub/mac/mod.rs +++ b/embassy-stm32-wpan/src/sub/mac/mod.rs | |||
| @@ -18,6 +18,7 @@ use crate::{channels, evt}; | |||
| 18 | 18 | ||
| 19 | pub mod commands; | 19 | pub mod commands; |
| 20 | mod consts; | 20 | mod consts; |
| 21 | pub mod indications; | ||
| 21 | mod opcodes; | 22 | mod opcodes; |
| 22 | pub mod responses; | 23 | pub mod responses; |
| 23 | pub mod typedefs; | 24 | pub mod typedefs; |
diff --git a/embassy-stm32-wpan/src/sub/mac/responses.rs b/embassy-stm32-wpan/src/sub/mac/responses.rs index 7b240f370..8c30a1823 100644 --- a/embassy-stm32-wpan/src/sub/mac/responses.rs +++ b/embassy-stm32-wpan/src/sub/mac/responses.rs | |||
| @@ -9,6 +9,7 @@ pub trait MacResponse { | |||
| 9 | 9 | ||
| 10 | /// MLME ASSOCIATE Confirm used to inform of the initiating device whether | 10 | /// MLME ASSOCIATE Confirm used to inform of the initiating device whether |
| 11 | /// its request to associate was successful or unsuccessful | 11 | /// its request to associate was successful or unsuccessful |
| 12 | #[repr(C)] | ||
| 12 | pub struct AssociateConfirm { | 13 | pub struct AssociateConfirm { |
| 13 | /// short address allocated by the coordinator on successful association | 14 | /// short address allocated by the coordinator on successful association |
| 14 | pub assoc_short_address: [u8; 2], | 15 | pub assoc_short_address: [u8; 2], |
| @@ -25,6 +26,7 @@ pub struct AssociateConfirm { | |||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | /// MLME DISASSOCIATE Confirm used to send disassociation Confirmation to the application. | 28 | /// MLME DISASSOCIATE Confirm used to send disassociation Confirmation to the application. |
| 29 | #[repr(C)] | ||
| 28 | pub struct DisassociateConfirm { | 30 | pub struct DisassociateConfirm { |
| 29 | /// status of the disassociation attempt | 31 | /// status of the disassociation attempt |
| 30 | pub status: u8, | 32 | pub status: u8, |
| @@ -37,6 +39,7 @@ pub struct DisassociateConfirm { | |||
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | /// MLME GET Confirm which requests information about a given PIB attribute | 41 | /// MLME GET Confirm which requests information about a given PIB attribute |
| 42 | #[repr(C)] | ||
| 40 | pub struct GetConfirm { | 43 | pub struct GetConfirm { |
| 41 | /// The pointer to the value of the PIB attribute attempted to read | 44 | /// The pointer to the value of the PIB attribute attempted to read |
| 42 | pub pib_attribute_value_ptr: *const u8, | 45 | pub pib_attribute_value_ptr: *const u8, |
| @@ -50,6 +53,7 @@ pub struct GetConfirm { | |||
| 50 | 53 | ||
| 51 | /// MLME GTS Confirm which eports the results of a request to allocate a new GTS | 54 | /// MLME GTS Confirm which eports the results of a request to allocate a new GTS |
| 52 | /// or to deallocate an existing GTS | 55 | /// or to deallocate an existing GTS |
| 56 | #[repr(C)] | ||
| 53 | pub struct GtsConfirm { | 57 | pub struct GtsConfirm { |
| 54 | /// The characteristics of the GTS | 58 | /// The characteristics of the GTS |
| 55 | pub gts_characteristics: u8, | 59 | pub gts_characteristics: u8, |
| @@ -58,6 +62,7 @@ pub struct GtsConfirm { | |||
| 58 | } | 62 | } |
| 59 | 63 | ||
| 60 | /// MLME RESET Confirm which is used to report the results of the reset operation | 64 | /// MLME RESET Confirm which is used to report the results of the reset operation |
| 65 | #[repr(C)] | ||
| 61 | pub struct ResetConfirm { | 66 | pub struct ResetConfirm { |
| 62 | /// The result of the reset operation | 67 | /// The result of the reset operation |
| 63 | status: u8, | 68 | status: u8, |
| @@ -65,12 +70,14 @@ pub struct ResetConfirm { | |||
| 65 | 70 | ||
| 66 | /// MLME RX ENABLE Confirm which is used to report the results of the attempt | 71 | /// MLME RX ENABLE Confirm which is used to report the results of the attempt |
| 67 | /// to enable or disable the receiver | 72 | /// to enable or disable the receiver |
| 73 | #[repr(C)] | ||
| 68 | pub struct RxEnableConfirm { | 74 | pub struct RxEnableConfirm { |
| 69 | /// Result of the request to enable or disable the receiver | 75 | /// Result of the request to enable or disable the receiver |
| 70 | status: u8, | 76 | status: u8, |
| 71 | } | 77 | } |
| 72 | 78 | ||
| 73 | /// MLME SCAN Confirm which is used to report the result of the channel scan request | 79 | /// MLME SCAN Confirm which is used to report the result of the channel scan request |
| 80 | #[repr(C)] | ||
| 74 | pub struct ScanConfirm { | 81 | pub struct ScanConfirm { |
| 75 | /// Status of the scan request | 82 | /// Status of the scan request |
| 76 | pub status: u8, | 83 | pub status: u8, |
| @@ -93,6 +100,7 @@ pub struct ScanConfirm { | |||
| 93 | } | 100 | } |
| 94 | 101 | ||
| 95 | /// MLME SET Confirm which reports the result of an attempt to write a value to a PIB attribute | 102 | /// MLME SET Confirm which reports the result of an attempt to write a value to a PIB attribute |
| 103 | #[repr(C)] | ||
| 96 | pub struct SetConfirm { | 104 | pub struct SetConfirm { |
| 97 | /// The result of the set operation | 105 | /// The result of the set operation |
| 98 | pub status: u8, | 106 | pub status: u8, |
| @@ -102,12 +110,14 @@ pub struct SetConfirm { | |||
| 102 | 110 | ||
| 103 | /// MLME START Confirm which is used to report the results of the attempt to | 111 | /// MLME START Confirm which is used to report the results of the attempt to |
| 104 | /// start using a new superframe configuration | 112 | /// start using a new superframe configuration |
| 113 | #[repr(C)] | ||
| 105 | pub struct StartConfirm { | 114 | pub struct StartConfirm { |
| 106 | /// Result of the attempt to start using an updated superframe configuration | 115 | /// Result of the attempt to start using an updated superframe configuration |
| 107 | pub status: u8, | 116 | pub status: u8, |
| 108 | } | 117 | } |
| 109 | 118 | ||
| 110 | /// MLME POLL Confirm which is used to report the result of a request to poll the coordinator for data | 119 | /// MLME POLL Confirm which is used to report the result of a request to poll the coordinator for data |
| 120 | #[repr(C)] | ||
| 111 | pub struct PollConfirm { | 121 | pub struct PollConfirm { |
| 112 | /// The status of the data request | 122 | /// The status of the data request |
| 113 | pub status: u8, | 123 | pub status: u8, |
| @@ -115,6 +125,7 @@ pub struct PollConfirm { | |||
| 115 | 125 | ||
| 116 | /// MLME SOUNDING Confirm which reports the result of a request to the PHY to provide | 126 | /// MLME SOUNDING Confirm which reports the result of a request to the PHY to provide |
| 117 | /// channel sounding information | 127 | /// channel sounding information |
| 128 | #[repr(C)] | ||
| 118 | pub struct SoundingConfirm { | 129 | pub struct SoundingConfirm { |
| 119 | /// Results of the sounding measurement | 130 | /// Results of the sounding measurement |
| 120 | sounding_list: [u8; MAX_SOUNDING_LIST_SUPPORTED], | 131 | sounding_list: [u8; MAX_SOUNDING_LIST_SUPPORTED], |
| @@ -122,6 +133,7 @@ pub struct SoundingConfirm { | |||
| 122 | 133 | ||
| 123 | /// MLME CALIBRATE Confirm which reports the result of a request to the PHY | 134 | /// MLME CALIBRATE Confirm which reports the result of a request to the PHY |
| 124 | /// to provide internal propagation path information | 135 | /// to provide internal propagation path information |
| 136 | #[repr(C)] | ||
| 125 | pub struct CalibrateConfirm { | 137 | pub struct CalibrateConfirm { |
| 126 | /// The status of the attempt to return sounding data | 138 | /// The status of the attempt to return sounding data |
| 127 | pub status: u8, | 139 | pub status: u8, |
| @@ -135,6 +147,7 @@ pub struct CalibrateConfirm { | |||
| 135 | 147 | ||
| 136 | /// MCPS DATA Confirm which will be used for reporting the results of | 148 | /// MCPS DATA Confirm which will be used for reporting the results of |
| 137 | /// MAC data related requests from the application | 149 | /// MAC data related requests from the application |
| 150 | #[repr(C)] | ||
| 138 | pub struct DataConfirm { | 151 | pub struct DataConfirm { |
| 139 | /// The handle associated with the MSDU being confirmed | 152 | /// The handle associated with the MSDU being confirmed |
| 140 | pub msdu_handle: u8, | 153 | pub msdu_handle: u8, |
| @@ -160,6 +173,7 @@ pub struct DataConfirm { | |||
| 160 | 173 | ||
| 161 | /// MCPS PURGE Confirm which will be used by the MAC to notify the application of | 174 | /// MCPS PURGE Confirm which will be used by the MAC to notify the application of |
| 162 | /// the status of its request to purge an MSDU from the transaction queue | 175 | /// the status of its request to purge an MSDU from the transaction queue |
| 176 | #[repr(C)] | ||
| 163 | pub struct PurgeConfirm { | 177 | pub struct PurgeConfirm { |
| 164 | /// Handle associated with the MSDU requested to be purged from the transaction queue | 178 | /// Handle associated with the MSDU requested to be purged from the transaction queue |
| 165 | pub msdu_handle: u8, | 179 | pub msdu_handle: u8, |
