Nol.A SDK Library 26.11.2
For IoT System Software Development
Loading...
Searching...
No Matches
IEEE802_15_4Frame Class Reference

IEEE 802.15.4 frame. More...

#include <IEEE802_15_4Frame.hpp>

Inheritance diagram for IEEE802_15_4Frame:
RadioPacket Printable

Classes

struct  EnhancedBeaconRequestInfo_t
struct  EnhancedBeaconInfo_t

Public Types

enum  SecurityMode_t {
  SEC_NONE = 0 , SEC_CBC_MAC_4 = 1 , SEC_CBC_MAC_8 = 2 , SEC_CBC_MAC_16 = 3 ,
  SEC_CTR = 4 , SEC_CCM_4 = 5 , SEC_CCM_8 = 6 , SEC_CCM_16 = 7
}
enum  Type_t {
  FRAME_BEACON = 0 , FRAME_DATA = 1 , FRAME_ACK = 2 , FRAME_MAC_COMMAND = 3 ,
  FRAME_UNKNOWN = 8
}
 Frame type. More...
enum  Ver_t { VER_2003 = 0 , VER_2006 = 1 , VER_CURRENT = 2 , VER_UNKNOWN = 4 }
 Frame version. More...
enum  Error_t {
  SUCCESS = 0 , INVALID_LEN = -1 , INVALID_TYPE = -2 , INVALID_ADDR = -3 ,
  ADDR_FILTERED_PAN = -4 , ADDR_FILTERED_EUI64 = -5 , ADDR_FILTERED_SHORT_ADDR = -6 , ADDR_FILTERED_SIMPLE_ADDR = -7 ,
  NOT_SUPPORTED = -8
}
 Error type. More...
enum  {
  ATTRIBUTE_ID_TRLE_ENABLED = (1 << 0) , ATTRIBUTE_ID_TSCH_ENABLED = (1 << 1) , ATTRIBUTE_ID_DSME_ENABLED = (1 << 2) , ATTRIBUTE_ID_LE_ENABLED = (1 << 3) ,
  ATTRIBUTE_ID_HOPPING_ENABLED = (1 << 4) , ATTRIBUTE_ID_DA_ENABLED = (1 << 5) , ATTRIBUTE_ID_MPM_IE = (1 << 6)
}
Public Types inherited from RadioPacket
enum  Result_t {
  SUCCESS = 0 , FAIL = -1 , NOT_ENOUGH_MEMORY = -2 , CANCELED = -3 ,
  TOO_BIG = -4 , DROPPED = -7 , INVALID_ARGS = -8 , TOO_NOISY = -9 ,
  CHANNEL_BUSY = -10 , INIT = -127
}

Public Member Functions

 IEEE802_15_4Frame (uint16_t payloadLength=0, Type_t t=FRAME_DATA, Ver_t v=VER_CURRENT)
 IEEE802_15_4Frame (const uint8_t *rawData, uint16_t len)
 IEEE802_15_4Frame (PacketRadioChip &chip)
uint16_t getHeaderLength ()
 Get MAC header length in unit of octets.
uint16_t getMaxPayloadLength ()
 Get the maximum payload length.
const void * getPayloadPointer () const
uint16_t setPayload (uint16_t index, const void *src, uint16_t len)
 Copy len byte of octets from memory area src to the payload buffer with index offset.
bool setPayloadAt (uint16_t index, uint8_t value)
 Set an octet of the payload buffer at index to value.
uint16_t getPayload (void *dst, uint16_t index, uint16_t len)
 Copy len bytes from the payload buffer with index offset to memory area dst.
int16_t getPayloadAt (uint16_t index) const
 Get an octet of the payload buffer at index.
int comparePayload (uint16_t index, const void *src, uint16_t len)
 Compare len bytes from the payload buffer and memory area src.
bool setPayloadLength (uint16_t len)
 Set payload length in unit of octets.
uint16_t getPayloadLength () const
 Get payload length in unit of octets.
void setType (Type_t t)
 Set frame type.
Type_t getType ()
 Get frame type.
void setSecurityEnabled (bool)
bool isSecurityEnabled ()
void setFsramePending ()
bool isFramePending ()
bool setAckRequest (bool request)
 Set Ack request flag.
bool requestsAck () const
 Get Ack request flag.
