SDK  23.9.2
For IoT System Software Development
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TSCHMac Class Referenceabstract

IEEE 802.15.4e TSCH (Time Slotted Channel Hopping) mode MAC. More...

#include <TSCHMac.hpp>

Inheritance diagram for TSCHMac:
IEEE802_15_4Mac TSCHMacRunnable PacketRadio

Public Types

enum  { LINK_TRANSMIT = (1 << 0), LINK_RECEIVE = (1 << 1), LINK_SHARED = (1 << 2), LINK_TIMEKEEPING = (1 << 3) }
 

Public Member Functions

virtual void begin (PacketRadioChip &chip, uint16_t panId, uint16_t nodeId, const uint8_t *eui64=nullptr, bool isCoordinator=false)
 TSCHMac 을 초기화합니다. More...
 
void setHoppingSequence (uint8_t hopSeqId, uint16_t hopSeqListLen, const uint16_t *hopSeqList, int32_t(*channelConverter)(uint16_t channel))
 채널 hopping sequence를 설정합니다. More...
 
error_t run ()
 Run the TSCH MAC. More...
 
void reset ()
 Reset the TSCH MAC.
 
void stop ()
 Stop the TSCH MAC.
 
error_t setSlotframe (uint16_t size)
 Set a slotframe. More...
 
uint16_t getSlotframeSize ()
 Get a number of slots in the slotframe.
 
uint16_t getTimeslotLength ()
 Get a timeslot length in unit of usec.
 
error_t setLink (uint16_t timeslot, uint16_t chOffset, uint8_t linkOpt, IEEE802_15_4Address nodeAddr, bool adv=false)
 Set a link. More...
 
error_t deleteLink (uint16_t timeslot)
 Delete a link.
 
error_t getLink (uint16_t timeslot, uint16_t *chOffset, uint8_t *linkOpt, IEEE802_15_4Address *addr, bool *advertising)
 Get a link.
 
void setTimeslotLength (uint16_t usec)
 Set a timeslot length. More...
 
error_t sendEnhancedBeacon (IEEE802_15_4Address addr=IEEE802_15_4Address(0xFFFF), bool includeIEs=false)
 Send an Enhanced Beacon. More...
 
error_t sendEnhancedBeaconRequest ()
 Send an Enhanced Beacon Request.
 
error_t sendKeepaliveRequest (const uint8_t *dstEui64, uint16_t dstShort)
 Send a Keep-Alive request.
 
void setTimesyncEventHandler (bool(*handler)(TSCHMac &tsch, uint16_t panId, const uint8_t *eui64, uint16_t shortId))
 Set TSCH time sync information reception event handler to handler to be called when the event is occurred at the radio device. The callee must distinguish whether it is from time source neighbors, or not, and return the result.
 
int64_t getAsn ()
 Get the ASN number.
 
void setJoinPriority (uint8_t priority)
 Set the join priority. More...
 
void setListenOnIdle (bool listen)
 Set listen on idle state.
 
bool isWorking ()
 
void onSendDone (void(*sendDoneHandler)(TSCHMac &radio, IEEE802_15_4Frame *frame))
 
void onReceive (void(*receiveHandler)(TSCHMac &radio, const IEEE802_15_4Frame *frame))
 
- Public Member Functions inherited from IEEE802_15_4Mac
error_t send (IEEE802_15_4Frame *frame)
 frame 을 전송합니다. More...
 
error_t cancelSend (IEEE802_15_4Frame *frame)
 frame 전송을 취소합니다. More...
 
virtual void onSendDone (void(*sendDoneHandler)(IEEE802_15_4Mac &, IEEE802_15_4Frame *))
 전송이 완료될 때 호출될 함수를 지정합니다. More...
 
void onReceive (void(*receiveHandler)(IEEE802_15_4Mac &, const IEEE802_15_4Frame *))
 수신이 완료될 때 호출될 함수를 지정합니다. More...
 

Static Public Member Functions

static TSCHMacCreate ()
 TSCHMac 을 생성합니다. More...
 
