SDK  23.9.2
For IoT System Software Development
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
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  EnhancedBeaconInfo_t
 
struct  EnhancedBeaconRequestInfo_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.
 
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.
 
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, 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. More...
 
bool setPayloadAt (uint16_t index, uint8_t value)
 Set an octet of the payload buffer at index to value. More...
 
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. More...
 
int16_t getPayloadAt (uint16_t index) const
 Get an octet of the payload buffer at index. More...
 
int comparePayload (uint16_t index, const void *src, uint16_t len)
 Compare len bytes from the payload buffer and memory area src. More...
 
bool setPayloadLength (uint16_t len)
 Set payload length in unit of octets. More...
 
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. More...
 
int16_t getSequence () const
 Get frame version. More...
 
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
 송신시 사용할, 또는 수신시의 타임스탬프 More...
 
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
 변복조 방식에 대한 속성 More...
 
uint16_t len
 
uint8_t * buf
 

Detailed Description

IEEE 802.15.4 frame.

Member Enumeration Documentation

◆ 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

182  {
183  VER_2003 = 0,
184  VER_2006 = 1,
185  VER_CURRENT = 2,
186  VER_UNKNOWN = 4,
187  } Ver_t;

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().

◆ 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.

◆ 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.
340  {
341  if (this->buf == nullptr ||
342  (this->getVersion() == VER_CURRENT && bitRead(this->buf[1], 0) == 1)) {
343  return -1;
344  }
345 
346  return this->buf[2];
347  }

◆ 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

◆ 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.

◆ 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.

The documentation for this class was generated from the following file:
IEEE802_15_4Frame::VER_2003
@ VER_2003
Definition: IEEE802_15_4Frame.hpp:183
IEEE802_15_4Frame::getVersion
Ver_t getVersion() const
Get frame version.
Definition: IEEE802_15_4Frame.hpp:321
IEEE802_15_4Frame::Ver_t
Ver_t
Frame version.
Definition: IEEE802_15_4Frame.hpp:182
bitRead
#define bitRead(v, n)
수의 한 비트를 읽습니다.
Definition: nola-common.h:336
IEEE802_15_4Frame::VER_CURRENT
@ VER_CURRENT
Definition: IEEE802_15_4Frame.hpp:185
IEEE802_15_4Frame::VER_2006
@ VER_2006
Definition: IEEE802_15_4Frame.hpp:184