0.01.00
radio.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
36 #ifndef RADIO_H_
37 #define RADIO_H_
38 
39 #include <stdint.h>
40 
41 #include <openthread/types.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
67 enum
68 {
74  OT_RADIO_BIT_RATE = 250000,
75 
77  OT_RADIO_SYMBOL_TIME = ((OT_RADIO_BITS_PER_OCTET / OT_RADIO_SYMBOLS_PER_OCTET) * 1000000) / OT_RADIO_BIT_RATE,
78 
81 };
82 
87 typedef enum otRadioCaps
88 {
94 } otRadioCaps;
95 
99 typedef struct otRadioFrame
100 {
101  uint8_t *mPsdu;
102  uint8_t mLength;
103  uint8_t mChannel;
104  int8_t mPower;
105  uint8_t mLqi;
106  uint8_t mMaxTxAttempts;
107  bool mSecurityValid: 1;
108  bool mDidTX: 1;
109  bool mIsARetx: 1;
110 
116  uint32_t mMsec;
117 
123  uint16_t mUsec;
124 } otRadioFrame;
125 
130 typedef enum otRadioState
131 {
132  OT_RADIO_STATE_DISABLED = 0,
133  OT_RADIO_STATE_SLEEP = 1,
134  OT_RADIO_STATE_RECEIVE = 2,
135  OT_RADIO_STATE_TRANSMIT = 3,
136 } otRadioState;
137 
173 void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64);
174 
182 void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId);
183 
192 void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress);
193 
201 void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress);
202 
230 
240 
249 
258 bool otPlatRadioIsEnabled(otInstance *aInstance);
259 
271 
282 otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel);
283 
301 void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable);
302 
312 otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress);
313 
323 otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress);
324 
334 otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress);
335 
345 otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress);
346 
354 
362 
373 extern void otPlatRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
374 
387 
405 
416 extern void otPlatRadioTxStarted(otInstance *aInstance, otRadioFrame *aFrame);
417 
431 extern void otPlatRadioTxDone(otInstance *aInstance, otRadioFrame *aFrame, otRadioFrame *aAckFrame,
432  otError aError);
433 
441 int8_t otPlatRadioGetRssi(otInstance *aInstance);
442 
451 
459 void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower);
460 
469 bool otPlatRadioGetPromiscuous(otInstance *aInstance);
470 
477 void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable);
478 
489 extern void otPlatDiagRadioTransmitDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
490 
501 extern void otPlatDiagRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
502 
513 otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration);
514 
522 extern void otPlatRadioEnergyScanDone(otInstance *aInstance, int8_t aEnergyScanMaxRssi);
523 
532 
543 #ifdef __cplusplus
544 } // end of extern "C"
545 #endif
546 
547 #endif // RADIO_H_
struct otRadioFrame otRadioFrame
This structure represents an IEEE 802.15.4 radio frame.
Invalid or unknown RSSI value.
Definition: radio.h:80
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
Enable or disable promiscuous mode.
This file defines the types and structures used in the OpenThread library API.
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
Clear all the extended/long addresses from source address match table.
None.
Definition: radio.h:89
int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
Get the radio receive sensitivity value.
void otPlatRadioTxStarted(otInstance *aInstance, otRadioFrame *aFrame)
The radio driver calls this method to notify OpenThread that the transmission has started...
Definition: mac.cpp:936
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
Get the radio capabilities.
otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
Transitioning the radio from Sleep to Receive.
void otPlatDiagRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
The radio driver calls this method to notify OpenThread diagnostics module of a received frame...
Definition: diag_process.cpp:415
otError otPlatRadioDisable(otInstance *aInstance)
Disable the radio.
int8_t otPlatRadioGetRssi(otInstance *aInstance)
Get the most recent RSSI measurement.
otRadioFrame * otPlatRadioGetTransmitBuffer(otInstance *aInstance)
The radio transitions from Transmit to Receive.
uint8_t * mPsdu
The PSDU.
Definition: radio.h:101
uint8_t mLength
Length of the PSDU.
Definition: radio.h:102
2.4 GHz IEEE 802.15.4-2006
Definition: radio.h:73
otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
This method begins the transmit sequence on the radio.
This structure represents an IEEE 802.15.4 radio frame.
Definition: radio.h:99
Radio supports Energy Scans.
Definition: radio.h:91
2.4 GHz IEEE 802.15.4-2006
Definition: radio.h:72
bool mSecurityValid
Security Enabled flag is set and frame passes security checks.
Definition: radio.h:107
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
Set the radio Tx power used for auto-generated frames.
LQI measurement not supported.
Definition: radio.h:79
otRadioState otPlatRadioGetState(otInstance *aInstance)
Get current state of the radio.
2.4 GHz IEEE 802.15.4-2006
Definition: radio.h:71
void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
Set the PAN ID for address filtering.
bool mIsARetx
Set to true if this frame is a retransmission. Should be ignored by radio driver. ...
Definition: radio.h:109
Radio supports AckTime event.
Definition: radio.h:90
2.4 GHz IEEE 802.15.4 (kilobits per second)
Definition: radio.h:74
Radio supports transmission retry logic with collision avoidance (CSMA).
Definition: radio.h:92
void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress)
Set the Short Address for address filtering.
uint8_t mLqi
Link Quality Indicator for received frames.
Definition: radio.h:105
otRadioState
This structure represents the state of a radio.
Definition: radio.h:130
uint8_t mChannel
Channel used to transmit/receive the frame.
Definition: radio.h:103
otRadioCaps
This enum represents radio capabilities.
Definition: radio.h:87
void otPlatRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
The radio driver calls this method to notify OpenThread of a received frame.
Definition: mac.cpp:1502
otError otPlatRadioSleep(otInstance *aInstance)
Transition the radio from Receive to Sleep.
2.4 GHz IEEE 802.15.4-2006
Definition: radio.h:70
bool otPlatRadioIsEnabled(otInstance *aInstance)
Check whether radio is enabled or not.
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
Clear all short addresses from the source address match table.
uint8_t mMaxTxAttempts
Max number of transmit attempts for an outbound frame.
Definition: radio.h:106
otError otPlatRadioEnable(otInstance *aInstance)
Enable the radio.
void otPlatRadioEnergyScanDone(otInstance *aInstance, int8_t aEnergyScanMaxRssi)
The radio driver calls this method to notify OpenThread that the energy scan is complete.
Definition: mac.cpp:336
uint16_t mUsec
The timestamp when the frame was received (microseconds, the offset to mMsec).
Definition: radio.h:123
This type represents the IEEE 802.15.4 Extended Address.
Definition: types.h:402
uint32_t mMsec
The timestamp when the frame was received (milliseconds).
Definition: radio.h:116
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
Remove a short address from the source address match table.
void otPlatRadioTxDone(otInstance *aInstance, otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError)
The radio driver calls this function to notify OpenThread that the transmit operation has completed...
Definition: mac.cpp:956
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
Add a short address to the source address match table.
void otPlatDiagRadioTransmitDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
The radio driver calls this method to notify OpenThread diagnostics module that the transmission has ...
Definition: diag_process.cpp:408
otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration)
This method begins the energy scan sequence on the radio.
int8_t mPower
Transmit/receive power in dBm.
Definition: radio.h:104
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
Add an extended address to the source address match table.
bool mDidTX
Set to true if this frame sent from the radio. Ignored by radio driver.
Definition: radio.h:108
Radio supports CSMA backoff for frame transmission (but no retry).
Definition: radio.h:93
Number of bits per octet.
Definition: radio.h:76
aMaxPHYPacketSize (IEEE 802.15.4-2006)
Definition: radio.h:69
void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
Enable/Disable source address match feature.
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
Remove an extended address from the source address match table.
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
Get the factory-assigned IEEE EUI-64 for this interface.
void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress)
Set the Extended Address for address filtering.
bool otPlatRadioGetPromiscuous(otInstance *aInstance)
Get the status of promiscuous mode.