|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Nordic Semiconductor ASA |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * @file |
| 9 | + * This file implements the OpenThread platform abstraction |
| 10 | + * for radio communication utilizing nRF IEEE802.15.4 radio driver. |
| 11 | + * |
| 12 | + */ |
| 13 | + |
| 14 | +#include <openthread/error.h> |
| 15 | +#define LOG_MODULE_NAME net_otPlat_radio |
| 16 | + |
| 17 | +#include <zephyr/logging/log.h> |
| 18 | +LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_L2_LOG_LEVEL); |
| 19 | + |
| 20 | +#include <zephyr/kernel.h> |
| 21 | +#include <zephyr/device.h> |
| 22 | +#include <zephyr/sys/__assert.h> |
| 23 | + |
| 24 | +#include <openthread/ip6.h> |
| 25 | +#include <openthread-system.h> |
| 26 | +#include <openthread/instance.h> |
| 27 | +#include <openthread/platform/radio.h> |
| 28 | +#include <openthread/platform/diag.h> |
| 29 | +#include <openthread/platform/time.h> |
| 30 | +#include <openthread/message.h> |
| 31 | +#if defined(CONFIG_OPENTHREAD_NAT64_TRANSLATOR) |
| 32 | +#include <openthread/nat64.h> |
| 33 | +#endif |
| 34 | + |
| 35 | +#include "nrf_802154.h" |
| 36 | +#include "nrf_802154_const.h" |
| 37 | + |
| 38 | +/******************************************************/ |
| 39 | +/* TODO: To remove once L2 layer dependency is removed */ |
| 40 | +#include <zephyr/net/ieee802154_radio.h> |
| 41 | +/******************************************************/ |
| 42 | + |
| 43 | +/* Notifications, init, process and other functions required by platform.c */ |
| 44 | + |
| 45 | +int notify_new_rx_frame(struct net_pkt *pkt) |
| 46 | +{ |
| 47 | +} |
| 48 | + |
| 49 | +int notify_new_tx_frame(struct net_pkt *pkt) |
| 50 | +{ |
| 51 | +} |
| 52 | + |
| 53 | +void platformRadioInit(void) |
| 54 | +{ |
| 55 | +} |
| 56 | + |
| 57 | +void platformRadioProcess(otInstance *aInstance) |
| 58 | +{ |
| 59 | +} |
| 60 | + |
| 61 | +uint16_t platformRadioChannelGet(otInstance *aInstance) |
| 62 | +{ |
| 63 | +} |
| 64 | + |
| 65 | +#if defined(CONFIG_OPENTHREAD_DIAG) |
| 66 | +void platformRadioChannelSet(uint8_t aChannel) |
| 67 | +{ |
| 68 | +} |
| 69 | +#endif |
| 70 | + |
| 71 | +/* Radio configuration */ |
| 72 | + |
| 73 | +otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) |
| 74 | +{ |
| 75 | +} |
| 76 | + |
| 77 | +const char *otPlatRadioGetVersionString(otInstance *aInstance) |
| 78 | +{ |
| 79 | +} |
| 80 | + |
| 81 | +int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) |
| 82 | +{ |
| 83 | +} |
| 84 | + |
| 85 | +/* TODO: This function is implemented in zephyr/subsys/net/l2/openthread, so we must remove that |
| 86 | + * dependency first and then implement this one |
| 87 | + */ |
| 88 | + |
| 89 | + /* |
| 90 | +void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) |
| 91 | +{ |
| 92 | +} |
| 93 | +*/ |
| 94 | + |
| 95 | +void otPlatRadioSetPanId(otInstance *aInstance, otPanId aPanId) |
| 96 | +{ |
| 97 | +} |
| 98 | + |
| 99 | +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) |
| 100 | +{ |
| 101 | +} |
| 102 | + |
| 103 | +void otPlatRadioSetShortAddress(otInstance *aInstance, otShortAddress aShortAddress) |
| 104 | +{ |
| 105 | +} |
| 106 | + |
| 107 | +otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) |
| 108 | +{ |
| 109 | +} |
| 110 | + |
| 111 | +otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) |
| 112 | +{ |
| 113 | +} |
| 114 | + |
| 115 | +otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold) |
| 116 | +{ |
| 117 | +} |
| 118 | + |
| 119 | +otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold) |
| 120 | +{ |
| 121 | +} |
| 122 | + |
| 123 | +otError otPlatRadioGetFemLnaGain(otInstance *aInstance, int8_t *aGain) |
| 124 | +{ |
| 125 | +} |
| 126 | + |
| 127 | +otError otPlatRadioSetFemLnaGain(otInstance *aInstance, int8_t aGain) |
| 128 | +{ |
| 129 | +} |
| 130 | + |
| 131 | +bool otPlatRadioGetPromiscuous(otInstance *aInstance) |
| 132 | +{ |
| 133 | +} |
| 134 | + |
| 135 | +void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) |
| 136 | +{ |
| 137 | +} |
| 138 | + |
| 139 | +void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable) |
| 140 | +{ |
| 141 | +} |
| 142 | + |
| 143 | +void otPlatRadioSetMacKey(otInstance *aInstance, uint8_t aKeyIdMode, uint8_t aKeyId, |
| 144 | + const otMacKeyMaterial *aPrevKey, const otMacKeyMaterial *aCurrKey, |
| 145 | + const otMacKeyMaterial *aNextKey, otRadioKeyType aKeyType) |
| 146 | +{ |
| 147 | +} |
| 148 | + |
| 149 | +void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter) |
| 150 | +{ |
| 151 | +} |
| 152 | + |
| 153 | +void otPlatRadioSetMacFrameCounterIfLarger(otInstance *aInstance, uint32_t aMacFrameCounter) |
| 154 | +{ |
| 155 | +} |
| 156 | + |
| 157 | +/* Radio operations */ |
| 158 | + |
| 159 | +uint64_t otPlatRadioGetNow(otInstance *aInstance) |
| 160 | +{ |
| 161 | +} |
| 162 | + |
| 163 | +uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance) |
| 164 | +{ |
| 165 | +} |
| 166 | + |
| 167 | +uint32_t otPlatRadioGetBusLatency(otInstance *aInstance) |
| 168 | +{ |
| 169 | +} |
| 170 | + |
| 171 | +otRadioState otPlatRadioGetState(otInstance *aInstance) |
| 172 | +{ |
| 173 | +} |
| 174 | + |
| 175 | +otError otPlatRadioEnable(otInstance *aInstance) |
| 176 | +{ |
| 177 | +} |
| 178 | + |
| 179 | +otError otPlatRadioDisable(otInstance *aInstance) |
| 180 | +{ |
| 181 | +} |
| 182 | + |
| 183 | +bool otPlatRadioIsEnabled(otInstance *aInstance) |
| 184 | +{ |
| 185 | +} |
| 186 | + |
| 187 | +otError otPlatRadioSleep(otInstance *aInstance) |
| 188 | +{ |
| 189 | +} |
| 190 | + |
| 191 | +otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) |
| 192 | +{ |
| 193 | +} |
| 194 | + |
| 195 | +otError otPlatRadioReceiveAt(otInstance *aInstance, uint8_t aChannel, uint32_t aStart, |
| 196 | + uint32_t aDuration) |
| 197 | +{ |
| 198 | +} |
| 199 | + |
| 200 | +otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) |
| 201 | +{ |
| 202 | +} |
| 203 | + |
| 204 | +otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) |
| 205 | +{ |
| 206 | +} |
| 207 | + |
| 208 | +int8_t otPlatRadioGetRssi(otInstance *aInstance) |
| 209 | +{ |
| 210 | +} |
| 211 | + |
| 212 | +otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) |
| 213 | +{ |
| 214 | +} |
| 215 | + |
| 216 | +void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) |
| 217 | +{ |
| 218 | +} |
| 219 | + |
| 220 | +otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, otShortAddress aShortAddress) |
| 221 | +{ |
| 222 | +} |
| 223 | + |
| 224 | +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) |
| 225 | +{ |
| 226 | +} |
| 227 | + |
| 228 | +otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, otShortAddress aShortAddress) |
| 229 | +{ |
| 230 | +} |
| 231 | + |
| 232 | +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) |
| 233 | +{ |
| 234 | +} |
| 235 | + |
| 236 | +void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) |
| 237 | +{ |
| 238 | +} |
| 239 | + |
| 240 | +void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) |
| 241 | +{ |
| 242 | +} |
| 243 | + |
| 244 | +uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance) |
| 245 | +{ |
| 246 | +} |
| 247 | + |
| 248 | +uint32_t otPlatRadioGetPreferredChannelMask(otInstance *aInstance) |
| 249 | +{ |
| 250 | +} |
| 251 | + |
| 252 | +otError otPlatRadioSetCoexEnabled(otInstance *aInstance, bool aEnabled) |
| 253 | +{ |
| 254 | +} |
| 255 | + |
| 256 | +bool otPlatRadioIsCoexEnabled(otInstance *aInstance) |
| 257 | +{ |
| 258 | +} |
| 259 | + |
| 260 | +otError otPlatRadioGetCoexMetrics(otInstance *aInstance, otRadioCoexMetrics *aCoexMetrics) |
| 261 | +{ |
| 262 | +} |
| 263 | + |
| 264 | +otError otPlatRadioEnableCsl(otInstance *aInstance, uint32_t aCslPeriod, otShortAddress aShortAddr, |
| 265 | + const otExtAddress *aExtAddr) |
| 266 | +{ |
| 267 | +} |
| 268 | + |
| 269 | +otError otPlatRadioResetCsl(otInstance *aInstance) |
| 270 | +{ |
| 271 | +} |
| 272 | + |
| 273 | +void otPlatRadioUpdateCslSampleTime(otInstance *aInstance, uint32_t aCslSampleTime) |
| 274 | +{ |
| 275 | +} |
| 276 | + |
| 277 | +uint8_t otPlatRadioGetCslAccuracy(otInstance *aInstance) |
| 278 | +{ |
| 279 | +} |
| 280 | + |
| 281 | +uint8_t otPlatRadioGetCslUncertainty(otInstance *aInstance) |
| 282 | +{ |
| 283 | +} |
| 284 | + |
| 285 | +otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aChannel, |
| 286 | + int8_t aMaxPower) |
| 287 | +{ |
| 288 | +} |
| 289 | + |
| 290 | +otError otPlatRadioSetRegion(otInstance *aInstance, uint16_t aRegionCode) |
| 291 | +{ |
| 292 | +} |
| 293 | + |
| 294 | +otError otPlatRadioGetRegion(otInstance *aInstance, uint16_t *aRegionCode) |
| 295 | +{ |
| 296 | +} |
| 297 | + |
| 298 | +otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance, otLinkMetrics aLinkMetrics, |
| 299 | + otShortAddress aShortAddress, |
| 300 | + const otExtAddress *aExtAddress) |
| 301 | +{ |
| 302 | +} |
| 303 | + |
| 304 | +otError otPlatRadioAddCalibratedPower(otInstance *aInstance, uint8_t aChannel, int16_t aActualPower, |
| 305 | + const uint8_t *aRawPowerSetting, |
| 306 | + uint16_t aRawPowerSettingLength) |
| 307 | +{ |
| 308 | +} |
| 309 | + |
| 310 | +otError otPlatRadioClearCalibratedPowers(otInstance *aInstance) |
| 311 | +{ |
| 312 | +} |
| 313 | + |
| 314 | +otError otPlatRadioSetChannelTargetPower(otInstance *aInstance, uint8_t aChannel, |
| 315 | + int16_t aTargetPower) |
| 316 | +{ |
| 317 | +} |
| 318 | + |
| 319 | +/* Platform related */ |
| 320 | + |
| 321 | +#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS) |
| 322 | +otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable) |
| 323 | +{ |
| 324 | +} |
| 325 | + |
| 326 | +otError platformRadioTransmitModulatedCarrier(otInstance *aInstance, bool aEnable, |
| 327 | + const uint8_t *aData) |
| 328 | +{ |
| 329 | +} |
| 330 | + |
| 331 | +#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */ |
| 332 | + |
| 333 | +/********************************************************************************/ |
| 334 | +/* TODO: These functions are redundant because they're used by Zephyr L2 layer. |
| 335 | + * For now let's keep them here to allow building the project without failure. |
| 336 | + * Once L2 dependency is removed, we can remove these functions as well. |
| 337 | + */ |
| 338 | + |
| 339 | +enum net_verdict ieee802154_handle_ack(struct net_if *iface, struct net_pkt *pkt) |
| 340 | +{ |
| 341 | +} |
| 342 | + |
| 343 | +/********************************************************************************/ |
0 commit comments