1*cfb92d14SAndroid Build Coastguard Worker /* 2*cfb92d14SAndroid Build Coastguard Worker * Copyright (c) 2018, The OpenThread Authors. 3*cfb92d14SAndroid Build Coastguard Worker * All rights reserved. 4*cfb92d14SAndroid Build Coastguard Worker * 5*cfb92d14SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without 6*cfb92d14SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions are met: 7*cfb92d14SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright 8*cfb92d14SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer. 9*cfb92d14SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright 10*cfb92d14SAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the 11*cfb92d14SAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution. 12*cfb92d14SAndroid Build Coastguard Worker * 3. Neither the name of the copyright holder nor the 13*cfb92d14SAndroid Build Coastguard Worker * names of its contributors may be used to endorse or promote products 14*cfb92d14SAndroid Build Coastguard Worker * derived from this software without specific prior written permission. 15*cfb92d14SAndroid Build Coastguard Worker * 16*cfb92d14SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17*cfb92d14SAndroid Build Coastguard Worker * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*cfb92d14SAndroid Build Coastguard Worker * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*cfb92d14SAndroid Build Coastguard Worker * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20*cfb92d14SAndroid Build Coastguard Worker * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*cfb92d14SAndroid Build Coastguard Worker * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*cfb92d14SAndroid Build Coastguard Worker * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*cfb92d14SAndroid Build Coastguard Worker * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*cfb92d14SAndroid Build Coastguard Worker * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*cfb92d14SAndroid Build Coastguard Worker * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*cfb92d14SAndroid Build Coastguard Worker * POSSIBILITY OF SUCH DAMAGE. 27*cfb92d14SAndroid Build Coastguard Worker */ 28*cfb92d14SAndroid Build Coastguard Worker 29*cfb92d14SAndroid Build Coastguard Worker /** 30*cfb92d14SAndroid Build Coastguard Worker * @file 31*cfb92d14SAndroid Build Coastguard Worker * This file includes definitions for the spinel based radio transceiver. 32*cfb92d14SAndroid Build Coastguard Worker */ 33*cfb92d14SAndroid Build Coastguard Worker 34*cfb92d14SAndroid Build Coastguard Worker #ifndef RADIO_SPINEL_HPP_ 35*cfb92d14SAndroid Build Coastguard Worker #define RADIO_SPINEL_HPP_ 36*cfb92d14SAndroid Build Coastguard Worker 37*cfb92d14SAndroid Build Coastguard Worker #include <openthread/platform/diag.h> 38*cfb92d14SAndroid Build Coastguard Worker #include <openthread/platform/radio.h> 39*cfb92d14SAndroid Build Coastguard Worker 40*cfb92d14SAndroid Build Coastguard Worker #include "openthread-spinel-config.h" 41*cfb92d14SAndroid Build Coastguard Worker #include "core/radio/max_power_table.hpp" 42*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/logger.hpp" 43*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/radio_spinel_metrics.h" 44*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel.h" 45*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel_driver.hpp" 46*cfb92d14SAndroid Build Coastguard Worker #include "lib/spinel/spinel_interface.hpp" 47*cfb92d14SAndroid Build Coastguard Worker #include "ncp/ncp_config.h" 48*cfb92d14SAndroid Build Coastguard Worker 49*cfb92d14SAndroid Build Coastguard Worker namespace ot { 50*cfb92d14SAndroid Build Coastguard Worker namespace Spinel { 51*cfb92d14SAndroid Build Coastguard Worker 52*cfb92d14SAndroid Build Coastguard Worker struct RadioSpinelCallbacks 53*cfb92d14SAndroid Build Coastguard Worker { 54*cfb92d14SAndroid Build Coastguard Worker /** 55*cfb92d14SAndroid Build Coastguard Worker * This callback notifies user of `RadioSpinel` of a received frame. 56*cfb92d14SAndroid Build Coastguard Worker * 57*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 58*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrame A pointer to the received frame or nullptr if the receive operation failed. 59*cfb92d14SAndroid Build Coastguard Worker * @param[in] aError kErrorNone when successfully received a frame, 60*cfb92d14SAndroid Build Coastguard Worker * kErrorAbort when reception was aborted and a frame was not received, 61*cfb92d14SAndroid Build Coastguard Worker * kErrorNoBufs when a frame could not be received due to lack of rx buffer space. 62*cfb92d14SAndroid Build Coastguard Worker * 63*cfb92d14SAndroid Build Coastguard Worker */ 64*cfb92d14SAndroid Build Coastguard Worker void (*mReceiveDone)(otInstance *aInstance, otRadioFrame *aFrame, Error aError); 65*cfb92d14SAndroid Build Coastguard Worker 66*cfb92d14SAndroid Build Coastguard Worker /** 67*cfb92d14SAndroid Build Coastguard Worker * The callback notifies user of `RadioSpinel` that the transmit operation has completed, providing, if 68*cfb92d14SAndroid Build Coastguard Worker * applicable, the received ACK frame. 69*cfb92d14SAndroid Build Coastguard Worker * 70*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 71*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrame The transmitted frame. 72*cfb92d14SAndroid Build Coastguard Worker * @param[in] aAckFrame A pointer to the ACK frame, nullptr if no ACK was received. 73*cfb92d14SAndroid Build Coastguard Worker * @param[in] aError kErrorNone when the frame was transmitted, 74*cfb92d14SAndroid Build Coastguard Worker * kErrorNoAck when the frame was transmitted but no ACK was received, 75*cfb92d14SAndroid Build Coastguard Worker * kErrorChannelAccessFailure tx failed due to activity on the channel, 76*cfb92d14SAndroid Build Coastguard Worker * kErrorAbort when transmission was aborted for other reasons. 77*cfb92d14SAndroid Build Coastguard Worker * 78*cfb92d14SAndroid Build Coastguard Worker */ 79*cfb92d14SAndroid Build Coastguard Worker void (*mTransmitDone)(otInstance *aInstance, otRadioFrame *aFrame, otRadioFrame *aAckFrame, Error aError); 80*cfb92d14SAndroid Build Coastguard Worker 81*cfb92d14SAndroid Build Coastguard Worker /** 82*cfb92d14SAndroid Build Coastguard Worker * This callback notifies user of `RadioSpinel` that energy scan is complete. 83*cfb92d14SAndroid Build Coastguard Worker * 84*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 85*cfb92d14SAndroid Build Coastguard Worker * @param[in] aMaxRssi Maximum RSSI seen on the channel, or `SubMac::kInvalidRssiValue` if failed. 86*cfb92d14SAndroid Build Coastguard Worker * 87*cfb92d14SAndroid Build Coastguard Worker */ 88*cfb92d14SAndroid Build Coastguard Worker void (*mEnergyScanDone)(otInstance *aInstance, int8_t aMaxRssi); 89*cfb92d14SAndroid Build Coastguard Worker 90*cfb92d14SAndroid Build Coastguard Worker /** 91*cfb92d14SAndroid Build Coastguard Worker * This callback notifies user of `RadioSpinel` that the bus latency has been changed. 92*cfb92d14SAndroid Build Coastguard Worker * 93*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 94*cfb92d14SAndroid Build Coastguard Worker * 95*cfb92d14SAndroid Build Coastguard Worker */ 96*cfb92d14SAndroid Build Coastguard Worker void (*mBusLatencyChanged)(otInstance *aInstance); 97*cfb92d14SAndroid Build Coastguard Worker 98*cfb92d14SAndroid Build Coastguard Worker /** 99*cfb92d14SAndroid Build Coastguard Worker * This callback notifies user of `RadioSpinel` that the transmission has started. 100*cfb92d14SAndroid Build Coastguard Worker * 101*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance A pointer to the OpenThread instance structure. 102*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrame A pointer to the frame that is being transmitted. 103*cfb92d14SAndroid Build Coastguard Worker * 104*cfb92d14SAndroid Build Coastguard Worker */ 105*cfb92d14SAndroid Build Coastguard Worker void (*mTxStarted)(otInstance *aInstance, otRadioFrame *aFrame); 106*cfb92d14SAndroid Build Coastguard Worker 107*cfb92d14SAndroid Build Coastguard Worker /** 108*cfb92d14SAndroid Build Coastguard Worker * This callback notifies user of `RadioSpinel` that the radio interface switchover has completed. 109*cfb92d14SAndroid Build Coastguard Worker * 110*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance A pointer to the OpenThread instance structure. 111*cfb92d14SAndroid Build Coastguard Worker * @param[in] aSuccess A value indicating if the switchover was successful or not. 112*cfb92d14SAndroid Build Coastguard Worker * 113*cfb92d14SAndroid Build Coastguard Worker */ 114*cfb92d14SAndroid Build Coastguard Worker void (*mSwitchoverDone)(otInstance *aInstance, bool aSuccess); 115*cfb92d14SAndroid Build Coastguard Worker 116*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 117*cfb92d14SAndroid Build Coastguard Worker /** 118*cfb92d14SAndroid Build Coastguard Worker * This callback notifies diagnostics module using `RadioSpinel` of a received frame. 119*cfb92d14SAndroid Build Coastguard Worker * 120*cfb92d14SAndroid Build Coastguard Worker * This callback is used when diagnostics is enabled. 121*cfb92d14SAndroid Build Coastguard Worker * 122*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 123*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. 124*cfb92d14SAndroid Build Coastguard Worker * @param[in] aError OT_ERROR_NONE when successfully received a frame, 125*cfb92d14SAndroid Build Coastguard Worker * OT_ERROR_ABORT when reception was aborted and a frame was not received, 126*cfb92d14SAndroid Build Coastguard Worker * OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. 127*cfb92d14SAndroid Build Coastguard Worker * 128*cfb92d14SAndroid Build Coastguard Worker */ 129*cfb92d14SAndroid Build Coastguard Worker void (*mDiagReceiveDone)(otInstance *aInstance, otRadioFrame *aFrame, Error aError); 130*cfb92d14SAndroid Build Coastguard Worker 131*cfb92d14SAndroid Build Coastguard Worker /** 132*cfb92d14SAndroid Build Coastguard Worker * This callback notifies diagnostics module using `RadioSpinel` that the transmission has completed. 133*cfb92d14SAndroid Build Coastguard Worker * 134*cfb92d14SAndroid Build Coastguard Worker * This callback is used when diagnostics is enabled. 135*cfb92d14SAndroid Build Coastguard Worker * 136*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 137*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrame A pointer to the frame that was transmitted. 138*cfb92d14SAndroid Build Coastguard Worker * @param[in] aError OT_ERROR_NONE when the frame was transmitted, 139*cfb92d14SAndroid Build Coastguard Worker * OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the 140*cfb92d14SAndroid Build Coastguard Worker * channel, OT_ERROR_ABORT when transmission was aborted for other reasons. 141*cfb92d14SAndroid Build Coastguard Worker * 142*cfb92d14SAndroid Build Coastguard Worker */ 143*cfb92d14SAndroid Build Coastguard Worker void (*mDiagTransmitDone)(otInstance *aInstance, otRadioFrame *aFrame, Error aError); 144*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_CONFIG_DIAG_ENABLE 145*cfb92d14SAndroid Build Coastguard Worker }; 146*cfb92d14SAndroid Build Coastguard Worker 147*cfb92d14SAndroid Build Coastguard Worker /** 148*cfb92d14SAndroid Build Coastguard Worker * The class for providing a OpenThread radio interface by talking with a radio-only 149*cfb92d14SAndroid Build Coastguard Worker * co-processor(RCP). 150*cfb92d14SAndroid Build Coastguard Worker * 151*cfb92d14SAndroid Build Coastguard Worker */ 152*cfb92d14SAndroid Build Coastguard Worker class RadioSpinel : private Logger 153*cfb92d14SAndroid Build Coastguard Worker { 154*cfb92d14SAndroid Build Coastguard Worker public: 155*cfb92d14SAndroid Build Coastguard Worker /** 156*cfb92d14SAndroid Build Coastguard Worker * Initializes the spinel based OpenThread transceiver. 157*cfb92d14SAndroid Build Coastguard Worker * 158*cfb92d14SAndroid Build Coastguard Worker */ 159*cfb92d14SAndroid Build Coastguard Worker RadioSpinel(void); 160*cfb92d14SAndroid Build Coastguard Worker 161*cfb92d14SAndroid Build Coastguard Worker /** 162*cfb92d14SAndroid Build Coastguard Worker * Deinitializes the spinel based OpenThread transceiver. 163*cfb92d14SAndroid Build Coastguard Worker * 164*cfb92d14SAndroid Build Coastguard Worker */ ~RadioSpinel(void)165*cfb92d14SAndroid Build Coastguard Worker ~RadioSpinel(void) { Deinit(); } 166*cfb92d14SAndroid Build Coastguard Worker 167*cfb92d14SAndroid Build Coastguard Worker /** 168*cfb92d14SAndroid Build Coastguard Worker * Initialize this radio transceiver. 169*cfb92d14SAndroid Build Coastguard Worker * 170*cfb92d14SAndroid Build Coastguard Worker * @param[in] aSkipRcpCompatibilityCheck TRUE to skip RCP compatibility check, FALSE to perform the check. 171*cfb92d14SAndroid Build Coastguard Worker * @param[in] aSoftwareReset When doing RCP recovery, TRUE to try software reset first, FALSE to 172*cfb92d14SAndroid Build Coastguard Worker * directly do a hardware reset. 173*cfb92d14SAndroid Build Coastguard Worker * @param[in] aSpinelDriver A pointer to the spinel driver instance that this object depends on. 174*cfb92d14SAndroid Build Coastguard Worker * @param[in] aRequiredRadioCaps The required radio capabilities. RadioSpinel will check if RCP has 175*cfb92d14SAndroid Build Coastguard Worker * the required capabilities during initialization. 176*cfb92d14SAndroid Build Coastguard Worker * @param[in] aEnableRcpTimeSync TRUE to enable RCP time sync, FALSE to not enable. 177*cfb92d14SAndroid Build Coastguard Worker * 178*cfb92d14SAndroid Build Coastguard Worker */ 179*cfb92d14SAndroid Build Coastguard Worker void Init(bool aSkipRcpCompatibilityCheck, 180*cfb92d14SAndroid Build Coastguard Worker bool aSoftwareReset, 181*cfb92d14SAndroid Build Coastguard Worker SpinelDriver *aSpinelDriver, 182*cfb92d14SAndroid Build Coastguard Worker otRadioCaps aRequiredRadioCaps, 183*cfb92d14SAndroid Build Coastguard Worker bool aEnableRcpTimeSync); 184*cfb92d14SAndroid Build Coastguard Worker 185*cfb92d14SAndroid Build Coastguard Worker /** 186*cfb92d14SAndroid Build Coastguard Worker * This method sets the notification callbacks. 187*cfb92d14SAndroid Build Coastguard Worker * 188*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCallbacks A pointer to structure with notification callbacks. 189*cfb92d14SAndroid Build Coastguard Worker * 190*cfb92d14SAndroid Build Coastguard Worker */ 191*cfb92d14SAndroid Build Coastguard Worker void SetCallbacks(const struct RadioSpinelCallbacks &aCallbacks); 192*cfb92d14SAndroid Build Coastguard Worker 193*cfb92d14SAndroid Build Coastguard Worker /** 194*cfb92d14SAndroid Build Coastguard Worker * Deinitialize this radio transceiver. 195*cfb92d14SAndroid Build Coastguard Worker * 196*cfb92d14SAndroid Build Coastguard Worker */ 197*cfb92d14SAndroid Build Coastguard Worker void Deinit(void); 198*cfb92d14SAndroid Build Coastguard Worker 199*cfb92d14SAndroid Build Coastguard Worker /** 200*cfb92d14SAndroid Build Coastguard Worker * Gets the status of promiscuous mode. 201*cfb92d14SAndroid Build Coastguard Worker * 202*cfb92d14SAndroid Build Coastguard Worker * @retval true Promiscuous mode is enabled. 203*cfb92d14SAndroid Build Coastguard Worker * @retval false Promiscuous mode is disabled. 204*cfb92d14SAndroid Build Coastguard Worker * 205*cfb92d14SAndroid Build Coastguard Worker */ IsPromiscuous(void) const206*cfb92d14SAndroid Build Coastguard Worker bool IsPromiscuous(void) const { return mIsPromiscuous; } 207*cfb92d14SAndroid Build Coastguard Worker 208*cfb92d14SAndroid Build Coastguard Worker /** 209*cfb92d14SAndroid Build Coastguard Worker * Sets the status of promiscuous mode. 210*cfb92d14SAndroid Build Coastguard Worker * 211*cfb92d14SAndroid Build Coastguard Worker * @param[in] aEnable Whether to enable or disable promiscuous mode. 212*cfb92d14SAndroid Build Coastguard Worker * 213*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 214*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 215*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 216*cfb92d14SAndroid Build Coastguard Worker * 217*cfb92d14SAndroid Build Coastguard Worker */ 218*cfb92d14SAndroid Build Coastguard Worker otError SetPromiscuous(bool aEnable); 219*cfb92d14SAndroid Build Coastguard Worker 220*cfb92d14SAndroid Build Coastguard Worker /** 221*cfb92d14SAndroid Build Coastguard Worker * Sets the status of RxOnWhenIdle mode. 222*cfb92d14SAndroid Build Coastguard Worker * 223*cfb92d14SAndroid Build Coastguard Worker * @param[in] aEnable Whether to enable or disable RxOnWhenIdle mode. 224*cfb92d14SAndroid Build Coastguard Worker * 225*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 226*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 227*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 228*cfb92d14SAndroid Build Coastguard Worker * 229*cfb92d14SAndroid Build Coastguard Worker */ 230*cfb92d14SAndroid Build Coastguard Worker otError SetRxOnWhenIdle(bool aEnable); 231*cfb92d14SAndroid Build Coastguard Worker 232*cfb92d14SAndroid Build Coastguard Worker /** 233*cfb92d14SAndroid Build Coastguard Worker * Sets the Short Address for address filtering. 234*cfb92d14SAndroid Build Coastguard Worker * 235*cfb92d14SAndroid Build Coastguard Worker * @param[in] aShortAddress The IEEE 802.15.4 Short Address. 236*cfb92d14SAndroid Build Coastguard Worker * 237*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 238*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 239*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 240*cfb92d14SAndroid Build Coastguard Worker * 241*cfb92d14SAndroid Build Coastguard Worker */ 242*cfb92d14SAndroid Build Coastguard Worker otError SetShortAddress(uint16_t aAddress); 243*cfb92d14SAndroid Build Coastguard Worker 244*cfb92d14SAndroid Build Coastguard Worker /** 245*cfb92d14SAndroid Build Coastguard Worker * Gets the factory-assigned IEEE EUI-64 for this transceiver. 246*cfb92d14SAndroid Build Coastguard Worker * 247*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 248*cfb92d14SAndroid Build Coastguard Worker * @param[out] aIeeeEui64 A pointer to the factory-assigned IEEE EUI-64. 249*cfb92d14SAndroid Build Coastguard Worker * 250*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 251*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 252*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 253*cfb92d14SAndroid Build Coastguard Worker * 254*cfb92d14SAndroid Build Coastguard Worker */ 255*cfb92d14SAndroid Build Coastguard Worker otError GetIeeeEui64(uint8_t *aIeeeEui64); 256*cfb92d14SAndroid Build Coastguard Worker 257*cfb92d14SAndroid Build Coastguard Worker /** 258*cfb92d14SAndroid Build Coastguard Worker * Sets the Extended Address for address filtering. 259*cfb92d14SAndroid Build Coastguard Worker * 260*cfb92d14SAndroid Build Coastguard Worker * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address stored in little-endian byte order. 261*cfb92d14SAndroid Build Coastguard Worker * 262*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 263*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 264*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 265*cfb92d14SAndroid Build Coastguard Worker * 266*cfb92d14SAndroid Build Coastguard Worker */ 267*cfb92d14SAndroid Build Coastguard Worker otError SetExtendedAddress(const otExtAddress &aExtAddress); 268*cfb92d14SAndroid Build Coastguard Worker 269*cfb92d14SAndroid Build Coastguard Worker /** 270*cfb92d14SAndroid Build Coastguard Worker * Sets the PAN ID for address filtering. 271*cfb92d14SAndroid Build Coastguard Worker * 272*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPanId The IEEE 802.15.4 PAN ID. 273*cfb92d14SAndroid Build Coastguard Worker * 274*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 275*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 276*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 277*cfb92d14SAndroid Build Coastguard Worker * 278*cfb92d14SAndroid Build Coastguard Worker */ 279*cfb92d14SAndroid Build Coastguard Worker otError SetPanId(uint16_t aPanId); 280*cfb92d14SAndroid Build Coastguard Worker 281*cfb92d14SAndroid Build Coastguard Worker /** 282*cfb92d14SAndroid Build Coastguard Worker * Gets the radio's transmit power in dBm. 283*cfb92d14SAndroid Build Coastguard Worker * 284*cfb92d14SAndroid Build Coastguard Worker * @param[out] aPower The transmit power in dBm. 285*cfb92d14SAndroid Build Coastguard Worker * 286*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 287*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 288*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 289*cfb92d14SAndroid Build Coastguard Worker * 290*cfb92d14SAndroid Build Coastguard Worker */ 291*cfb92d14SAndroid Build Coastguard Worker otError GetTransmitPower(int8_t &aPower); 292*cfb92d14SAndroid Build Coastguard Worker 293*cfb92d14SAndroid Build Coastguard Worker /** 294*cfb92d14SAndroid Build Coastguard Worker * Sets the radio's transmit power in dBm. 295*cfb92d14SAndroid Build Coastguard Worker * 296*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPower The transmit power in dBm. 297*cfb92d14SAndroid Build Coastguard Worker * 298*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 299*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 300*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 301*cfb92d14SAndroid Build Coastguard Worker * 302*cfb92d14SAndroid Build Coastguard Worker */ 303*cfb92d14SAndroid Build Coastguard Worker otError SetTransmitPower(int8_t aPower); 304*cfb92d14SAndroid Build Coastguard Worker 305*cfb92d14SAndroid Build Coastguard Worker /** 306*cfb92d14SAndroid Build Coastguard Worker * Gets the radio's CCA ED threshold in dBm. 307*cfb92d14SAndroid Build Coastguard Worker * 308*cfb92d14SAndroid Build Coastguard Worker * @param[out] aThreshold The CCA ED threshold in dBm. 309*cfb92d14SAndroid Build Coastguard Worker * 310*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 311*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 312*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 313*cfb92d14SAndroid Build Coastguard Worker * 314*cfb92d14SAndroid Build Coastguard Worker */ 315*cfb92d14SAndroid Build Coastguard Worker otError GetCcaEnergyDetectThreshold(int8_t &aThreshold); 316*cfb92d14SAndroid Build Coastguard Worker 317*cfb92d14SAndroid Build Coastguard Worker /** 318*cfb92d14SAndroid Build Coastguard Worker * Sets the radio's CCA ED threshold in dBm. 319*cfb92d14SAndroid Build Coastguard Worker * 320*cfb92d14SAndroid Build Coastguard Worker * @param[in] aThreshold The CCA ED threshold in dBm. 321*cfb92d14SAndroid Build Coastguard Worker * 322*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 323*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 324*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 325*cfb92d14SAndroid Build Coastguard Worker * 326*cfb92d14SAndroid Build Coastguard Worker */ 327*cfb92d14SAndroid Build Coastguard Worker otError SetCcaEnergyDetectThreshold(int8_t aThreshold); 328*cfb92d14SAndroid Build Coastguard Worker 329*cfb92d14SAndroid Build Coastguard Worker /** 330*cfb92d14SAndroid Build Coastguard Worker * Gets the FEM's Rx LNA gain in dBm. 331*cfb92d14SAndroid Build Coastguard Worker * 332*cfb92d14SAndroid Build Coastguard Worker * @param[out] aGain The FEM's Rx LNA gain in dBm. 333*cfb92d14SAndroid Build Coastguard Worker * 334*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 335*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 336*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 337*cfb92d14SAndroid Build Coastguard Worker * 338*cfb92d14SAndroid Build Coastguard Worker */ 339*cfb92d14SAndroid Build Coastguard Worker otError GetFemLnaGain(int8_t &aGain); 340*cfb92d14SAndroid Build Coastguard Worker 341*cfb92d14SAndroid Build Coastguard Worker /** 342*cfb92d14SAndroid Build Coastguard Worker * Sets the FEM's Rx LNA gain in dBm. 343*cfb92d14SAndroid Build Coastguard Worker * 344*cfb92d14SAndroid Build Coastguard Worker * @param[in] aGain The FEM's Rx LNA gain in dBm. 345*cfb92d14SAndroid Build Coastguard Worker * 346*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 347*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 348*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 349*cfb92d14SAndroid Build Coastguard Worker * 350*cfb92d14SAndroid Build Coastguard Worker */ 351*cfb92d14SAndroid Build Coastguard Worker otError SetFemLnaGain(int8_t aGain); 352*cfb92d14SAndroid Build Coastguard Worker 353*cfb92d14SAndroid Build Coastguard Worker /** 354*cfb92d14SAndroid Build Coastguard Worker * Returns the radio capabilities. 355*cfb92d14SAndroid Build Coastguard Worker * 356*cfb92d14SAndroid Build Coastguard Worker * @returns The radio capability bit vector. 357*cfb92d14SAndroid Build Coastguard Worker * 358*cfb92d14SAndroid Build Coastguard Worker */ GetRadioCaps(void) const359*cfb92d14SAndroid Build Coastguard Worker otRadioCaps GetRadioCaps(void) const { return sRadioCaps; } 360*cfb92d14SAndroid Build Coastguard Worker 361*cfb92d14SAndroid Build Coastguard Worker /** 362*cfb92d14SAndroid Build Coastguard Worker * Gets the most recent RSSI measurement. 363*cfb92d14SAndroid Build Coastguard Worker * 364*cfb92d14SAndroid Build Coastguard Worker * @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid. 365*cfb92d14SAndroid Build Coastguard Worker */ 366*cfb92d14SAndroid Build Coastguard Worker int8_t GetRssi(void); 367*cfb92d14SAndroid Build Coastguard Worker 368*cfb92d14SAndroid Build Coastguard Worker /** 369*cfb92d14SAndroid Build Coastguard Worker * Returns the radio receive sensitivity value. 370*cfb92d14SAndroid Build Coastguard Worker * 371*cfb92d14SAndroid Build Coastguard Worker * @returns The radio receive sensitivity value in dBm. 372*cfb92d14SAndroid Build Coastguard Worker * 373*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 374*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 375*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 376*cfb92d14SAndroid Build Coastguard Worker * 377*cfb92d14SAndroid Build Coastguard Worker */ GetReceiveSensitivity(void) const378*cfb92d14SAndroid Build Coastguard Worker int8_t GetReceiveSensitivity(void) const { return mRxSensitivity; } 379*cfb92d14SAndroid Build Coastguard Worker 380*cfb92d14SAndroid Build Coastguard Worker /** 381*cfb92d14SAndroid Build Coastguard Worker * Gets current state of the radio. 382*cfb92d14SAndroid Build Coastguard Worker * 383*cfb92d14SAndroid Build Coastguard Worker * @return Current state of the radio. 384*cfb92d14SAndroid Build Coastguard Worker * 385*cfb92d14SAndroid Build Coastguard Worker */ 386*cfb92d14SAndroid Build Coastguard Worker otRadioState GetState(void) const; 387*cfb92d14SAndroid Build Coastguard Worker 388*cfb92d14SAndroid Build Coastguard Worker /** 389*cfb92d14SAndroid Build Coastguard Worker * Gets the current receiving channel. 390*cfb92d14SAndroid Build Coastguard Worker * 391*cfb92d14SAndroid Build Coastguard Worker * @returns Current receiving channel. 392*cfb92d14SAndroid Build Coastguard Worker * 393*cfb92d14SAndroid Build Coastguard Worker */ GetChannel(void) const394*cfb92d14SAndroid Build Coastguard Worker uint8_t GetChannel(void) const { return mChannel; } 395*cfb92d14SAndroid Build Coastguard Worker 396*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE 397*cfb92d14SAndroid Build Coastguard Worker /** 398*cfb92d14SAndroid Build Coastguard Worker * Enable the radio coex. 399*cfb92d14SAndroid Build Coastguard Worker * 400*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 401*cfb92d14SAndroid Build Coastguard Worker * @param[in] aEnabled TRUE to enable the radio coex, FALSE otherwise. 402*cfb92d14SAndroid Build Coastguard Worker * 403*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully enabled. 404*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_FAILED The radio coex could not be enabled. 405*cfb92d14SAndroid Build Coastguard Worker * 406*cfb92d14SAndroid Build Coastguard Worker */ 407*cfb92d14SAndroid Build Coastguard Worker otError SetCoexEnabled(bool aEnabled); 408*cfb92d14SAndroid Build Coastguard Worker 409*cfb92d14SAndroid Build Coastguard Worker /** 410*cfb92d14SAndroid Build Coastguard Worker * Check whether radio coex is enabled or not. 411*cfb92d14SAndroid Build Coastguard Worker * 412*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 413*cfb92d14SAndroid Build Coastguard Worker * 414*cfb92d14SAndroid Build Coastguard Worker * @returns TRUE if the radio coex is enabled, FALSE otherwise. 415*cfb92d14SAndroid Build Coastguard Worker * 416*cfb92d14SAndroid Build Coastguard Worker */ 417*cfb92d14SAndroid Build Coastguard Worker bool IsCoexEnabled(void); 418*cfb92d14SAndroid Build Coastguard Worker 419*cfb92d14SAndroid Build Coastguard Worker /** 420*cfb92d14SAndroid Build Coastguard Worker * Retrieves the radio coexistence metrics. 421*cfb92d14SAndroid Build Coastguard Worker * 422*cfb92d14SAndroid Build Coastguard Worker * @param[out] aCoexMetrics A reference to the coexistence metrics structure. 423*cfb92d14SAndroid Build Coastguard Worker * 424*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully retrieved the coex metrics. 425*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS @p aCoexMetrics was nullptr. 426*cfb92d14SAndroid Build Coastguard Worker * 427*cfb92d14SAndroid Build Coastguard Worker */ 428*cfb92d14SAndroid Build Coastguard Worker otError GetCoexMetrics(otRadioCoexMetrics &aCoexMetrics); 429*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE 430*cfb92d14SAndroid Build Coastguard Worker 431*cfb92d14SAndroid Build Coastguard Worker /** 432*cfb92d14SAndroid Build Coastguard Worker * Get currently active interface. 433*cfb92d14SAndroid Build Coastguard Worker * 434*cfb92d14SAndroid Build Coastguard Worker * @param[out] aIid IID of the interface that owns the radio. 435*cfb92d14SAndroid Build Coastguard Worker * 436*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully got the property. 437*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 438*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_IMPLEMENTED Failed due to lack of the support in radio 439*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_COMMAND Platform supports all interfaces simultaneously. 440*cfb92d14SAndroid Build Coastguard Worker * (i.e. no active/inactive interface concept in the platform level) 441*cfb92d14SAndroid Build Coastguard Worker * 442*cfb92d14SAndroid Build Coastguard Worker */ 443*cfb92d14SAndroid Build Coastguard Worker otError GetMultipanActiveInterface(spinel_iid_t *aIid); 444*cfb92d14SAndroid Build Coastguard Worker 445*cfb92d14SAndroid Build Coastguard Worker /** 446*cfb92d14SAndroid Build Coastguard Worker * Sets specified radio interface active 447*cfb92d14SAndroid Build Coastguard Worker * 448*cfb92d14SAndroid Build Coastguard Worker * This function allows selecting currently active radio interface on platforms that do not support parallel 449*cfb92d14SAndroid Build Coastguard Worker * communication on multiple interfaces. I.e. if more than one interface is in receive state calling 450*cfb92d14SAndroid Build Coastguard Worker * SetMultipanActiveInterface guarantees that specified interface will not be losing frames. This function 451*cfb92d14SAndroid Build Coastguard Worker * returns if the request was received properly. After interface switching is complete SwitchoverDone callback is 452*cfb92d14SAndroid Build Coastguard Worker * Invoked. Switching interfaces may take longer if aCompletePending is set true. 453*cfb92d14SAndroid Build Coastguard Worker * 454*cfb92d14SAndroid Build Coastguard Worker * @param[in] aIid IID of the interface to set active. 455*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCompletePending Set true if pending radio operation should complete first(Soft switch) or false if 456*cfb92d14SAndroid Build Coastguard Worker * ongoing operations should be interrupted (Force switch). 457*cfb92d14SAndroid Build Coastguard Worker * 458*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully requested interface switch. 459*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation on going. 460*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 461*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_IMPLEMENTED Failed due to lack of support in radio for the given interface id or 462*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_COMMAND Platform supports all interfaces simultaneously 463*cfb92d14SAndroid Build Coastguard Worker * (i.e. no active/inactive interface concept in the platform level) 464*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_ALREADY Given interface is already active. 465*cfb92d14SAndroid Build Coastguard Worker * 466*cfb92d14SAndroid Build Coastguard Worker */ 467*cfb92d14SAndroid Build Coastguard Worker otError SetMultipanActiveInterface(spinel_iid_t aIid, bool aCompletePending); 468*cfb92d14SAndroid Build Coastguard Worker 469*cfb92d14SAndroid Build Coastguard Worker /** 470*cfb92d14SAndroid Build Coastguard Worker * Returns a reference to the transmit buffer. 471*cfb92d14SAndroid Build Coastguard Worker * 472*cfb92d14SAndroid Build Coastguard Worker * The caller forms the IEEE 802.15.4 frame in this buffer then calls otPlatRadioTransmit() to request transmission. 473*cfb92d14SAndroid Build Coastguard Worker * 474*cfb92d14SAndroid Build Coastguard Worker * @returns A reference to the transmit buffer. 475*cfb92d14SAndroid Build Coastguard Worker * 476*cfb92d14SAndroid Build Coastguard Worker */ GetTransmitFrame(void)477*cfb92d14SAndroid Build Coastguard Worker otRadioFrame &GetTransmitFrame(void) { return mTxRadioFrame; } 478*cfb92d14SAndroid Build Coastguard Worker 479*cfb92d14SAndroid Build Coastguard Worker /** 480*cfb92d14SAndroid Build Coastguard Worker * Enables or disables source address match feature. 481*cfb92d14SAndroid Build Coastguard Worker * 482*cfb92d14SAndroid Build Coastguard Worker * @param[in] aEnable Enable/disable source address match feature. 483*cfb92d14SAndroid Build Coastguard Worker * 484*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 485*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 486*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 487*cfb92d14SAndroid Build Coastguard Worker * 488*cfb92d14SAndroid Build Coastguard Worker */ 489*cfb92d14SAndroid Build Coastguard Worker otError EnableSrcMatch(bool aEnable); 490*cfb92d14SAndroid Build Coastguard Worker 491*cfb92d14SAndroid Build Coastguard Worker /** 492*cfb92d14SAndroid Build Coastguard Worker * Adds a short address to the source address match table. 493*cfb92d14SAndroid Build Coastguard Worker * 494*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 495*cfb92d14SAndroid Build Coastguard Worker * @param[in] aShortAddress The short address to be added. 496*cfb92d14SAndroid Build Coastguard Worker * 497*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully added short address to the source match table. 498*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 499*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 500*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_BUFS No available entry in the source match table. 501*cfb92d14SAndroid Build Coastguard Worker */ 502*cfb92d14SAndroid Build Coastguard Worker otError AddSrcMatchShortEntry(uint16_t aShortAddress); 503*cfb92d14SAndroid Build Coastguard Worker 504*cfb92d14SAndroid Build Coastguard Worker /** 505*cfb92d14SAndroid Build Coastguard Worker * Removes a short address from the source address match table. 506*cfb92d14SAndroid Build Coastguard Worker * 507*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 508*cfb92d14SAndroid Build Coastguard Worker * @param[in] aShortAddress The short address to be removed. 509*cfb92d14SAndroid Build Coastguard Worker * 510*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully removed short address from the source match table. 511*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 512*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 513*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_ADDRESS The short address is not in source address match table. 514*cfb92d14SAndroid Build Coastguard Worker */ 515*cfb92d14SAndroid Build Coastguard Worker otError ClearSrcMatchShortEntry(uint16_t aShortAddress); 516*cfb92d14SAndroid Build Coastguard Worker 517*cfb92d14SAndroid Build Coastguard Worker /** 518*cfb92d14SAndroid Build Coastguard Worker * Clear all short addresses from the source address match table. 519*cfb92d14SAndroid Build Coastguard Worker * 520*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 521*cfb92d14SAndroid Build Coastguard Worker * 522*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 523*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 524*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 525*cfb92d14SAndroid Build Coastguard Worker * 526*cfb92d14SAndroid Build Coastguard Worker */ 527*cfb92d14SAndroid Build Coastguard Worker otError ClearSrcMatchShortEntries(void); 528*cfb92d14SAndroid Build Coastguard Worker 529*cfb92d14SAndroid Build Coastguard Worker /** 530*cfb92d14SAndroid Build Coastguard Worker * Add an extended address to the source address match table. 531*cfb92d14SAndroid Build Coastguard Worker * 532*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 533*cfb92d14SAndroid Build Coastguard Worker * @param[in] aExtAddress The extended address to be added stored in little-endian byte order. 534*cfb92d14SAndroid Build Coastguard Worker * 535*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully added extended address to the source match table. 536*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 537*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 538*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_BUFS No available entry in the source match table. 539*cfb92d14SAndroid Build Coastguard Worker */ 540*cfb92d14SAndroid Build Coastguard Worker otError AddSrcMatchExtEntry(const otExtAddress &aExtAddress); 541*cfb92d14SAndroid Build Coastguard Worker 542*cfb92d14SAndroid Build Coastguard Worker /** 543*cfb92d14SAndroid Build Coastguard Worker * Remove an extended address from the source address match table. 544*cfb92d14SAndroid Build Coastguard Worker * 545*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 546*cfb92d14SAndroid Build Coastguard Worker * @param[in] aExtAddress The extended address to be removed stored in little-endian byte order. 547*cfb92d14SAndroid Build Coastguard Worker * 548*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully removed the extended address from the source match table. 549*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 550*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 551*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_ADDRESS The extended address is not in source address match table. 552*cfb92d14SAndroid Build Coastguard Worker */ 553*cfb92d14SAndroid Build Coastguard Worker otError ClearSrcMatchExtEntry(const otExtAddress &aExtAddress); 554*cfb92d14SAndroid Build Coastguard Worker 555*cfb92d14SAndroid Build Coastguard Worker /** 556*cfb92d14SAndroid Build Coastguard Worker * Clear all the extended/long addresses from source address match table. 557*cfb92d14SAndroid Build Coastguard Worker * 558*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance The OpenThread instance structure. 559*cfb92d14SAndroid Build Coastguard Worker * 560*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 561*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 562*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 563*cfb92d14SAndroid Build Coastguard Worker * 564*cfb92d14SAndroid Build Coastguard Worker */ 565*cfb92d14SAndroid Build Coastguard Worker otError ClearSrcMatchExtEntries(void); 566*cfb92d14SAndroid Build Coastguard Worker 567*cfb92d14SAndroid Build Coastguard Worker /** 568*cfb92d14SAndroid Build Coastguard Worker * Begins the energy scan sequence on the radio. 569*cfb92d14SAndroid Build Coastguard Worker * 570*cfb92d14SAndroid Build Coastguard Worker * @param[in] aScanChannel The channel to perform the energy scan on. 571*cfb92d14SAndroid Build Coastguard Worker * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. 572*cfb92d14SAndroid Build Coastguard Worker * 573*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 574*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 575*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 576*cfb92d14SAndroid Build Coastguard Worker * 577*cfb92d14SAndroid Build Coastguard Worker */ 578*cfb92d14SAndroid Build Coastguard Worker otError EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration); 579*cfb92d14SAndroid Build Coastguard Worker 580*cfb92d14SAndroid Build Coastguard Worker /** 581*cfb92d14SAndroid Build Coastguard Worker * Switches the radio state from Receive to Transmit. 582*cfb92d14SAndroid Build Coastguard Worker * 583*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFrame A reference to the transmitted frame. 584*cfb92d14SAndroid Build Coastguard Worker * 585*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully transitioned to Transmit. 586*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another transmission is on going. 587*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 588*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state. 589*cfb92d14SAndroid Build Coastguard Worker */ 590*cfb92d14SAndroid Build Coastguard Worker otError Transmit(otRadioFrame &aFrame); 591*cfb92d14SAndroid Build Coastguard Worker 592*cfb92d14SAndroid Build Coastguard Worker /** 593*cfb92d14SAndroid Build Coastguard Worker * Switches the radio state from Sleep to Receive. 594*cfb92d14SAndroid Build Coastguard Worker * 595*cfb92d14SAndroid Build Coastguard Worker * @param[in] aChannel The channel to use for receiving. 596*cfb92d14SAndroid Build Coastguard Worker * 597*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully transitioned to Receive. 598*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_STATE The radio was disabled or transmitting. 599*cfb92d14SAndroid Build Coastguard Worker * 600*cfb92d14SAndroid Build Coastguard Worker */ 601*cfb92d14SAndroid Build Coastguard Worker otError Receive(uint8_t aChannel); 602*cfb92d14SAndroid Build Coastguard Worker 603*cfb92d14SAndroid Build Coastguard Worker /** 604*cfb92d14SAndroid Build Coastguard Worker * Switches the radio state from Receive to Sleep. 605*cfb92d14SAndroid Build Coastguard Worker * 606*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully transitioned to Sleep. 607*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY The radio was transmitting 608*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_STATE The radio was disabled 609*cfb92d14SAndroid Build Coastguard Worker * 610*cfb92d14SAndroid Build Coastguard Worker */ 611*cfb92d14SAndroid Build Coastguard Worker otError Sleep(void); 612*cfb92d14SAndroid Build Coastguard Worker 613*cfb92d14SAndroid Build Coastguard Worker /** 614*cfb92d14SAndroid Build Coastguard Worker * Enable the radio. 615*cfb92d14SAndroid Build Coastguard Worker * 616*cfb92d14SAndroid Build Coastguard Worker * @param[in] aInstance A pointer to the OpenThread instance. 617*cfb92d14SAndroid Build Coastguard Worker * 618*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully enabled. 619*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_FAILED The radio could not be enabled. 620*cfb92d14SAndroid Build Coastguard Worker * 621*cfb92d14SAndroid Build Coastguard Worker */ 622*cfb92d14SAndroid Build Coastguard Worker otError Enable(otInstance *aInstance); 623*cfb92d14SAndroid Build Coastguard Worker 624*cfb92d14SAndroid Build Coastguard Worker /** 625*cfb92d14SAndroid Build Coastguard Worker * Disable the radio. 626*cfb92d14SAndroid Build Coastguard Worker * 627*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully transitioned to Disabled. 628*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 629*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 630*cfb92d14SAndroid Build Coastguard Worker * 631*cfb92d14SAndroid Build Coastguard Worker */ 632*cfb92d14SAndroid Build Coastguard Worker otError Disable(void); 633*cfb92d14SAndroid Build Coastguard Worker 634*cfb92d14SAndroid Build Coastguard Worker /** 635*cfb92d14SAndroid Build Coastguard Worker * Checks whether radio is enabled or not. 636*cfb92d14SAndroid Build Coastguard Worker * 637*cfb92d14SAndroid Build Coastguard Worker * @returns TRUE if the radio is enabled, FALSE otherwise. 638*cfb92d14SAndroid Build Coastguard Worker * 639*cfb92d14SAndroid Build Coastguard Worker */ IsEnabled(void) const640*cfb92d14SAndroid Build Coastguard Worker bool IsEnabled(void) const { return mState != kStateDisabled; } 641*cfb92d14SAndroid Build Coastguard Worker 642*cfb92d14SAndroid Build Coastguard Worker /** 643*cfb92d14SAndroid Build Coastguard Worker * Indicates whether there is a pending transmission. 644*cfb92d14SAndroid Build Coastguard Worker * 645*cfb92d14SAndroid Build Coastguard Worker * @retval TRUE There is a pending transmission. 646*cfb92d14SAndroid Build Coastguard Worker * @retval FALSE There is no pending transmission. 647*cfb92d14SAndroid Build Coastguard Worker * 648*cfb92d14SAndroid Build Coastguard Worker */ IsTransmitting(void) const649*cfb92d14SAndroid Build Coastguard Worker bool IsTransmitting(void) const { return mState == kStateTransmitting; } 650*cfb92d14SAndroid Build Coastguard Worker 651*cfb92d14SAndroid Build Coastguard Worker /** 652*cfb92d14SAndroid Build Coastguard Worker * Indicates whether a transmit has just finished. 653*cfb92d14SAndroid Build Coastguard Worker * 654*cfb92d14SAndroid Build Coastguard Worker * @retval TRUE The transmission is done. 655*cfb92d14SAndroid Build Coastguard Worker * @retval FALSE The transmission is not done. 656*cfb92d14SAndroid Build Coastguard Worker * 657*cfb92d14SAndroid Build Coastguard Worker */ IsTransmitDone(void) const658*cfb92d14SAndroid Build Coastguard Worker bool IsTransmitDone(void) const { return mState == kStateTransmitDone; } 659*cfb92d14SAndroid Build Coastguard Worker 660*cfb92d14SAndroid Build Coastguard Worker /** 661*cfb92d14SAndroid Build Coastguard Worker * Returns the timeout timepoint for the pending transmission. 662*cfb92d14SAndroid Build Coastguard Worker * 663*cfb92d14SAndroid Build Coastguard Worker * @returns The timeout timepoint for the pending transmission. 664*cfb92d14SAndroid Build Coastguard Worker * 665*cfb92d14SAndroid Build Coastguard Worker */ GetTxRadioEndUs(void) const666*cfb92d14SAndroid Build Coastguard Worker uint64_t GetTxRadioEndUs(void) const { return mTxRadioEndUs; } 667*cfb92d14SAndroid Build Coastguard Worker 668*cfb92d14SAndroid Build Coastguard Worker /** 669*cfb92d14SAndroid Build Coastguard Worker * Processes any pending the I/O data. 670*cfb92d14SAndroid Build Coastguard Worker * 671*cfb92d14SAndroid Build Coastguard Worker * @param[in] aContext The process context. 672*cfb92d14SAndroid Build Coastguard Worker * 673*cfb92d14SAndroid Build Coastguard Worker */ 674*cfb92d14SAndroid Build Coastguard Worker void Process(const void *aContext); 675*cfb92d14SAndroid Build Coastguard Worker 676*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 677*cfb92d14SAndroid Build Coastguard Worker /** 678*cfb92d14SAndroid Build Coastguard Worker * Enables/disables the factory diagnostics mode. 679*cfb92d14SAndroid Build Coastguard Worker * 680*cfb92d14SAndroid Build Coastguard Worker * @param[in] aMode TRUE to enable diagnostics mode, FALSE otherwise. 681*cfb92d14SAndroid Build Coastguard Worker * 682*cfb92d14SAndroid Build Coastguard Worker */ SetDiagEnabled(bool aMode)683*cfb92d14SAndroid Build Coastguard Worker void SetDiagEnabled(bool aMode) { mDiagMode = aMode; } 684*cfb92d14SAndroid Build Coastguard Worker 685*cfb92d14SAndroid Build Coastguard Worker /** 686*cfb92d14SAndroid Build Coastguard Worker * Indicates whether or not factory diagnostics mode is enabled. 687*cfb92d14SAndroid Build Coastguard Worker * 688*cfb92d14SAndroid Build Coastguard Worker * @returns TRUE if factory diagnostics mode is enabled, FALSE otherwise. 689*cfb92d14SAndroid Build Coastguard Worker * 690*cfb92d14SAndroid Build Coastguard Worker */ IsDiagEnabled(void) const691*cfb92d14SAndroid Build Coastguard Worker bool IsDiagEnabled(void) const { return mDiagMode; } 692*cfb92d14SAndroid Build Coastguard Worker 693*cfb92d14SAndroid Build Coastguard Worker /** 694*cfb92d14SAndroid Build Coastguard Worker * Processes RadioSpinel - specific diagnostics commands. 695*cfb92d14SAndroid Build Coastguard Worker * 696*cfb92d14SAndroid Build Coastguard Worker * @param[in] aArgsLength The number of arguments in @p aArgs. 697*cfb92d14SAndroid Build Coastguard Worker * @param[in] aArgs The arguments of diagnostics command line. 698*cfb92d14SAndroid Build Coastguard Worker * 699*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 700*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS Failed due to invalid arguments provided. 701*cfb92d14SAndroid Build Coastguard Worker * 702*cfb92d14SAndroid Build Coastguard Worker */ 703*cfb92d14SAndroid Build Coastguard Worker otError RadioSpinelDiagProcess(char *aArgs[], uint8_t aArgsLength); 704*cfb92d14SAndroid Build Coastguard Worker 705*cfb92d14SAndroid Build Coastguard Worker /** 706*cfb92d14SAndroid Build Coastguard Worker * Processes platform diagnostics commands. 707*cfb92d14SAndroid Build Coastguard Worker * 708*cfb92d14SAndroid Build Coastguard Worker * @param[in] aString A null-terminated input string. 709*cfb92d14SAndroid Build Coastguard Worker * 710*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 711*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 712*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 713*cfb92d14SAndroid Build Coastguard Worker * 714*cfb92d14SAndroid Build Coastguard Worker */ 715*cfb92d14SAndroid Build Coastguard Worker otError PlatDiagProcess(const char *aString); 716*cfb92d14SAndroid Build Coastguard Worker 717*cfb92d14SAndroid Build Coastguard Worker /** 718*cfb92d14SAndroid Build Coastguard Worker * Sets the diag output callback. 719*cfb92d14SAndroid Build Coastguard Worker * 720*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCallback A pointer to a function that is called on outputting diag messages. 721*cfb92d14SAndroid Build Coastguard Worker * @param[in] aContext A pointer to the user context. 722*cfb92d14SAndroid Build Coastguard Worker * 723*cfb92d14SAndroid Build Coastguard Worker */ 724*cfb92d14SAndroid Build Coastguard Worker void SetDiagOutputCallback(otPlatDiagOutputCallback aCallback, void *aContext); 725*cfb92d14SAndroid Build Coastguard Worker 726*cfb92d14SAndroid Build Coastguard Worker /** 727*cfb92d14SAndroid Build Coastguard Worker * Gets the diag output callback. 728*cfb92d14SAndroid Build Coastguard Worker * 729*cfb92d14SAndroid Build Coastguard Worker * @param[out] aCallback A reference to a function that is called on outputting diag messages. 730*cfb92d14SAndroid Build Coastguard Worker * @param[out] aContext A reference to the user context. 731*cfb92d14SAndroid Build Coastguard Worker * 732*cfb92d14SAndroid Build Coastguard Worker */ 733*cfb92d14SAndroid Build Coastguard Worker void GetDiagOutputCallback(otPlatDiagOutputCallback &aCallback, void *&aContext); 734*cfb92d14SAndroid Build Coastguard Worker #endif 735*cfb92d14SAndroid Build Coastguard Worker 736*cfb92d14SAndroid Build Coastguard Worker /** 737*cfb92d14SAndroid Build Coastguard Worker * Returns the radio channel mask. 738*cfb92d14SAndroid Build Coastguard Worker * 739*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPreferred TRUE to get preferred channel mask, FALSE to get supported channel mask. 740*cfb92d14SAndroid Build Coastguard Worker * 741*cfb92d14SAndroid Build Coastguard Worker * @returns The radio channel mask according to @aPreferred: 742*cfb92d14SAndroid Build Coastguard Worker * The radio supported channel mask that the device is allowed to be on. 743*cfb92d14SAndroid Build Coastguard Worker * The radio preferred channel mask that the device prefers to form on. 744*cfb92d14SAndroid Build Coastguard Worker * 745*cfb92d14SAndroid Build Coastguard Worker */ 746*cfb92d14SAndroid Build Coastguard Worker uint32_t GetRadioChannelMask(bool aPreferred); 747*cfb92d14SAndroid Build Coastguard Worker 748*cfb92d14SAndroid Build Coastguard Worker /** 749*cfb92d14SAndroid Build Coastguard Worker * Sets MAC key and key index to RCP. 750*cfb92d14SAndroid Build Coastguard Worker * 751*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKeyIdMode The key ID mode. 752*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKeyId The key index. 753*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPrevKey Pointer to previous MAC key. 754*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCurrKey Pointer to current MAC key. 755*cfb92d14SAndroid Build Coastguard Worker * @param[in] aNextKey Pointer to next MAC key. 756*cfb92d14SAndroid Build Coastguard Worker * 757*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Succeeded. 758*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS One of the keys passed is invalid.. 759*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 760*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 761*cfb92d14SAndroid Build Coastguard Worker * 762*cfb92d14SAndroid Build Coastguard Worker */ 763*cfb92d14SAndroid Build Coastguard Worker otError SetMacKey(uint8_t aKeyIdMode, 764*cfb92d14SAndroid Build Coastguard Worker uint8_t aKeyId, 765*cfb92d14SAndroid Build Coastguard Worker const otMacKeyMaterial *aPrevKey, 766*cfb92d14SAndroid Build Coastguard Worker const otMacKeyMaterial *aCurrKey, 767*cfb92d14SAndroid Build Coastguard Worker const otMacKeyMaterial *aNextKey); 768*cfb92d14SAndroid Build Coastguard Worker 769*cfb92d14SAndroid Build Coastguard Worker /** 770*cfb92d14SAndroid Build Coastguard Worker * Sets the current MAC Frame Counter value. 771*cfb92d14SAndroid Build Coastguard Worker * 772*cfb92d14SAndroid Build Coastguard Worker * @param[in] aMacFrameCounter The MAC Frame Counter value. 773*cfb92d14SAndroid Build Coastguard Worker * @param[in] aSetIfLarger If `true`, set only if the new value is larger than the current value. 774*cfb92d14SAndroid Build Coastguard Worker * If `false`, set the new value independent of the current value. 775*cfb92d14SAndroid Build Coastguard Worker * 776*cfb92d14SAndroid Build Coastguard Worker */ 777*cfb92d14SAndroid Build Coastguard Worker otError SetMacFrameCounter(uint32_t aMacFrameCounter, bool aSetIfLarger); 778*cfb92d14SAndroid Build Coastguard Worker 779*cfb92d14SAndroid Build Coastguard Worker /** 780*cfb92d14SAndroid Build Coastguard Worker * Sets the radio region code. 781*cfb92d14SAndroid Build Coastguard Worker * 782*cfb92d14SAndroid Build Coastguard Worker * @param[in] aRegionCode The radio region code. 783*cfb92d14SAndroid Build Coastguard Worker * 784*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully set region code. 785*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_FAILED Other platform specific errors. 786*cfb92d14SAndroid Build Coastguard Worker * 787*cfb92d14SAndroid Build Coastguard Worker */ 788*cfb92d14SAndroid Build Coastguard Worker otError SetRadioRegion(uint16_t aRegionCode); 789*cfb92d14SAndroid Build Coastguard Worker 790*cfb92d14SAndroid Build Coastguard Worker /** 791*cfb92d14SAndroid Build Coastguard Worker * Gets the radio region code. 792*cfb92d14SAndroid Build Coastguard Worker * 793*cfb92d14SAndroid Build Coastguard Worker * @param[out] aRegionCode The radio region code. 794*cfb92d14SAndroid Build Coastguard Worker * 795*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS @p aRegionCode is nullptr. 796*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully got region code. 797*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_FAILED Other platform specific errors. 798*cfb92d14SAndroid Build Coastguard Worker * 799*cfb92d14SAndroid Build Coastguard Worker */ 800*cfb92d14SAndroid Build Coastguard Worker otError GetRadioRegion(uint16_t *aRegionCode); 801*cfb92d14SAndroid Build Coastguard Worker 802*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 803*cfb92d14SAndroid Build Coastguard Worker /** 804*cfb92d14SAndroid Build Coastguard Worker * Enable/disable or update Enhanced-ACK Based Probing in radio for a specific Initiator. 805*cfb92d14SAndroid Build Coastguard Worker * 806*cfb92d14SAndroid Build Coastguard Worker * After Enhanced-ACK Based Probing is configured by a specific Probing Initiator, the Enhanced-ACK sent to that 807*cfb92d14SAndroid Build Coastguard Worker * node should include Vendor-Specific IE containing Link Metrics data. This method informs the radio to start/stop 808*cfb92d14SAndroid Build Coastguard Worker * to collect Link Metrics data and include Vendor-Specific IE that containing the data in Enhanced-ACK sent to that 809*cfb92d14SAndroid Build Coastguard Worker * Probing Initiator. 810*cfb92d14SAndroid Build Coastguard Worker * 811*cfb92d14SAndroid Build Coastguard Worker * @param[in] aLinkMetrics This parameter specifies what metrics to query. Per spec 4.11.3.4.4.6, at most 2 812*cfb92d14SAndroid Build Coastguard Worker * metrics can be specified. The probing would be disabled if @p aLinkMetrics is 813*cfb92d14SAndroid Build Coastguard Worker * bitwise 0. 814*cfb92d14SAndroid Build Coastguard Worker * @param[in] aShortAddress The short address of the Probing Initiator. 815*cfb92d14SAndroid Build Coastguard Worker * @param[in] aExtAddress The extended source address of the Probing Initiator. @p aExtAddress MUST NOT be 816*cfb92d14SAndroid Build Coastguard Worker * nullptr. 817*cfb92d14SAndroid Build Coastguard Worker * 818*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully configured the Enhanced-ACK Based Probing. 819*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS @p aExtAddress is nullptr. 820*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_FOUND The Initiator indicated by @p aShortAddress is not found when trying to clear. 821*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_BUFS No more Initiator can be supported. 822*cfb92d14SAndroid Build Coastguard Worker */ 823*cfb92d14SAndroid Build Coastguard Worker otError ConfigureEnhAckProbing(otLinkMetrics aLinkMetrics, 824*cfb92d14SAndroid Build Coastguard Worker const otShortAddress &aShortAddress, 825*cfb92d14SAndroid Build Coastguard Worker const otExtAddress &aExtAddress); 826*cfb92d14SAndroid Build Coastguard Worker #endif 827*cfb92d14SAndroid Build Coastguard Worker 828*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 829*cfb92d14SAndroid Build Coastguard Worker /** 830*cfb92d14SAndroid Build Coastguard Worker * Get the current accuracy, in units of ± ppm, of the clock used for scheduling CSL operations. 831*cfb92d14SAndroid Build Coastguard Worker * 832*cfb92d14SAndroid Build Coastguard Worker * @note Platforms may optimize this value based on operational conditions (i.e.: temperature). 833*cfb92d14SAndroid Build Coastguard Worker * 834*cfb92d14SAndroid Build Coastguard Worker * @retval The current CSL rx/tx scheduling drift, in units of ± ppm. 835*cfb92d14SAndroid Build Coastguard Worker * 836*cfb92d14SAndroid Build Coastguard Worker */ 837*cfb92d14SAndroid Build Coastguard Worker uint8_t GetCslAccuracy(void); 838*cfb92d14SAndroid Build Coastguard Worker #endif 839*cfb92d14SAndroid Build Coastguard Worker 840*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 841*cfb92d14SAndroid Build Coastguard Worker /** 842*cfb92d14SAndroid Build Coastguard Worker * Get the current uncertainty, in units of 10 us, of the clock used for scheduling CSL operations. 843*cfb92d14SAndroid Build Coastguard Worker * 844*cfb92d14SAndroid Build Coastguard Worker * @retval The current CSL Clock Uncertainty in units of 10 us. 845*cfb92d14SAndroid Build Coastguard Worker * 846*cfb92d14SAndroid Build Coastguard Worker */ 847*cfb92d14SAndroid Build Coastguard Worker uint8_t GetCslUncertainty(void); 848*cfb92d14SAndroid Build Coastguard Worker #endif 849*cfb92d14SAndroid Build Coastguard Worker 850*cfb92d14SAndroid Build Coastguard Worker /** 851*cfb92d14SAndroid Build Coastguard Worker * Checks whether there is pending frame in the buffer. 852*cfb92d14SAndroid Build Coastguard Worker * 853*cfb92d14SAndroid Build Coastguard Worker * @returns Whether there is pending frame in the buffer. 854*cfb92d14SAndroid Build Coastguard Worker * 855*cfb92d14SAndroid Build Coastguard Worker */ HasPendingFrame(void) const856*cfb92d14SAndroid Build Coastguard Worker bool HasPendingFrame(void) const { return mSpinelDriver->HasPendingFrame(); } 857*cfb92d14SAndroid Build Coastguard Worker 858*cfb92d14SAndroid Build Coastguard Worker /** 859*cfb92d14SAndroid Build Coastguard Worker * Returns the next timepoint to recalculate RCP time offset. 860*cfb92d14SAndroid Build Coastguard Worker * 861*cfb92d14SAndroid Build Coastguard Worker * @returns The timepoint to start the recalculation of RCP time offset. 862*cfb92d14SAndroid Build Coastguard Worker * 863*cfb92d14SAndroid Build Coastguard Worker */ GetNextRadioTimeRecalcStart(void) const864*cfb92d14SAndroid Build Coastguard Worker uint64_t GetNextRadioTimeRecalcStart(void) const { return mRadioTimeRecalcStart; } 865*cfb92d14SAndroid Build Coastguard Worker 866*cfb92d14SAndroid Build Coastguard Worker /** 867*cfb92d14SAndroid Build Coastguard Worker * Gets the current estimated time on RCP. 868*cfb92d14SAndroid Build Coastguard Worker * 869*cfb92d14SAndroid Build Coastguard Worker * @returns The current estimated RCP time in microseconds. 870*cfb92d14SAndroid Build Coastguard Worker * 871*cfb92d14SAndroid Build Coastguard Worker */ 872*cfb92d14SAndroid Build Coastguard Worker uint64_t GetNow(void); 873*cfb92d14SAndroid Build Coastguard Worker 874*cfb92d14SAndroid Build Coastguard Worker /** 875*cfb92d14SAndroid Build Coastguard Worker * Returns the bus speed between the host and the radio. 876*cfb92d14SAndroid Build Coastguard Worker * 877*cfb92d14SAndroid Build Coastguard Worker * @returns bus speed in bits/second. 878*cfb92d14SAndroid Build Coastguard Worker * 879*cfb92d14SAndroid Build Coastguard Worker */ 880*cfb92d14SAndroid Build Coastguard Worker uint32_t GetBusSpeed(void) const; 881*cfb92d14SAndroid Build Coastguard Worker 882*cfb92d14SAndroid Build Coastguard Worker /** 883*cfb92d14SAndroid Build Coastguard Worker * Returns the bus latency between the host and the radio. 884*cfb92d14SAndroid Build Coastguard Worker * 885*cfb92d14SAndroid Build Coastguard Worker * @returns Bus latency in microseconds. 886*cfb92d14SAndroid Build Coastguard Worker * 887*cfb92d14SAndroid Build Coastguard Worker */ 888*cfb92d14SAndroid Build Coastguard Worker uint32_t GetBusLatency(void) const; 889*cfb92d14SAndroid Build Coastguard Worker 890*cfb92d14SAndroid Build Coastguard Worker /** 891*cfb92d14SAndroid Build Coastguard Worker * Sets the bus latency between the host and the radio. 892*cfb92d14SAndroid Build Coastguard Worker * 893*cfb92d14SAndroid Build Coastguard Worker * @param[in] aBusLatency Bus latency in microseconds. 894*cfb92d14SAndroid Build Coastguard Worker * 895*cfb92d14SAndroid Build Coastguard Worker */ 896*cfb92d14SAndroid Build Coastguard Worker void SetBusLatency(uint32_t aBusLatency); 897*cfb92d14SAndroid Build Coastguard Worker 898*cfb92d14SAndroid Build Coastguard Worker /** 899*cfb92d14SAndroid Build Coastguard Worker * Returns the co-processor sw version string. 900*cfb92d14SAndroid Build Coastguard Worker * 901*cfb92d14SAndroid Build Coastguard Worker * @returns A pointer to the co-processor version string. 902*cfb92d14SAndroid Build Coastguard Worker * 903*cfb92d14SAndroid Build Coastguard Worker */ GetVersion(void) const904*cfb92d14SAndroid Build Coastguard Worker const char *GetVersion(void) const { return mSpinelDriver->GetVersion(); } 905*cfb92d14SAndroid Build Coastguard Worker 906*cfb92d14SAndroid Build Coastguard Worker /** 907*cfb92d14SAndroid Build Coastguard Worker * Sets the max transmit power. 908*cfb92d14SAndroid Build Coastguard Worker * 909*cfb92d14SAndroid Build Coastguard Worker * @param[in] aChannel The radio channel. 910*cfb92d14SAndroid Build Coastguard Worker * @param[in] aMaxPower The max transmit power in dBm. 911*cfb92d14SAndroid Build Coastguard Worker * 912*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully set the max transmit power. 913*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS Channel is not in valid range. 914*cfb92d14SAndroid Build Coastguard Worker * 915*cfb92d14SAndroid Build Coastguard Worker */ 916*cfb92d14SAndroid Build Coastguard Worker otError SetChannelMaxTransmitPower(uint8_t aChannel, int8_t aMaxPower); 917*cfb92d14SAndroid Build Coastguard Worker 918*cfb92d14SAndroid Build Coastguard Worker /** 919*cfb92d14SAndroid Build Coastguard Worker * Tries to retrieve a spinel property from OpenThread transceiver. 920*cfb92d14SAndroid Build Coastguard Worker * 921*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKey Spinel property key. 922*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFormat Spinel formatter to unpack property value. 923*cfb92d14SAndroid Build Coastguard Worker * @param[out] ... Variable arguments list. 924*cfb92d14SAndroid Build Coastguard Worker * 925*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully got the property. 926*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 927*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 928*cfb92d14SAndroid Build Coastguard Worker * 929*cfb92d14SAndroid Build Coastguard Worker */ 930*cfb92d14SAndroid Build Coastguard Worker otError Get(spinel_prop_key_t aKey, const char *aFormat, ...); 931*cfb92d14SAndroid Build Coastguard Worker 932*cfb92d14SAndroid Build Coastguard Worker /** 933*cfb92d14SAndroid Build Coastguard Worker * Tries to retrieve a spinel property from OpenThread transceiver with parameter appended. 934*cfb92d14SAndroid Build Coastguard Worker * 935*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKey Spinel property key. 936*cfb92d14SAndroid Build Coastguard Worker * @param[in] aParam Parameter appended to spinel command. 937*cfb92d14SAndroid Build Coastguard Worker * @param[in] aParamSize Size of parameter appended to spinel command 938*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFormat Spinel formatter to unpack property value. 939*cfb92d14SAndroid Build Coastguard Worker * @param[out] ... Variable arguments list. 940*cfb92d14SAndroid Build Coastguard Worker * 941*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully got the property. 942*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 943*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 944*cfb92d14SAndroid Build Coastguard Worker * 945*cfb92d14SAndroid Build Coastguard Worker */ 946*cfb92d14SAndroid Build Coastguard Worker otError GetWithParam(spinel_prop_key_t aKey, 947*cfb92d14SAndroid Build Coastguard Worker const uint8_t *aParam, 948*cfb92d14SAndroid Build Coastguard Worker spinel_size_t aParamSize, 949*cfb92d14SAndroid Build Coastguard Worker const char *aFormat, 950*cfb92d14SAndroid Build Coastguard Worker ...); 951*cfb92d14SAndroid Build Coastguard Worker 952*cfb92d14SAndroid Build Coastguard Worker /** 953*cfb92d14SAndroid Build Coastguard Worker * Tries to update a spinel property of OpenThread transceiver. 954*cfb92d14SAndroid Build Coastguard Worker * 955*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKey Spinel property key. 956*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFormat Spinel formatter to pack property value. 957*cfb92d14SAndroid Build Coastguard Worker * @param[in] ... Variable arguments list. 958*cfb92d14SAndroid Build Coastguard Worker * 959*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully set the property. 960*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 961*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 962*cfb92d14SAndroid Build Coastguard Worker * 963*cfb92d14SAndroid Build Coastguard Worker */ 964*cfb92d14SAndroid Build Coastguard Worker otError Set(spinel_prop_key_t aKey, const char *aFormat, ...); 965*cfb92d14SAndroid Build Coastguard Worker 966*cfb92d14SAndroid Build Coastguard Worker /** 967*cfb92d14SAndroid Build Coastguard Worker * Tries to insert a item into a spinel list property of OpenThread transceiver. 968*cfb92d14SAndroid Build Coastguard Worker * 969*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKey Spinel property key. 970*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFormat Spinel formatter to pack the item. 971*cfb92d14SAndroid Build Coastguard Worker * @param[in] ... Variable arguments list. 972*cfb92d14SAndroid Build Coastguard Worker * 973*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully insert item into the property. 974*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 975*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 976*cfb92d14SAndroid Build Coastguard Worker * 977*cfb92d14SAndroid Build Coastguard Worker */ 978*cfb92d14SAndroid Build Coastguard Worker otError Insert(spinel_prop_key_t aKey, const char *aFormat, ...); 979*cfb92d14SAndroid Build Coastguard Worker 980*cfb92d14SAndroid Build Coastguard Worker /** 981*cfb92d14SAndroid Build Coastguard Worker * Tries to remove a item from a spinel list property of OpenThread transceiver. 982*cfb92d14SAndroid Build Coastguard Worker * 983*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKey Spinel property key. 984*cfb92d14SAndroid Build Coastguard Worker * @param[in] aFormat Spinel formatter to pack the item. 985*cfb92d14SAndroid Build Coastguard Worker * @param[in] ... Variable arguments list. 986*cfb92d14SAndroid Build Coastguard Worker * 987*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully removed item from the property. 988*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 989*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 990*cfb92d14SAndroid Build Coastguard Worker * 991*cfb92d14SAndroid Build Coastguard Worker */ 992*cfb92d14SAndroid Build Coastguard Worker otError Remove(spinel_prop_key_t aKey, const char *aFormat, ...); 993*cfb92d14SAndroid Build Coastguard Worker 994*cfb92d14SAndroid Build Coastguard Worker /** 995*cfb92d14SAndroid Build Coastguard Worker * Sends a reset command to the RCP. 996*cfb92d14SAndroid Build Coastguard Worker * 997*cfb92d14SAndroid Build Coastguard Worker * @param[in] aResetType The reset type, SPINEL_RESET_PLATFORM, SPINEL_RESET_STACK, or SPINEL_RESET_BOOTLOADER. 998*cfb92d14SAndroid Build Coastguard Worker * 999*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully sent the reset command. 1000*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 1001*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_CAPABLE Requested reset type is not supported by the co-processor. 1002*cfb92d14SAndroid Build Coastguard Worker * 1003*cfb92d14SAndroid Build Coastguard Worker */ 1004*cfb92d14SAndroid Build Coastguard Worker otError SendReset(uint8_t aResetType); 1005*cfb92d14SAndroid Build Coastguard Worker 1006*cfb92d14SAndroid Build Coastguard Worker /** 1007*cfb92d14SAndroid Build Coastguard Worker * Returns the radio Spinel metrics. 1008*cfb92d14SAndroid Build Coastguard Worker * 1009*cfb92d14SAndroid Build Coastguard Worker * @returns The radio Spinel metrics. 1010*cfb92d14SAndroid Build Coastguard Worker * 1011*cfb92d14SAndroid Build Coastguard Worker */ GetRadioSpinelMetrics(void) const1012*cfb92d14SAndroid Build Coastguard Worker const otRadioSpinelMetrics *GetRadioSpinelMetrics(void) const { return &mRadioSpinelMetrics; } 1013*cfb92d14SAndroid Build Coastguard Worker 1014*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE 1015*cfb92d14SAndroid Build Coastguard Worker /** 1016*cfb92d14SAndroid Build Coastguard Worker * Add a calibrated power of the specified channel to the power calibration table. 1017*cfb92d14SAndroid Build Coastguard Worker * 1018*cfb92d14SAndroid Build Coastguard Worker * @param[in] aChannel The radio channel. 1019*cfb92d14SAndroid Build Coastguard Worker * @param[in] aActualPower The actual power in 0.01dBm. 1020*cfb92d14SAndroid Build Coastguard Worker * @param[in] aRawPowerSetting A pointer to the raw power setting byte array. 1021*cfb92d14SAndroid Build Coastguard Worker * @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting. 1022*cfb92d14SAndroid Build Coastguard Worker * 1023*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully added the calibrated power to the power calibration table. 1024*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NO_BUFS No available entry in the power calibration table. 1025*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS The @p aChannel, @p aActualPower or @p aRawPowerSetting is invalid. 1026*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. 1027*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 1028*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 1029*cfb92d14SAndroid Build Coastguard Worker * 1030*cfb92d14SAndroid Build Coastguard Worker */ 1031*cfb92d14SAndroid Build Coastguard Worker otError AddCalibratedPower(uint8_t aChannel, 1032*cfb92d14SAndroid Build Coastguard Worker int16_t aActualPower, 1033*cfb92d14SAndroid Build Coastguard Worker const uint8_t *aRawPowerSetting, 1034*cfb92d14SAndroid Build Coastguard Worker uint16_t aRawPowerSettingLength); 1035*cfb92d14SAndroid Build Coastguard Worker 1036*cfb92d14SAndroid Build Coastguard Worker /** 1037*cfb92d14SAndroid Build Coastguard Worker * Clear all calibrated powers from the power calibration table. 1038*cfb92d14SAndroid Build Coastguard Worker * 1039*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully cleared all calibrated powers from the power calibration table. 1040*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. 1041*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 1042*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 1043*cfb92d14SAndroid Build Coastguard Worker * 1044*cfb92d14SAndroid Build Coastguard Worker */ 1045*cfb92d14SAndroid Build Coastguard Worker otError ClearCalibratedPowers(void); 1046*cfb92d14SAndroid Build Coastguard Worker 1047*cfb92d14SAndroid Build Coastguard Worker /** 1048*cfb92d14SAndroid Build Coastguard Worker * Set the target power for the given channel. 1049*cfb92d14SAndroid Build Coastguard Worker * 1050*cfb92d14SAndroid Build Coastguard Worker * @param[in] aChannel The radio channel. 1051*cfb92d14SAndroid Build Coastguard Worker * @param[in] aTargetPower The target power in 0.01dBm. Passing `INT16_MAX` will disable this channel. 1052*cfb92d14SAndroid Build Coastguard Worker * 1053*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NONE Successfully set the target power. 1054*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_INVALID_ARGS The @p aChannel or @p aTargetPower is invalid.. 1055*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. 1056*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_BUSY Failed due to another operation is on going. 1057*cfb92d14SAndroid Build Coastguard Worker * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the transceiver. 1058*cfb92d14SAndroid Build Coastguard Worker * 1059*cfb92d14SAndroid Build Coastguard Worker */ 1060*cfb92d14SAndroid Build Coastguard Worker otError SetChannelTargetPower(uint8_t aChannel, int16_t aTargetPower); 1061*cfb92d14SAndroid Build Coastguard Worker #endif 1062*cfb92d14SAndroid Build Coastguard Worker 1063*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 1064*cfb92d14SAndroid Build Coastguard Worker /** 1065*cfb92d14SAndroid Build Coastguard Worker * Restore the properties of Radio Co-processor (RCP). 1066*cfb92d14SAndroid Build Coastguard Worker * 1067*cfb92d14SAndroid Build Coastguard Worker */ 1068*cfb92d14SAndroid Build Coastguard Worker void RestoreProperties(void); 1069*cfb92d14SAndroid Build Coastguard Worker #endif 1070*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1071*cfb92d14SAndroid Build Coastguard Worker /** 1072*cfb92d14SAndroid Build Coastguard Worker * Defines a vendor "set property handler" hook to process vendor spinel properties. 1073*cfb92d14SAndroid Build Coastguard Worker * 1074*cfb92d14SAndroid Build Coastguard Worker * The vendor handler should return `OT_ERROR_NOT_FOUND` status if it does not support "set" operation for the 1075*cfb92d14SAndroid Build Coastguard Worker * given property key. Otherwise, the vendor handler should behave like other property set handlers, i.e., it 1076*cfb92d14SAndroid Build Coastguard Worker * should first decode the value from the input spinel frame and then perform the corresponding set operation. The 1077*cfb92d14SAndroid Build Coastguard Worker * handler should not prepare the spinel response and therefore should not write anything to the NCP buffer. The 1078*cfb92d14SAndroid Build Coastguard Worker * `otError` returned from handler (other than `OT_ERROR_NOT_FOUND`) indicates the error in either parsing of the 1079*cfb92d14SAndroid Build Coastguard Worker * input or the error of the set operation. In case of a successful "set", `NcpBase` set command handler will call 1080*cfb92d14SAndroid Build Coastguard Worker * the `VendorGetPropertyHandler()` for the same property key to prepare the response. 1081*cfb92d14SAndroid Build Coastguard Worker * 1082*cfb92d14SAndroid Build Coastguard Worker * @param[in] aPropKey The spinel property key. 1083*cfb92d14SAndroid Build Coastguard Worker * 1084*cfb92d14SAndroid Build Coastguard Worker * @returns OT_ERROR_NOT_FOUND if it does not support the given property key, otherwise the error in either parsing 1085*cfb92d14SAndroid Build Coastguard Worker * of the input or the "set" operation. 1086*cfb92d14SAndroid Build Coastguard Worker * 1087*cfb92d14SAndroid Build Coastguard Worker */ 1088*cfb92d14SAndroid Build Coastguard Worker otError VendorHandleValueIs(spinel_prop_key_t aPropKey); 1089*cfb92d14SAndroid Build Coastguard Worker 1090*cfb92d14SAndroid Build Coastguard Worker /** 1091*cfb92d14SAndroid Build Coastguard Worker * A callback type for restoring vendor properties. 1092*cfb92d14SAndroid Build Coastguard Worker * 1093*cfb92d14SAndroid Build Coastguard Worker */ 1094*cfb92d14SAndroid Build Coastguard Worker typedef void (*otRadioSpinelVendorRestorePropertiesCallback)(void *context); 1095*cfb92d14SAndroid Build Coastguard Worker 1096*cfb92d14SAndroid Build Coastguard Worker /** 1097*cfb92d14SAndroid Build Coastguard Worker * Registers a callback to restore vendor properties. 1098*cfb92d14SAndroid Build Coastguard Worker * 1099*cfb92d14SAndroid Build Coastguard Worker * This function is used to register a callback for vendor properties recovery. When an event which needs to restore 1100*cfb92d14SAndroid Build Coastguard Worker * properties occurs (such as an unexpected RCP reset), the user can restore the vendor properties via the callback. 1101*cfb92d14SAndroid Build Coastguard Worker * 1102*cfb92d14SAndroid Build Coastguard Worker * @param[in] aCallback The callback. 1103*cfb92d14SAndroid Build Coastguard Worker * @param[in] aContext The context. 1104*cfb92d14SAndroid Build Coastguard Worker * 1105*cfb92d14SAndroid Build Coastguard Worker */ 1106*cfb92d14SAndroid Build Coastguard Worker void SetVendorRestorePropertiesCallback(otRadioSpinelVendorRestorePropertiesCallback aCallback, void *aContext); 1107*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1108*cfb92d14SAndroid Build Coastguard Worker 1109*cfb92d14SAndroid Build Coastguard Worker /** 1110*cfb92d14SAndroid Build Coastguard Worker * Enables or disables the time synchronization between the host and RCP. 1111*cfb92d14SAndroid Build Coastguard Worker * 1112*cfb92d14SAndroid Build Coastguard Worker * @param[in] aOn TRUE to turn on the time synchronization, FALSE otherwise. 1113*cfb92d14SAndroid Build Coastguard Worker * 1114*cfb92d14SAndroid Build Coastguard Worker */ SetTimeSyncState(bool aOn)1115*cfb92d14SAndroid Build Coastguard Worker void SetTimeSyncState(bool aOn) { mTimeSyncOn = aOn; } 1116*cfb92d14SAndroid Build Coastguard Worker 1117*cfb92d14SAndroid Build Coastguard Worker private: 1118*cfb92d14SAndroid Build Coastguard Worker enum 1119*cfb92d14SAndroid Build Coastguard Worker { 1120*cfb92d14SAndroid Build Coastguard Worker kMaxWaitTime = 2000, ///< Max time to wait for response in milliseconds. 1121*cfb92d14SAndroid Build Coastguard Worker kVersionStringSize = 128, ///< Max size of version string. 1122*cfb92d14SAndroid Build Coastguard Worker kCapsBufferSize = 100, ///< Max buffer size used to store `SPINEL_PROP_CAPS` value. 1123*cfb92d14SAndroid Build Coastguard Worker kChannelMaskBufferSize = 32, ///< Max buffer size used to store `SPINEL_PROP_PHY_CHAN_SUPPORTED` value. 1124*cfb92d14SAndroid Build Coastguard Worker }; 1125*cfb92d14SAndroid Build Coastguard Worker 1126*cfb92d14SAndroid Build Coastguard Worker enum State 1127*cfb92d14SAndroid Build Coastguard Worker { 1128*cfb92d14SAndroid Build Coastguard Worker kStateDisabled, ///< Radio is disabled. 1129*cfb92d14SAndroid Build Coastguard Worker kStateSleep, ///< Radio is sleep. 1130*cfb92d14SAndroid Build Coastguard Worker kStateReceive, ///< Radio is in receive mode. 1131*cfb92d14SAndroid Build Coastguard Worker kStateTransmitting, ///< Frame passed to radio for transmission, waiting for done event from radio. 1132*cfb92d14SAndroid Build Coastguard Worker kStateTransmitDone, ///< Radio indicated frame transmission is done. 1133*cfb92d14SAndroid Build Coastguard Worker }; 1134*cfb92d14SAndroid Build Coastguard Worker 1135*cfb92d14SAndroid Build Coastguard Worker static constexpr uint32_t kUsPerMs = 1000; ///< Microseconds per millisecond. 1136*cfb92d14SAndroid Build Coastguard Worker static constexpr uint32_t kMsPerSec = 1000; ///< Milliseconds per second. 1137*cfb92d14SAndroid Build Coastguard Worker static constexpr uint32_t kUsPerSec = kUsPerMs * kMsPerSec; ///< Microseconds per second. 1138*cfb92d14SAndroid Build Coastguard Worker static constexpr uint64_t kTxWaitUs = 1139*cfb92d14SAndroid Build Coastguard Worker OPENTHREAD_SPINEL_CONFIG_RCP_TX_WAIT_TIME_SECS * 1140*cfb92d14SAndroid Build Coastguard Worker kUsPerSec; ///< Maximum time of waiting for `TransmitDone` event, in microseconds. 1141*cfb92d14SAndroid Build Coastguard Worker 1142*cfb92d14SAndroid Build Coastguard Worker typedef otError (RadioSpinel::*ResponseHandler)(const uint8_t *aBuffer, uint16_t aLength); 1143*cfb92d14SAndroid Build Coastguard Worker 1144*cfb92d14SAndroid Build Coastguard Worker SpinelDriver &GetSpinelDriver(void) const; 1145*cfb92d14SAndroid Build Coastguard Worker 1146*cfb92d14SAndroid Build Coastguard Worker otError CheckSpinelVersion(void); 1147*cfb92d14SAndroid Build Coastguard Worker otError CheckRadioCapabilities(otRadioCaps aRequiredRadioCaps); 1148*cfb92d14SAndroid Build Coastguard Worker otError CheckRcpApiVersion(bool aSupportsRcpApiVersion, bool aSupportsRcpMinHostApiVersion); 1149*cfb92d14SAndroid Build Coastguard Worker void InitializeCaps(bool &aSupportsRcpApiVersion, bool &aSupportsRcpMinHostApiVersion); 1150*cfb92d14SAndroid Build Coastguard Worker 1151*cfb92d14SAndroid Build Coastguard Worker /** 1152*cfb92d14SAndroid Build Coastguard Worker * Triggers a state transfer of the state machine. 1153*cfb92d14SAndroid Build Coastguard Worker * 1154*cfb92d14SAndroid Build Coastguard Worker */ 1155*cfb92d14SAndroid Build Coastguard Worker void ProcessRadioStateMachine(void); 1156*cfb92d14SAndroid Build Coastguard Worker 1157*cfb92d14SAndroid Build Coastguard Worker /** 1158*cfb92d14SAndroid Build Coastguard Worker * Processes the frame queue. 1159*cfb92d14SAndroid Build Coastguard Worker * 1160*cfb92d14SAndroid Build Coastguard Worker */ 1161*cfb92d14SAndroid Build Coastguard Worker void ProcessFrameQueue(void); 1162*cfb92d14SAndroid Build Coastguard Worker 1163*cfb92d14SAndroid Build Coastguard Worker spinel_tid_t GetNextTid(void); FreeTid(spinel_tid_t tid)1164*cfb92d14SAndroid Build Coastguard Worker void FreeTid(spinel_tid_t tid) { mCmdTidsInUse &= ~(1 << tid); } 1165*cfb92d14SAndroid Build Coastguard Worker 1166*cfb92d14SAndroid Build Coastguard Worker otError RequestV(uint32_t aCommand, spinel_prop_key_t aKey, const char *aFormat, va_list aArgs); 1167*cfb92d14SAndroid Build Coastguard Worker otError Request(uint32_t aCommand, spinel_prop_key_t aKey, const char *aFormat, ...); 1168*cfb92d14SAndroid Build Coastguard Worker otError RequestWithPropertyFormat(const char *aPropertyFormat, 1169*cfb92d14SAndroid Build Coastguard Worker uint32_t aCommand, 1170*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t aKey, 1171*cfb92d14SAndroid Build Coastguard Worker const char *aFormat, 1172*cfb92d14SAndroid Build Coastguard Worker ...); 1173*cfb92d14SAndroid Build Coastguard Worker otError RequestWithPropertyFormatV(const char *aPropertyFormat, 1174*cfb92d14SAndroid Build Coastguard Worker uint32_t aCommand, 1175*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t aKey, 1176*cfb92d14SAndroid Build Coastguard Worker const char *aFormat, 1177*cfb92d14SAndroid Build Coastguard Worker va_list aArgs); 1178*cfb92d14SAndroid Build Coastguard Worker otError RequestWithExpectedCommandV(uint32_t aExpectedCommand, 1179*cfb92d14SAndroid Build Coastguard Worker uint32_t aCommand, 1180*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t aKey, 1181*cfb92d14SAndroid Build Coastguard Worker const char *aFormat, 1182*cfb92d14SAndroid Build Coastguard Worker va_list aArgs); 1183*cfb92d14SAndroid Build Coastguard Worker otError WaitResponse(bool aHandleRcpTimeout = true); 1184*cfb92d14SAndroid Build Coastguard Worker otError ParseRadioFrame(otRadioFrame &aFrame, const uint8_t *aBuffer, uint16_t aLength, spinel_ssize_t &aUnpacked); 1185*cfb92d14SAndroid Build Coastguard Worker 1186*cfb92d14SAndroid Build Coastguard Worker /** 1187*cfb92d14SAndroid Build Coastguard Worker * Returns if the property changed event is safe to be handled now. 1188*cfb92d14SAndroid Build Coastguard Worker * 1189*cfb92d14SAndroid Build Coastguard Worker * If a property handler will go up to core stack, it may cause reentrant issue of `Hdlc::Decode()` and 1190*cfb92d14SAndroid Build Coastguard Worker * `WaitResponse()`. 1191*cfb92d14SAndroid Build Coastguard Worker * 1192*cfb92d14SAndroid Build Coastguard Worker * @param[in] aKey The identifier of the property. 1193*cfb92d14SAndroid Build Coastguard Worker * 1194*cfb92d14SAndroid Build Coastguard Worker * @returns Whether this property is safe to be handled now. 1195*cfb92d14SAndroid Build Coastguard Worker * 1196*cfb92d14SAndroid Build Coastguard Worker */ IsSafeToHandleNow(spinel_prop_key_t aKey) const1197*cfb92d14SAndroid Build Coastguard Worker bool IsSafeToHandleNow(spinel_prop_key_t aKey) const 1198*cfb92d14SAndroid Build Coastguard Worker { 1199*cfb92d14SAndroid Build Coastguard Worker return !(aKey == SPINEL_PROP_STREAM_RAW || aKey == SPINEL_PROP_MAC_ENERGY_SCAN_RESULT); 1200*cfb92d14SAndroid Build Coastguard Worker } 1201*cfb92d14SAndroid Build Coastguard Worker 1202*cfb92d14SAndroid Build Coastguard Worker void HandleNotification(const uint8_t *aFrame, uint16_t aLength, bool &aShouldSaveFrame); 1203*cfb92d14SAndroid Build Coastguard Worker void HandleNotification(const uint8_t *aFrame, uint16_t aLength); 1204*cfb92d14SAndroid Build Coastguard Worker void HandleValueIs(spinel_prop_key_t aKey, const uint8_t *aBuffer, uint16_t aLength); 1205*cfb92d14SAndroid Build Coastguard Worker 1206*cfb92d14SAndroid Build Coastguard Worker void HandleResponse(const uint8_t *aBuffer, uint16_t aLength); 1207*cfb92d14SAndroid Build Coastguard Worker void HandleTransmitDone(uint32_t aCommand, spinel_prop_key_t aKey, const uint8_t *aBuffer, uint16_t aLength); 1208*cfb92d14SAndroid Build Coastguard Worker void HandleWaitingResponse(uint32_t aCommand, spinel_prop_key_t aKey, const uint8_t *aBuffer, uint16_t aLength); 1209*cfb92d14SAndroid Build Coastguard Worker 1210*cfb92d14SAndroid Build Coastguard Worker void RadioReceive(void); 1211*cfb92d14SAndroid Build Coastguard Worker 1212*cfb92d14SAndroid Build Coastguard Worker void TransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError); 1213*cfb92d14SAndroid Build Coastguard Worker 1214*cfb92d14SAndroid Build Coastguard Worker void CalcRcpTimeOffset(void); 1215*cfb92d14SAndroid Build Coastguard Worker 1216*cfb92d14SAndroid Build Coastguard Worker void HandleRcpUnexpectedReset(spinel_status_t aStatus); 1217*cfb92d14SAndroid Build Coastguard Worker void HandleRcpTimeout(void); 1218*cfb92d14SAndroid Build Coastguard Worker void RecoverFromRcpFailure(void); 1219*cfb92d14SAndroid Build Coastguard Worker 1220*cfb92d14SAndroid Build Coastguard Worker static void HandleReceivedFrame(const uint8_t *aFrame, 1221*cfb92d14SAndroid Build Coastguard Worker uint16_t aLength, 1222*cfb92d14SAndroid Build Coastguard Worker uint8_t aHeader, 1223*cfb92d14SAndroid Build Coastguard Worker bool &aSave, 1224*cfb92d14SAndroid Build Coastguard Worker void *aContext); 1225*cfb92d14SAndroid Build Coastguard Worker void HandleReceivedFrame(const uint8_t *aFrame, uint16_t aLength, uint8_t aHeader, bool &aShouldSaveFrame); 1226*cfb92d14SAndroid Build Coastguard Worker static void HandleSavedFrame(const uint8_t *aFrame, uint16_t aLength, void *aContext); 1227*cfb92d14SAndroid Build Coastguard Worker void HandleSavedFrame(const uint8_t *aFrame, uint16_t aLength); 1228*cfb92d14SAndroid Build Coastguard Worker UpdateParseErrorCount(otError aError)1229*cfb92d14SAndroid Build Coastguard Worker void UpdateParseErrorCount(otError aError) 1230*cfb92d14SAndroid Build Coastguard Worker { 1231*cfb92d14SAndroid Build Coastguard Worker mRadioSpinelMetrics.mSpinelParseErrorCount += (aError == OT_ERROR_PARSE) ? 1 : 0; 1232*cfb92d14SAndroid Build Coastguard Worker } 1233*cfb92d14SAndroid Build Coastguard Worker 1234*cfb92d14SAndroid Build Coastguard Worker otError SetMacKey(uint8_t aKeyIdMode, 1235*cfb92d14SAndroid Build Coastguard Worker uint8_t aKeyId, 1236*cfb92d14SAndroid Build Coastguard Worker const otMacKey &aPrevKey, 1237*cfb92d14SAndroid Build Coastguard Worker const otMacKey &aCurrKey, 1238*cfb92d14SAndroid Build Coastguard Worker const otMacKey &NextKey); 1239*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE 1240*cfb92d14SAndroid Build Coastguard Worker static otError ReadMacKey(const otMacKeyMaterial &aKeyMaterial, otMacKey &aKey); 1241*cfb92d14SAndroid Build Coastguard Worker #endif 1242*cfb92d14SAndroid Build Coastguard Worker 1243*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 1244*cfb92d14SAndroid Build Coastguard Worker void PlatDiagOutput(const char *aFormat, ...); 1245*cfb92d14SAndroid Build Coastguard Worker #endif 1246*cfb92d14SAndroid Build Coastguard Worker 1247*cfb92d14SAndroid Build Coastguard Worker otInstance *mInstance; 1248*cfb92d14SAndroid Build Coastguard Worker 1249*cfb92d14SAndroid Build Coastguard Worker RadioSpinelCallbacks mCallbacks; ///< Callbacks for notifications of higher layer. 1250*cfb92d14SAndroid Build Coastguard Worker 1251*cfb92d14SAndroid Build Coastguard Worker uint16_t mCmdTidsInUse; ///< Used transaction ids. 1252*cfb92d14SAndroid Build Coastguard Worker spinel_tid_t mCmdNextTid; ///< Next available transaction id. 1253*cfb92d14SAndroid Build Coastguard Worker spinel_tid_t mTxRadioTid; ///< The transaction id used to send a radio frame. 1254*cfb92d14SAndroid Build Coastguard Worker spinel_tid_t mWaitingTid; ///< The transaction id of current transaction. 1255*cfb92d14SAndroid Build Coastguard Worker spinel_prop_key_t mWaitingKey; ///< The property key of current transaction. 1256*cfb92d14SAndroid Build Coastguard Worker const char *mPropertyFormat; ///< The spinel property format of current transaction. 1257*cfb92d14SAndroid Build Coastguard Worker va_list mPropertyArgs; ///< The arguments pack or unpack spinel property of current transaction. 1258*cfb92d14SAndroid Build Coastguard Worker uint32_t mExpectedCommand; ///< Expected response command of current transaction. 1259*cfb92d14SAndroid Build Coastguard Worker otError mError; ///< The result of current transaction. 1260*cfb92d14SAndroid Build Coastguard Worker uint8_t mRxPsdu[OT_RADIO_FRAME_MAX_SIZE]; 1261*cfb92d14SAndroid Build Coastguard Worker uint8_t mTxPsdu[OT_RADIO_FRAME_MAX_SIZE]; 1262*cfb92d14SAndroid Build Coastguard Worker uint8_t mAckPsdu[OT_RADIO_FRAME_MAX_SIZE]; 1263*cfb92d14SAndroid Build Coastguard Worker otRadioFrame mRxRadioFrame; 1264*cfb92d14SAndroid Build Coastguard Worker otRadioFrame mTxRadioFrame; 1265*cfb92d14SAndroid Build Coastguard Worker otRadioFrame mAckRadioFrame; 1266*cfb92d14SAndroid Build Coastguard Worker otRadioFrame *mTransmitFrame; ///< Points to the frame to send 1267*cfb92d14SAndroid Build Coastguard Worker 1268*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT && OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 1269*cfb92d14SAndroid Build Coastguard Worker otRadioIeInfo mTxIeInfo; 1270*cfb92d14SAndroid Build Coastguard Worker #endif 1271*cfb92d14SAndroid Build Coastguard Worker 1272*cfb92d14SAndroid Build Coastguard Worker otExtAddress mExtendedAddress; 1273*cfb92d14SAndroid Build Coastguard Worker uint16_t mShortAddress; 1274*cfb92d14SAndroid Build Coastguard Worker uint16_t mPanId; 1275*cfb92d14SAndroid Build Coastguard Worker uint8_t mChannel; 1276*cfb92d14SAndroid Build Coastguard Worker int8_t mRxSensitivity; 1277*cfb92d14SAndroid Build Coastguard Worker otError mTxError; 1278*cfb92d14SAndroid Build Coastguard Worker static otExtAddress sIeeeEui64; 1279*cfb92d14SAndroid Build Coastguard Worker static otRadioCaps sRadioCaps; 1280*cfb92d14SAndroid Build Coastguard Worker uint32_t mBusLatency; 1281*cfb92d14SAndroid Build Coastguard Worker 1282*cfb92d14SAndroid Build Coastguard Worker State mState; 1283*cfb92d14SAndroid Build Coastguard Worker bool mIsPromiscuous : 1; ///< Promiscuous mode. 1284*cfb92d14SAndroid Build Coastguard Worker bool mRxOnWhenIdle : 1; ///< RxOnWhenIdle mode. 1285*cfb92d14SAndroid Build Coastguard Worker bool mIsTimeSynced : 1; ///< Host has calculated the time difference between host and RCP. 1286*cfb92d14SAndroid Build Coastguard Worker 1287*cfb92d14SAndroid Build Coastguard Worker static bool sSupportsLogStream; ///< RCP supports `LOG_STREAM` property with OpenThread log meta-data format. 1288*cfb92d14SAndroid Build Coastguard Worker static bool sSupportsResetToBootloader; ///< RCP supports resetting into bootloader mode. 1289*cfb92d14SAndroid Build Coastguard Worker static bool sSupportsLogCrashDump; ///< RCP supports logging a crash dump. 1290*cfb92d14SAndroid Build Coastguard Worker 1291*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 1292*cfb92d14SAndroid Build Coastguard Worker 1293*cfb92d14SAndroid Build Coastguard Worker enum 1294*cfb92d14SAndroid Build Coastguard Worker { 1295*cfb92d14SAndroid Build Coastguard Worker kRcpFailureNone, 1296*cfb92d14SAndroid Build Coastguard Worker kRcpFailureTimeout, 1297*cfb92d14SAndroid Build Coastguard Worker kRcpFailureUnexpectedReset, 1298*cfb92d14SAndroid Build Coastguard Worker }; 1299*cfb92d14SAndroid Build Coastguard Worker 1300*cfb92d14SAndroid Build Coastguard Worker bool mResetRadioOnStartup : 1; ///< Whether should send reset command when init. 1301*cfb92d14SAndroid Build Coastguard Worker int16_t mRcpFailureCount; ///< Count of consecutive RCP failures. 1302*cfb92d14SAndroid Build Coastguard Worker uint8_t mRcpFailure : 2; ///< RCP failure reason, should recover and retry operation. 1303*cfb92d14SAndroid Build Coastguard Worker 1304*cfb92d14SAndroid Build Coastguard Worker // Properties set by core. 1305*cfb92d14SAndroid Build Coastguard Worker uint8_t mKeyIdMode; 1306*cfb92d14SAndroid Build Coastguard Worker uint8_t mKeyId; 1307*cfb92d14SAndroid Build Coastguard Worker otMacKey mPrevKey; 1308*cfb92d14SAndroid Build Coastguard Worker otMacKey mCurrKey; 1309*cfb92d14SAndroid Build Coastguard Worker otMacKey mNextKey; 1310*cfb92d14SAndroid Build Coastguard Worker uint16_t mSrcMatchShortEntries[OPENTHREAD_CONFIG_MLE_MAX_CHILDREN]; 1311*cfb92d14SAndroid Build Coastguard Worker int16_t mSrcMatchShortEntryCount; 1312*cfb92d14SAndroid Build Coastguard Worker otExtAddress mSrcMatchExtEntries[OPENTHREAD_CONFIG_MLE_MAX_CHILDREN]; 1313*cfb92d14SAndroid Build Coastguard Worker int16_t mSrcMatchExtEntryCount; 1314*cfb92d14SAndroid Build Coastguard Worker uint8_t mScanChannel; 1315*cfb92d14SAndroid Build Coastguard Worker uint16_t mScanDuration; 1316*cfb92d14SAndroid Build Coastguard Worker int8_t mCcaEnergyDetectThreshold; 1317*cfb92d14SAndroid Build Coastguard Worker int8_t mTransmitPower; 1318*cfb92d14SAndroid Build Coastguard Worker int8_t mFemLnaGain; 1319*cfb92d14SAndroid Build Coastguard Worker bool mCoexEnabled : 1; 1320*cfb92d14SAndroid Build Coastguard Worker bool mSrcMatchEnabled : 1; 1321*cfb92d14SAndroid Build Coastguard Worker 1322*cfb92d14SAndroid Build Coastguard Worker bool mMacKeySet : 1; ///< Whether MAC key has been set. 1323*cfb92d14SAndroid Build Coastguard Worker bool mCcaEnergyDetectThresholdSet : 1; ///< Whether CCA energy detect threshold has been set. 1324*cfb92d14SAndroid Build Coastguard Worker bool mTransmitPowerSet : 1; ///< Whether transmit power has been set. 1325*cfb92d14SAndroid Build Coastguard Worker bool mCoexEnabledSet : 1; ///< Whether coex enabled has been set. 1326*cfb92d14SAndroid Build Coastguard Worker bool mFemLnaGainSet : 1; ///< Whether FEM LNA gain has been set. 1327*cfb92d14SAndroid Build Coastguard Worker bool mEnergyScanning : 1; ///< If fails while scanning, restarts scanning. 1328*cfb92d14SAndroid Build Coastguard Worker bool mMacFrameCounterSet : 1; ///< Whether the MAC frame counter has been set. 1329*cfb92d14SAndroid Build Coastguard Worker bool mSrcMatchSet : 1; ///< Whether the source match feature has been set. 1330*cfb92d14SAndroid Build Coastguard Worker 1331*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 1332*cfb92d14SAndroid Build Coastguard Worker 1333*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_CONFIG_DIAG_ENABLE 1334*cfb92d14SAndroid Build Coastguard Worker bool mDiagMode; 1335*cfb92d14SAndroid Build Coastguard Worker otPlatDiagOutputCallback mOutputCallback; 1336*cfb92d14SAndroid Build Coastguard Worker void *mOutputContext; 1337*cfb92d14SAndroid Build Coastguard Worker #endif 1338*cfb92d14SAndroid Build Coastguard Worker 1339*cfb92d14SAndroid Build Coastguard Worker uint64_t mTxRadioEndUs; 1340*cfb92d14SAndroid Build Coastguard Worker uint64_t mRadioTimeRecalcStart; ///< When to recalculate RCP time offset. 1341*cfb92d14SAndroid Build Coastguard Worker uint64_t mRadioTimeOffset; ///< Time difference with estimated RCP time minus host time. 1342*cfb92d14SAndroid Build Coastguard Worker 1343*cfb92d14SAndroid Build Coastguard Worker MaxPowerTable mMaxPowerTable; 1344*cfb92d14SAndroid Build Coastguard Worker 1345*cfb92d14SAndroid Build Coastguard Worker otRadioSpinelMetrics mRadioSpinelMetrics; 1346*cfb92d14SAndroid Build Coastguard Worker 1347*cfb92d14SAndroid Build Coastguard Worker #if OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1348*cfb92d14SAndroid Build Coastguard Worker otRadioSpinelVendorRestorePropertiesCallback mVendorRestorePropertiesCallback; 1349*cfb92d14SAndroid Build Coastguard Worker void *mVendorRestorePropertiesContext; 1350*cfb92d14SAndroid Build Coastguard Worker #endif 1351*cfb92d14SAndroid Build Coastguard Worker 1352*cfb92d14SAndroid Build Coastguard Worker bool mTimeSyncEnabled : 1; 1353*cfb92d14SAndroid Build Coastguard Worker bool mTimeSyncOn : 1; 1354*cfb92d14SAndroid Build Coastguard Worker 1355*cfb92d14SAndroid Build Coastguard Worker SpinelDriver *mSpinelDriver; 1356*cfb92d14SAndroid Build Coastguard Worker }; 1357*cfb92d14SAndroid Build Coastguard Worker 1358*cfb92d14SAndroid Build Coastguard Worker } // namespace Spinel 1359*cfb92d14SAndroid Build Coastguard Worker } // namespace ot 1360*cfb92d14SAndroid Build Coastguard Worker 1361*cfb92d14SAndroid Build Coastguard Worker #endif // RADIO_SPINEL_HPP_ 1362