- Static Public Member Functions inherited from IEEE802_15_4Mac
static int32_t ConvertChToFreq2450MHz (uint16_t channelNumber)
 IEEE 802.15.4-2015 2450MHz 대역 채널번호-주파수 변환 함수 More...
 
static int32_t ConvertChToFreq917MHzSUN_FSK1 (uint16_t channelNumber)
 IEEE 802.15.4-2015 917~923.5 MHz 대역 SUN FSK operating mode #1 채널번호-주파수 변환 함수 More...
 

Public Attributes

void(* onEBRReceive )(TSCHMac &, IEEE802_15_4Address src, IEEE802_15_4Frame::EnhancedBeaconRequestInfo_t &) = nullptr
 The callback function pointer that is called when EBR reception event is occurred. More...
 
bool(* onJoin )(TSCHMac &mac, uint16_t panId) = nullptr
 The callback function pointer that is called when join event is occurred.
 
bool(* onTimesynced )(TSCHMac &mac, IEEE802_15_4Address src) = nullptr
 The callback function pointer that is called when time sync information reception event is occurred. More...
 
IEEE802_15_4Address src
 
int16_t correction
 
bool confirmed
 
- Public Attributes inherited from IEEE802_15_4Mac
bool useForceNoAckRequest = false
 전송할 프레임에 대해 강제로 Ack를 요청하지 않게 합니다. More...
 

Protected Member Functions

virtual void signalRxStarted (uint32_t)
 
void signalRxDone (uint32_t)
 
void signalTxDone (bool success, uint32_t)
 
void signalChannelBusy (uint32_t)
 
bool checkTxFrame (IEEE802_15_4Frame *frame) override
 
void handleRxFrame (IEEE802_15_4Frame *frame) override
 
virtual uint16_t eventOnTimeslot (uint16_t maxSkipSlot, uint32_t tickStart) override
 
virtual void eventOnTimeout (uint32_t tickEvent) override
 
virtual void startTimeslotTimer ()=0
 Start a timeslot timer. More...
 
virtual void stopTimeslotTimer ()=0
 Stop a timeslot timer. More...
 
virtual void correctTimeslot (int16_t timeCorrection)=0
 Correct timeslot timing. More...
 
virtual void enableTimeoutTimer (uint32_t)=0
 
virtual void disableTimeoutTimer ()=0
 
virtual void debugTxStarted ()
 
virtual void debugTxStopped ()
 
virtual void debugRxStarted ()
 
virtual void debugRxStopped ()
 
- Protected Member Functions inherited from IEEE802_15_4Mac
bool checkTxFrame (RadioPacket *frame)
 
void handleRxFrame (RadioPacket *frame)
 
IEEE802_15_4FramegetNextTxFrame ()
 
- Protected Member Functions inherited from PacketRadio
virtual void receive (RadioPacket *frame)
 
RadioPacketgetNextTxFrame ()
 
error_t enqueueTxFrame (RadioPacket *frame)
 
virtual void notifySendDone (RadioPacket *frame)
 
virtual void notifyReceive (RadioPacket *frame)
 
error_t send (RadioPacket *frame)
 frame 을 전송합니다. More...
 
error_t cancelSend (RadioPacket *frame)
 frame 전송을 취소합니다. More...
 
void onSendDone (void(*sendDoneHandler)(PacketRadio &, RadioPacket *))
 전송이 완료될 때 호출될 함수를 지정합니다. More...
 
uint8_t getNumPendingSendFrames ()
 전송 대기 중인 프레임 갯수를 구합니다. More...
 
void onReceive (void(*receiveHandler)(PacketRadio &, const RadioPacket *))
 수신이 완료될 때 호출될 함수를 지정합니다. More...
 
void setEventListener (PacketRadioEventListener &)
 전송 완료 및 수신 이벤트에 대해 PacketRadioEventListener 를 구현한 클래스로 콜백합니다. More...
 
- Protected Member Functions inherited from TSCHMacRunnable
virtual bool isOkToSleep ()=0
 

Protected Attributes

uint16_t devTxDelay = 0
 
