@@ -9,6 +9,7 @@ use super::typedefs::{
99 AddressMode , Capabilities , DisassociationReason , KeyIdMode , MacAddress , MacChannel , MacStatus , PanDescriptor ,
1010 PanId , SecurityLevel ,
1111} ;
12+ use crate :: mac:: typedefs:: MacAddressAndMode ;
1213
1314/// MLME ASSOCIATE Indication which will be used by the MAC
1415/// to indicate the reception of an association request command
@@ -77,6 +78,22 @@ pub struct BeaconNotifyIndication {
7778
7879impl ParseableMacEvent for BeaconNotifyIndication { }
7980
81+ impl BeaconNotifyIndication {
82+ pub fn payload < ' a > ( & ' a self ) -> & ' a mut [ u8 ] {
83+ unsafe { slice:: from_raw_parts_mut ( self . sdu_ptr as * mut _ , self . sdu_length as usize ) }
84+ }
85+ }
86+
87+ pub fn write_frame_from_beacon_indication < ' a , T : AsRef < [ u8 ] > + AsMut < [ u8 ] > > (
88+ data : & ' a BeaconNotifyIndication ,
89+ buffer : & ' a mut T ,
90+ ) {
91+ let mut frame = Frame :: new_unchecked ( buffer) ;
92+
93+ frame. set_frame_type ( Ieee802154FrameType :: Beacon ) ;
94+ frame. set_sequence_number ( data. bsn ) ;
95+ }
96+
8097/// MLME COMM STATUS Indication which is used by the MAC to indicate a communications status
8198#[ repr( C ) ]
8299#[ derive( Debug ) ]
@@ -256,13 +273,13 @@ impl DataIndication {
256273pub fn write_frame_from_data_indication < ' a , T : AsRef < [ u8 ] > + AsMut < [ u8 ] > > ( data : & ' a DataIndication , buffer : & ' a mut T ) {
257274 let mut frame = Frame :: new_unchecked ( buffer) ;
258275
259- // TODO: complete frame creation
260276 frame. set_frame_type ( Ieee802154FrameType :: Data ) ;
261- frame. set_dst_addr ( data. dst_address . into ( ) ) ;
262- frame. set_src_addr ( data. src_address . into ( ) ) ;
277+ frame. set_src_addr ( MacAddressAndMode ( data. src_address , data . src_addr_mode ) . into ( ) ) ;
278+ frame. set_dst_addr ( MacAddressAndMode ( data. dst_address , data . dst_addr_mode ) . into ( ) ) ;
263279 frame. set_dst_pan_id ( data. dst_pan_id . into ( ) ) ;
264280 frame. set_src_pan_id ( data. src_pan_id . into ( ) ) ;
265281 frame. set_sequence_number ( data. dsn ) ;
282+ frame. set_security_enabled ( data. security_level == SecurityLevel :: Secured ) ;
266283
267284 // No way around the copy with the current API
268285 frame. payload_mut ( ) . unwrap ( ) . copy_from_slice ( data. payload ( ) ) ;
0 commit comments