void setVersion (Ver_t v)
 Set frame version.
Ver_t getVersion () const
 Get frame version.
bool setSequence (int16_t seq)
 Set frame sequence.
int16_t getSequence () const
 Get frame version.
bool setDstAddr (IEEE802_15_4Address &dst)
 Set destination address.
IEEE802_15_4Address getDstAddr () const
 Get destination address.
bool setSrcAddr (IEEE802_15_4Address &src)
 Set source address.
IEEE802_15_4Address getSrcAddr () const
 Get source address.
bool getAddresses (IEEE802_15_4Address *dst, IEEE802_15_4Address *src) const
bool setAddresses (IEEE802_15_4Address &dst, IEEE802_15_4Address &src)
bool setIE (bool present)
 Set IE flag.
bool hasIE ()
 Get IE flag.
error_t make (uint8_t seq, bool ack)
Error_t verify (bool addrCheckRequired=false, uint16_t panId=0xFFFF, uint16_t nodeId=0xFFFF, const uint8_t *nodeEui64=nullptr)
EnhancedBeaconRequestInfo_t parseEnhancedBeaconRequest ()
EnhancedBeaconInfo_t parseEnhancedBeacon ()
Public Member Functions inherited from RadioPacket
 RadioPacket (uint16_t len=0)
void operator= (const RadioPacket &)
virtual size_t printTo (Print &) const override
virtual size_t printPropertiesTo (Print &p) const

Public Attributes

uint8_t txCount
 Number of Tx trials.
SecurityMode_t sec
uint32_t sec_frame_counter
uint8_t sec_key_idx
Public Attributes inherited from RadioPacket
Result_t result
 송신 또는 수신 패킷 처리 결과
int16_t power
 송신시 사용할 power (단위: dBm) 또는 수신시의 신호 세기 (단위: dB)
uint32_t freq
 송신시 사용할, 또는 수신시 사용된 주파수 (단위: Hz)
int64_t timestamp
 송신시 사용할, 또는 수신시의 타임스탬프
Radio::Modulation_t modulation
 송신시 사용할, 또는 수신시 사용된 변복조 방식
union { 
   struct { 
      int8_t   snr 
 수신시의 Signal-to-Noise Ratio (SNR)
      Radio::LoRaSF_t   sf 
 송신시 사용할, 또는 수신시 사용된 spreading factor
      Radio::LoRaCR_t   cr 
 송신시 사용할, 또는 수신시 사용된 coding rate
      Radio::LoRaBW_t   bw 
 송신시 사용할, 또는 수신시 사용된 bandwidth
      Radio::LoRaIQ_t   iq 
 송신시 사용할, 또는 수신시 사용된 I&Q signal mode
      uint16_t   preambleLength 
      Radio::AutoCRCOption_t   autoCrcOpt 
      Radio::FixedPayloadLengthOption_t   fixedPayloadLengthOpt 
      uint8_t   fixedPayloadLength 
      Radio::RxTimeoutOption_t   rxTimeoutOpt 
      uint16_t   rxTimeout 
   }   LoRa
 modulation 이 Radio::MOD_LORA 인 경우 사용되는 변수
   struct { 
      uint32_t   drBps 
 송신시 사용할, 또는 수신시 사용된 data rate (단위: bps)
      uint32_t   bwHz 
 송신시 사용할, 또는 수신시 사용된 bandwidth (단위: Hz)
      uint32_t   afcBwHz 
      uint32_t   fDevHz 
 송신시 사용할, 또는 수신시 사용된 frequency deviation (단위: Hz)
      uint16_t   preambleLength 
      Radio::AutoCRCOption_t   autoCrcOpt 
      Radio::FixedPayloadLengthOption_t   fixedPayloadLengthOpt 
      uint8_t   fixedPayloadLength 
      Radio::RxTimeoutOption_t   rxTimeoutOpt 
      uint16_t   rxTimeout 
   }   FSK
 modulation 이 Radio::MOD_FSK 인 경우 사용되는 변수
   struct { 
      uint8_t   corr 
 송신시 사용할, 또는 수신시 사용된 correlation
   }   DSSS
 modulation 이 Radio::MOD_DSSS 인 경우 사용되는 변수
} meta
 변복조 방식에 대한 속성