uint8_t macTimeslotTemplateId = 0
 
uint16_t macTsCcaOffset = 1800
 
uint16_t macTsCca = 128
 
uint16_t macTsTxOffset = 2120
 
uint16_t macTsRxOffset = 1120
 
uint16_t macTsRxAckDelay = 800
 
uint16_t macTsTxAckDelay = 1000
 
uint16_t macTsRxWait = 2200
 
uint16_t macTsAckWait = 400
 
uint16_t macTsRxTx = 192
 
uint16_t macTsMaxAck = 2400
 
uint16_t macTsMaxTx = 4256
 
uint16_t macTsTimeslotLength = 10000
 
uint8_t macSlotframeHandle
 
uint16_t macSlotframeSize
 
- Protected Attributes inherited from PacketRadio
Queue< RadioPacket * > txFifo
 
Queue< RadioPacket * > rxFifo
 
Queue< RadioPacket * > txDoneFifo
 
void(* callbackSendDone )(PacketRadio &, RadioPacket *)
 
void(* callbackReceive )(PacketRadio &, const RadioPacket *)
 
PacketRadioEventListenereventListener
 

Additional Inherited Members

- Static Public Attributes inherited from IEEE802_15_4Mac
static uint16_t HoppingSequenceList2450MHz [16]
 IEEE 802.15.4-2015 2450 MHz 대역을 위한 macHoppingSequenceList. More...
 
static uint16_t HoppingSequenceList917MHzSUN_FSK1 [32]
 IEEE 802.15.4-2015 917~923.5 MHz 대역 SUN FSK operating mode #1 을 위한 macHoppingSequenceList. More...
 
- Protected Types inherited from PacketRadio
enum  { TX_FIFO_SIZE = 10, RX_FIFO_SIZE = 10, TX_DONE_FIFO_SIZE = 10 }
 

Detailed Description

IEEE 802.15.4e TSCH (Time Slotted Channel Hopping) mode MAC.

Member Function Documentation

◆ begin()

virtual void TSCHMac::begin ( PacketRadioChip chip,
uint16_t  panId,
uint16_t  nodeId,
const uint8_t *  eui64 = nullptr,
bool  isCoordinator = false 
)
virtual

TSCHMac 을 초기화합니다.

Parameters
chipTSCH MAC에서 사용할 PacketRadioChip.
panIdIEEE 802.15.4 PAN ID
nodeIdIEEE 802.15.4 2-byte short ID
eui64IEEE 802.15.4 EUI-64
isCoordinatorTSCH coordinator로 동작 여부

이 함수는 TSCHMac 을 초기화할 뿐 실제 동작은 run() 을 통해 이뤄집니다.

◆ correctTimeslot()

virtual void TSCHMac::correctTimeslot ( int16_t  timeCorrection)
protectedpure virtual

Correct timeslot timing.

Parameters
timeCorrectionTime correction value in unit of microseconds.

◆ Create()

static TSCHMac* TSCHMac::Create ( )
static

TSCHMac 을 생성합니다.

TSCHMac 은 하드웨어 의존적인 MAC 프로토콜로 하드웨어의 종류에 따라서 생성 여부 및 생성 가능 인스턴스 수가 결정됩니다.

Returns
nullptr 가 아니면 생성 성공.

◆ run()

error_t TSCHMac::run ( )

Run the TSCH MAC.

If the node is a coordinator, TSCH will be started immediately. If the node is a non-coordinator, listening for EBs to join a network will be started. ASN will be reset to 0.

◆ sendEnhancedBeacon()

error_t TSCHMac::sendEnhancedBeacon ( IEEE802_15_4Address  addr = IEEE802_15_4Address(0xFFFF),
bool  includeIEs = false 
)

Send an Enhanced Beacon.

Parameters
addrDestination node address
includeIEsInclude all TSCH IEs in the Enhanced Beacon frame if true.
Returns
  • ERROR_SUCCESS : An Enhanced Beacon is posted successfully.
  • ERROR_NOT_ENOUGH_MEMORY : Not enough memory to make a new frame.
  • ERROR_FAIL : Cannot send a beacon due to following one or more reasons.
    • This is not a TSCH coordinator.
    • This have no slotframe.

