127 typedef void (*DataPollTimeoutHandler)(
Receiver &aReceiver);
137 Receiver(ReceiveFrameHandler aReceiveFrameHandler, DataPollTimeoutHandler aPollTimeoutHandler,
void *aContext):
139 mReceiveFrameHandler(aReceiveFrameHandler),
140 mPollTimeoutHandler(aPollTimeoutHandler),
145 void HandleReceivedFrame(
Frame &aFrame) { mReceiveFrameHandler(*
this, aFrame); }
147 void HandleDataPollTimeout(
void) {
148 if (mPollTimeoutHandler != NULL) {
149 mPollTimeoutHandler(*
this);
153 ReceiveFrameHandler mReceiveFrameHandler;
154 DataPollTimeoutHandler mPollTimeoutHandler;
194 Sender(FrameRequestHandler aFrameRequestHandler, SentFrameHandler aSentFrameHandler,
void *aContext):
196 mFrameRequestHandler(aFrameRequestHandler),
197 mSentFrameHandler(aSentFrameHandler),
202 otError HandleFrameRequest(
Frame &aFrame) {
return mFrameRequestHandler(*
this, aFrame); }
203 void HandleSentFrame(
Frame &aFrame,
otError aError) { mSentFrameHandler(*
this, aFrame, aError); }
205 FrameRequestHandler mFrameRequestHandler;
206 SentFrameHandler mSentFrameHandler;
232 typedef void (*ActiveScanHandler)(
void *aContext,
Frame *aBeaconFrame);
243 otError ActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, ActiveScanHandler aHandler,
void *aContext);
281 otError EnergyScan(uint32_t aScanChannels, uint16_t aScanDuration, EnergyScanHandler aHandler,
void *aContext);
289 void EnergyScanDone(int8_t aEnergyScanMaxRssi);
321 void SetRxOnWhenIdle(
bool aRxOnWhenIdle);
351 void GenerateExtAddress(
ExtAddress *aExtAddress);
367 void SetExtAddress(
const ExtAddress &aExtAddress);
403 otError SetChannel(uint8_t aChannel);
437 otError SetNetworkName(
const char *aNetworkName);
455 otError SetPanId(uint16_t aPanId);
473 otError SetExtendedPanId(
const uint8_t *aExtPanId);
475 #if OPENTHREAD_ENABLE_MAC_FILTER 482 Filter &GetFilter(
void) {
return mFilter; }
483 #endif // OPENTHREAD_ENABLE_MAC_FILTER 519 bool IsActiveScanInProgress(
void);
525 bool IsEnergyScanInProgress(
void);
535 bool IsInTransmitState(
void);
554 bool IsPromiscuous(
void);
564 void SetPromiscuous(
bool aPromiscuous);
578 void ResetCounters(
void);
580 #if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_WHEN_JOINABLE 588 bool IsBeaconJoinable(
void);
589 #endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_WHEN_JOINABLE 614 bool RadioSupportsCsmaBackoff(
void);
623 bool RadioSupportsRetries(
void);
628 kInvalidRssiValue = 127
634 kOperationActiveScan,
635 kOperationEnergyScan,
636 kOperationTransmitBeacon,
637 kOperationTransmitData,
638 kOperationWaitingForData,
641 void GenerateNonce(
const ExtAddress &aAddress, uint32_t aFrameCounter, uint8_t aSecurityLevel, uint8_t *aNonce);
642 void ProcessTransmitSecurity(
Frame &aFrame);
644 void UpdateIdleMode(
void);
645 void StartOperation(Operation aOperation);
646 void FinishOperation(
void);
647 void SentFrame(
otError aError);
648 void SendBeaconRequest(
Frame &aFrame);
649 void SendBeacon(
Frame &aFrame);
650 void StartBackoff(
void);
651 void StartEnergyScan(
void);
654 static void HandleMacTimer(
Timer &aTimer);
655 void HandleMacTimer(
void);
656 static void HandleBeginTransmit(
Timer &aTimer);
657 void HandleBeginTransmit(
void);
658 static void HandleReceiveTimer(
Timer &aTimer);
659 void HandleReceiveTimer(
void);
660 static void HandleEnergyScanSampleRssi(
Tasklet &aTasklet);
661 void HandleEnergyScanSampleRssi(
void);
663 void StartCsmaBackoff(
void);
664 otError Scan(Operation aScanOperation, uint32_t aScanChannels, uint16_t aScanDuration,
void *aContext);
667 otError RadioReceive(uint8_t aChannel);
670 static Mac &GetOwner(
const Context &aContext);
672 static const char *OperationToString(Operation aOperation);
674 Operation mOperation;
676 bool mPendingActiveScan : 1;
677 bool mPendingEnergyScan : 1;
678 bool mPendingTransmitBeacon : 1;
679 bool mPendingTransmitData : 1;
680 bool mPendingWaitingForData : 1;
681 bool mRxOnWhenIdle : 1;
682 bool mBeaconsEnabled : 1;
683 #if OPENTHREAD_CONFIG_STAY_AWAKE_BETWEEN_FRAGMENTS 684 bool mDelaySleep : 1;
688 #if OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER 689 TimerMicro mBackoffTimer;
699 int8_t mMaxTransmitPower;
704 Sender *mSendHead, *mSendTail;
705 Receiver *mReceiveHead, *mReceiveTail;
707 uint8_t mBeaconSequence;
708 uint8_t mDataSequence;
709 uint8_t mCsmaAttempts;
710 uint8_t mTransmitAttempts;
712 uint32_t mScanChannels;
713 uint16_t mScanDuration;
714 uint8_t mScanChannel;
715 int8_t mEnergyScanCurrentMaxRssi;
719 ActiveScanHandler mActiveScanHandler;
720 EnergyScanHandler mEnergyScanHandler;
722 Tasklet mEnergyScanSampleRssiTask;
725 void *mPcapCallbackContext;
727 #if OPENTHREAD_ENABLE_MAC_FILTER 729 #endif // OPENTHREAD_ENABLE_MAC_FILTER 734 uint32_t mKeyIdMode2FrameCounter;
This struct represents an energy scan result.
Definition: types.h:542
#define OPENTHREAD_CONFIG_MAX_TX_ATTEMPTS_INDIRECT_PER_POLL
Maximum number of MAC layer transmit attempts for an outbound indirect frame (to a sleepy child) afte...
Definition: openthread-core-default-config.h:147
Minimum backoff (milliseconds).
Definition: mac.hpp:78
void SetBeaconEnabled(bool aEnabled)
This method enables/disables IEEE 802.15.4 Beacon transmissions.
Definition: mac.hpp:305
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
Timeout for waiting on an ACK (milliseconds).
Definition: mac.hpp:80
Maximum number of MAC layer tx attempts for an outbound indirect frame (for a sleepy child) after rec...
Definition: mac.hpp:99
This class implements IEEE 802.15.4 MAC frame generation and parsing.
Definition: mac_frame.hpp:177
This structure represents an IEEE 802.15.4 Short or Extended Address.
Definition: mac_frame.hpp:147
const ExtAddress * GetExtAddress(void) const
This method returns a pointer to the IEEE 802.15.4 Extended Address.
Definition: mac.hpp:359
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
Get the radio receive sensitivity value.
This class implements a MAC receiver client.
Definition: mac.hpp:106
This class implements MLE functionality required by the Thread Router and Leader roles.
Definition: mle_router_ftd.hpp:76
void(* otLinkPcapCallback)(const otRadioFrame *aFrame, void *aContext)
This function pointer is called when an IEEE 802.15.4 frame is received.
Definition: link.h:568
All channels.
Definition: mac.hpp:85
This file includes definitions for locator class for OpenThread objects.
uint16_t GetPanId(void) const
This method returns the IEEE 802.15.4 PAN ID.
Definition: mac.hpp:445
This class implements MLE functionality required by the Thread EndDevices, Router, and Leader roles.
Definition: mle.hpp:462
This file defines the radio interface for OpenThread.
ShortAddress GetShortAddress(void) const
This method returns the IEEE 802.15.4 Short Address.
Definition: mac.hpp:375
This class implements a MAC sender client.
Definition: mac.hpp:162
This class implements Mac Counters TLV generation and parsing.
Definition: network_diagnostic_tlvs.hpp:894
Default interval between channels (milliseconds).
Definition: mac.hpp:86
This class is used to represent a tasklet.
Definition: tasklet.hpp:64
This file includes definitions for maintaining Thread network topologies.
This structure represents an IEEE 802.15.4 radio frame.
Definition: radio.h:99
This file includes definitions for maintaining a pointer to arbitrary context information.
This class represents a Thread neighbor.
Definition: topology.hpp:53
This class implements a timer.
Definition: timer.hpp:69
This class implements the millisecond timer.
Definition: timer.hpp:145
Sender(FrameRequestHandler aFrameRequestHandler, SentFrameHandler aSentFrameHandler, void *aContext)
This constructor creates a MAC sender client.
Definition: mac.hpp:194
This file includes definitions for IEEE 802.15.4 frame filtering based on MAC address.
void SetMaxTransmitPower(int8_t aPower)
This method sets the maximum transmit power in dBm.
Definition: mac.hpp:419
int8_t GetNoiseFloor(void)
This method returns the noise floor value (currently use the radio receive sensitivity value)...
Definition: mac.hpp:605
Timeout for receiving Data Frame (milliseconds).
Definition: mac.hpp:81
const uint8_t * GetExtendedPanId(void) const
This method returns the IEEE 802.15.4 Extended PAN ID.
Definition: mac.hpp:463
This structure represents an IEEE 802.15.4 Extended Address.
Definition: mac_frame.hpp:84
This file includes definitions for generating and processing IEEE 802.15.4 MAC frames.
bool IsBeaconEnabled(void) const
This method indicates whether or not IEEE 802.15.4 Beacon transmissions are enabled.
Definition: mac.hpp:297
uint8_t GetChannel(void) const
This method returns the IEEE 802.15.4 Channel.
Definition: mac.hpp:393
This class implements definitions for maintaining a pointer to arbitrary context information.
Definition: context.hpp:61
This file includes definitions for tasklets and the tasklet scheduler.
This file includes definitions for generating and processing MLE TLVs.
otMacCounters & GetCounters(void)
This method returns the MAC counter.
Definition: mac.hpp:597
int8_t GetMaxTransmitPower(void) const
This method returns the maximum transmit power in dBm.
Definition: mac.hpp:411
This struct represents a received IEEE 802.15.4 Beacon.
Definition: types.h:522
Receiver(ReceiveFrameHandler aReceiveFrameHandler, DataPollTimeoutHandler aPollTimeoutHandler, void *aContext)
This constructor creates a MAC receiver client.
Definition: mac.hpp:137
This class implements the IEEE 802.15.4 MAC.
Definition: mac.hpp:214
This class implements locator for otInstance object.
Definition: locator.hpp:63
Maximum number of MAC layer tx attempts for an outbound direct frame.
Definition: mac.hpp:92
const char * GetNetworkName(void) const
This method returns the IEEE 802.15.4 Network Name.
Definition: mac.hpp:427
This file includes definitions for the multiplexed timer service.
#define OPENTHREAD_CONFIG_MAX_TX_ATTEMPTS_DIRECT
Maximum number of MAC layer transmit attempts for an outbound direct frame.
Definition: openthread-core-default-config.h:136
macMaxCSMABackoffs (IEEE 802.15.4-2006)
Definition: mac.hpp:75
macMinBE (IEEE 802.15.4-2006)
Definition: mac.hpp:73
This structure represents a Network Name.
Definition: types.h:314
This structure represents the MAC layer counters.
Definition: types.h:1011
Max sleep delay when frame is pending (milliseconds).
Definition: mac.hpp:82
#define OT_CHANNEL_ALL
All channels.
Definition: types.h:504
otPanId PanId
This type represents the IEEE 802.15.4 PAN ID.
Definition: mac_frame.hpp:72
bool GetRxOnWhenIdle(void) const
This method indicates whether or not rx-on-when-idle is enabled.
Definition: mac.hpp:313
Size of IEEE 802.15.4 Nonce (bytes).
Definition: mac.hpp:83
Number of symbols (IEEE 802.15.4-2006)
Definition: mac.hpp:76
This structure represents an Extended PAN ID.
Definition: types.h:325
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
otShortAddress ShortAddress
This type represents the IEEE 802.15.4 Short Address.
Definition: mac_frame.hpp:78
This file includes compile-time configuration constants for OpenThread.
macMaxBE (IEEE 802.15.4-2006)
Definition: mac.hpp:74
This file includes definitions for Thread security material generation.