uint16_t len
uint8_t * buf

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
430 { ATTRIBUTE_ID_TRLE_ENABLED = (1 << 0),
431 ATTRIBUTE_ID_TSCH_ENABLED = (1 << 1),
432 ATTRIBUTE_ID_DSME_ENABLED = (1 << 2),
433 ATTRIBUTE_ID_LE_ENABLED = (1 << 3),
434 ATTRIBUTE_ID_HOPPING_ENABLED = (1 << 4),
435 ATTRIBUTE_ID_DA_ENABLED = (1 << 5),
436 ATTRIBUTE_ID_MPM_IE = (1 << 6) };

◆ Error_t

Error type.

208 {
209 SUCCESS = 0,
210 INVALID_LEN = -1,
211 INVALID_TYPE = -2,
212 INVALID_ADDR = -3,
213 ADDR_FILTERED_PAN = -4,
214 ADDR_FILTERED_EUI64 = -5,
215 ADDR_FILTERED_SHORT_ADDR = -6,
216 ADDR_FILTERED_SIMPLE_ADDR = -7,
217 NOT_SUPPORTED = -8,
218 } Error_t;
Error_t
Error type.
Definition IEEE802_15_4Frame.hpp:208

◆ SecurityMode_t

enum IEEE802_15_4Frame::SecurityMode_t
170 {
171 SEC_NONE = 0,
172 SEC_CBC_MAC_4 = 1,
173 SEC_CBC_MAC_8 = 2,
174 SEC_CBC_MAC_16 = 3,
175 SEC_CTR = 4,
176 SEC_CCM_4 = 5,
177 SEC_CCM_8 = 6,
178 SEC_CCM_16 = 7,
179 } SecurityMode_t;

◆ Type_t

Frame type.

187 {
188 FRAME_BEACON = 0,
189 FRAME_DATA = 1,
190 FRAME_ACK = 2,
191 FRAME_MAC_COMMAND = 3,
192 FRAME_UNKNOWN = 8,
193 } Type_t;
Type_t
Frame type.
Definition IEEE802_15_4Frame.hpp:187

◆ Ver_t

Frame version.

Enumerator
VER_2003 

IEEE Std 802.15.4-2003

VER_2006 

IEEE Std 802.15.4-2006

VER_CURRENT 

IEEE Std 802.15.4

198 {
199 VER_2003 = 0,
200 VER_2006 = 1,
201 VER_CURRENT = 2,
202 VER_UNKNOWN = 4,
203 } Ver_t;
Ver_t
Frame version.
Definition IEEE802_15_4Frame.hpp:198
@ VER_2003
Definition IEEE802_15_4Frame.hpp:199
@ VER_2006
Definition IEEE802_15_4Frame.hpp:200
@ VER_CURRENT
Definition IEEE802_15_4Frame.hpp:201

Constructor & Destructor Documentation

◆ IEEE802_15_4Frame()

IEEE802_15_4Frame::IEEE802_15_4Frame ( uint16_t payloadLength = 0,
Type_t t = FRAME_DATA,
Ver_t v = VER_CURRENT )
Parameters
payloadLengthMaximum payload length
tFrame type
vIEEE 802.15.4 version

It tries to allocate memory size payloadLength + 37 (maximum header size). If it fails, getHeaderLength() returns 0. And all manipulating methods will not work correctly.

Member Function Documentation

◆ comparePayload()

int IEEE802_15_4Frame::comparePayload ( uint16_t index,
const void * src,
uint16_t len )

Compare len bytes from the payload buffer and memory area src.

Returns
Same with memcmp().

◆ getDstAddr()

IEEE802_15_4Address IEEE802_15_4Frame::getDstAddr ( ) const
inline

Get destination address.

377 {
378 IEEE802_15_4Address addr;
379 getAddresses(&addr, nullptr);
380 return addr;
381 }

◆ getPayload()

uint16_t IEEE802_15_4Frame::getPayload ( void * dst,
uint16_t index,
uint16_t len )

Copy len bytes from the payload buffer with index offset to memory area dst.

Returns
Actual number of copied bytes

It copies with bound checking. The only octets of the valid buffer area will be copied to the dst area.

◆ getPayloadAt()

int16_t IEEE802_15_4Frame::getPayloadAt ( uint16_t index) const

Get an octet of the payload buffer at index.