◆ setHoppingSequence()

void TSCHMac::setHoppingSequence ( uint8_t  hopSeqId,
uint16_t  hopSeqListLen,
const uint16_t *  hopSeqList,
int32_t(*)(uint16_t channel)  channelConverter 
)

채널 hopping sequence를 설정합니다.

Parameters
hopSeqIdHopping sequence ID (macHoppingSequenceId).
hopSeqListLenHopping sequence의 길이.
hopSeqListHopping sequence. IEEE802_15_4Mac::HoppingSequenceList2450MHz, IEEE802_15_4Mac::HoppingSequenceList917MHzSUN_FSK1 등을 참고하시기 바랍니다.
channelConverter16-bit 채널 번호를 Hz 단위의 주파수로 변경하기 위한 함수 포인터. 변환함수는 IEEE802_15_4Mac::ConvertChToFreq2450MHz(), IEEE802_15_4Mac::ConvertChToFreq917MHzSUN_FSK1() 등을 참고하시기 바랍니다.
Warning
channelConverter 가 nullptr 인 경우, 16-bit 채널 번호가 PacketRadioChip::setChannel() 에 그대로 적용되므로 채널 호핑이 의도한대로 동작하지 않을 수 있습니다.

◆ setJoinPriority()

void TSCHMac::setJoinPriority ( uint8_t  priority)

Set the join priority.

Warning
We recommend that only coordinators use this function.

◆ setLink()

error_t TSCHMac::setLink ( uint16_t  timeslot,
uint16_t  chOffset,
uint8_t  linkOpt,
IEEE802_15_4Address  nodeAddr,
bool  adv = false 
)

Set a link.

Parameters
slotframe
timeslot
chOffset
linkOptIEEE 802.15.4e-2012 compatible TSCH link options (macLinkOptions)
nodeAddrAddress of the node connected to this link (macNodeAddress). Currently, only 16-bit address is supported.
adv(Coordinators only) Whether the link is for transmitting unsolicited EBs, or not.

◆ setSlotframe()

error_t TSCHMac::setSlotframe ( uint16_t  size)

Set a slotframe.

Warning
We recommend that only coordinators use this function. Non-coordinator devices may configure their slotframes by receiving EBs sent by coordinators. Coordinators must call this function after stop(). The modified slotframe will be applied after run().

◆ setTimeslotLength()

void TSCHMac::setTimeslotLength ( uint16_t  usec)

Set a timeslot length.

Warning
We recommend that only coordinators use this function. Non-coordinator devices may configure their timeslot length by receiving EBs sent by coordinators.Coordinators must call this function after stop(). The modified slotframe will be applied after run().

◆ startTimeslotTimer()

virtual void TSCHMac::startTimeslotTimer ( )
protectedpure virtual

Start a timeslot timer.

The timeslot timer is used to notify start of a timeslot to TSCH MAC layer.

The platform that supports TSCH MAC should implement this function to start the timeslot timer to call tsch_event_on_timeslot() when the timer is expired.

◆ stopTimeslotTimer()

virtual void TSCHMac::stopTimeslotTimer ( )
protectedpure virtual

Stop a timeslot timer.

The platform that supports TSCH MAC should implement this function to stop the timeslot timer.

Member Data Documentation

◆ onEBRReceive

void(* TSCHMac::onEBRReceive) (TSCHMac &, IEEE802_15_4Address src, IEEE802_15_4Frame::EnhancedBeaconRequestInfo_t &) = nullptr

The callback function pointer that is called when EBR reception event is occurred.

On this callback, the Enhanced Beacon can be sent as a response by calling sendEnhancedBeacon().

◆ onTimesynced

bool(* TSCHMac::onTimesynced) (TSCHMac &mac, IEEE802_15_4Address src) = nullptr

The callback function pointer that is called when time sync information reception event is occurred.

On this callback, a boolean value whether it's ok to sync with the src or not should be returned.


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