Returns
Data if positive. Failed due to index out of bound if negative.
Examples
atsamr21-xpro/LPP-Receiver/main.cpp, atsamr21-xpro/LPP-Sender/main.cpp, st-nucleo-l152re/LPP-Receiver/main.cpp, and st-nucleo-l152re/LPP-Sender/main.cpp.

◆ getSequence()

int16_t IEEE802_15_4Frame::getSequence ( ) const
inline

Get frame version.

Returns
Frame sequence is suppressed if -1 (only for VER_CURRENT). Otherwise, the frame sequence.
356 {
357 if (this->buf == nullptr ||
358 (this->getVersion() == VER_CURRENT && bitRead(this->buf[1], 0) == 1)) {
359 return -1;
360 }
361
362 return this->buf[2];
363 }
Ver_t getVersion() const
Get frame version.
Definition IEEE802_15_4Frame.hpp:337
#define bitRead(v, n)
수의 한 비트를 읽습니다.
Definition nola-common.h:339

◆ getSrcAddr()

IEEE802_15_4Address IEEE802_15_4Frame::getSrcAddr ( ) const
inline

Get source address.

Examples
atsamr21-xpro/LPP-Receiver/main.cpp, and st-nucleo-l152re/LPP-Receiver/main.cpp.
395 {
396 IEEE802_15_4Address addr;
397 getAddresses(nullptr, &addr);
398 return addr;
399 }

◆ getVersion()

Ver_t IEEE802_15_4Frame::getVersion ( ) const
inline

Get frame version.

337 {
338 if (this->buf == nullptr) {
339 return VER_UNKNOWN;
340 }
341
342 return (Ver_t) ((this->buf[1] >> 4) & 0b11);
343 }

◆ make()

error_t IEEE802_15_4Frame::make ( uint8_t seq,
bool ack )
inline
415 {
416 if (this->buf && setSequence(seq) && setAckRequest(ack)) {
417 return ERROR_SUCCESS;
418 } else {
419 return ERROR_FAIL;
420 }
421 }
bool setSequence(int16_t seq)
Set frame sequence.
bool setAckRequest(bool request)
Set Ack request flag.
@ ERROR_FAIL
Definition nola-common.h:120
@ ERROR_SUCCESS
Definition nola-common.h:119

◆ setDstAddr()

bool IEEE802_15_4Frame::setDstAddr ( IEEE802_15_4Address & dst)
inline

Set destination address.

Examples
st-nucleo-l152re/LPP-Sender/main.cpp.
368 {
369 IEEE802_15_4Address src;
370 getAddresses(nullptr, &src);
371 return setAddresses(dst, src);
372 }

◆ setPayload()

uint16_t IEEE802_15_4Frame::setPayload ( uint16_t index,
const void * src,
uint16_t len )

Copy len byte of octets from memory area src to the payload buffer with index offset.

Returns
Actual number of copied bytes

It copies with bound checking. That means byte out of bounds will not be manipulated.

It does not manipulate payload length. After manipulating, set length by using setPayloadLength().

◆ setPayloadAt()

bool IEEE802_15_4Frame::setPayloadAt ( uint16_t index,
uint8_t value )

Set an octet of the payload buffer at index to value.

Returns
Successful if true
Examples
atsamr21-xpro/LPP-Sender/main.cpp, and st-nucleo-l152re/LPP-Sender/main.cpp.

◆ setPayloadLength()

bool IEEE802_15_4Frame::setPayloadLength ( uint16_t len)

Set payload length in unit of octets.

Returns
Successful if true. len exceeds the maximum payload length (getHeaderLength() + getPayloadLength()) if false.
Examples
atsamr21-xpro/LPP-Sender/main.cpp.

◆ setSequence()

bool IEEE802_15_4Frame::setSequence ( int16_t seq)

Set frame sequence.

Parameters
seqLow byte of the positive number will be the frame sequence. If it is negative, the frame sequence is suppressed (only for VER_CURRENT).
Returns
Successful if true.

◆ setSrcAddr()

bool IEEE802_15_4Frame::setSrcAddr ( IEEE802_15_4Address & src)
inline

Set source address.

386 {
387 IEEE802_15_4Address dst;
388 getAddresses(&dst, nullptr);
389 return setAddresses(dst, src);
390 }

The documentation for this class was generated from the following file: