Skip to content

Commit 241369d

Browse files
committed
openthread: Add Kconfigs for packet TX time and carrier functions
Add new Kconfig options to enable platform-specific features in OpenThread: - CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME enables support for packet TX time when CONFIG_NET_PKT_TXTIME is selected. - CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS enables modulated and continuous carrier functions when CONFIG_OPENTHREAD_DIAG and CONFIG_IEEE802154_CARRIER_FUNCTIONS are enabled. Update preprocessor conditionals to use the new options instead of relying directly on CONFIG_NET_PKT_TXTIME and CONFIG_IEEE802154_CARRIER_FUNCTIONS. This change improves configurability and allows to reuse the platform implementation when not using Zephyr networking. Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
1 parent 2bb7fcc commit 241369d

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

modules/openthread/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,19 @@ config OPENTHREAD_INTERFACE_EARLY_UP
337337
Otherwise, OpenThread interface will be marked operational UP only
338338
after the device joins a Thread network.
339339

340+
config OPENTHREAD_PLATFORM_PKT_TXTIME
341+
bool
342+
default y if NET_PKT_TXTIME
343+
help
344+
Enable packet TX time support. This is needed for when the application
345+
wants to set the exact time when the packet should be sent.
346+
347+
config OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS
348+
bool
349+
default y if OPENTHREAD_DIAG && IEEE802154_CARRIER_FUNCTIONS
350+
help
351+
Enable support for functions such as modulated carrier and continuous carrier.
352+
340353
menu "OpenThread stack features"
341354
rsource "Kconfig.features"
342355
endmenu

modules/openthread/platform/alarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ K_TIMER_DEFINE(ot_us_timer, ot_timer_us_fired, NULL);
5050

5151
void platformAlarmInit(void)
5252
{
53-
#if defined(CONFIG_NET_PKT_TXTIME)
53+
#if defined(CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME)
5454
time_offset_us =
5555
(int32_t)((int64_t)otPlatAlarmMicroGetNow() - (uint32_t)otPlatRadioGetNow(NULL));
5656
time_offset_ms = time_offset_us / 1000;

modules/openthread/platform/diag.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ static uint32_t sTxPeriod = 1;
3737
static int32_t sTxCount;
3838
static int32_t sTxRequestedCount = 1;
3939

40+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS)
4041
static otError startModCarrier(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[]);
42+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
43+
4144
static otError processTransmit(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[]);
4245

4346
static otError parse_long(char *aArgs, long *aValue)
@@ -72,11 +75,11 @@ void otPlatDiagSetOutputCallback(otInstance *aInstance,
7275

7376
otError otPlatDiagProcess(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[])
7477
{
75-
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
78+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS)
7679
if (strcmp(aArgs[0], "modcarrier") == 0) {
7780
return startModCarrier(aInstance, aArgsLength - 1, aArgs + 1);
7881
}
79-
#endif
82+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
8083

8184
if (strcmp(aArgs[0], "transmit") == 0) {
8285
return processTransmit(aInstance, aArgsLength - 1, aArgs + 1);
@@ -128,7 +131,7 @@ void otPlatDiagRadioReceived(otInstance *aInstance,
128131
ARG_UNUSED(aError);
129132
}
130133

131-
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
134+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS)
132135
otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
133136
{
134137
if (sTransmitMode != DIAG_TRANSMIT_MODE_IDLE &&
@@ -144,7 +147,7 @@ otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
144147

145148
return platformRadioTransmitCarrier(aInstance, aEnable);
146149
}
147-
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
150+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
148151

149152
/*
150153
* To enable gpio diag commands, in Devicetree create `openthread` node in `/options/` path
@@ -317,7 +320,7 @@ otError otPlatDiagGpioGetMode(uint32_t aGpio, otGpioMode *aMode)
317320
* DT_NODE_HAS_PROP(DT_COMPAT_GET_ANY_STATUS_OKAY(openthread_config), diag_gpios)
318321
*/
319322

320-
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
323+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS)
321324

322325
static otError startModCarrier(otInstance *aInstance, uint8_t aArgsLength, char *aArgs[])
323326
{
@@ -346,7 +349,7 @@ static otError startModCarrier(otInstance *aInstance, uint8_t aArgsLength, char
346349
return platformRadioTransmitModulatedCarrier(aInstance, enable, data);
347350
}
348351

349-
#endif
352+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
350353

351354
void otPlatDiagAlarmCallback(otInstance *aInstance)
352355
{

modules/openthread/platform/platform-zephyr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,20 @@ uint16_t platformRadioChannelGet(otInstance *aInstance);
8080
void platformRadioChannelSet(uint8_t aChannel);
8181
#endif /* CONFIG_OPENTHREAD_DIAG */
8282

83-
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
83+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS)
8484
/**
8585
* Start/stop continuous carrier wave transmission.
8686
*/
8787
otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable);
88-
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
88+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
8989

90-
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
90+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS )
9191
/**
9292
* Start/stop modulated carrier wave transmission.
9393
*/
9494
otError platformRadioTransmitModulatedCarrier(otInstance *aInstance, bool aEnable,
9595
const uint8_t *aData);
96-
#endif
96+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
9797

9898
/**
9999
* This function initializes the random number service used by OpenThread.

modules/openthread/platform/radio.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void handle_radio_event(const struct device *dev, enum ieee802154_event evt,
244244
}
245245
}
246246

247-
#if defined(CONFIG_NET_PKT_TXTIME) || defined(CONFIG_OPENTHREAD_CSL_RECEIVER)
247+
#if defined(CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME) || defined(CONFIG_OPENTHREAD_CSL_RECEIVER)
248248
/**
249249
* @brief Convert 32-bit (potentially wrapped) OpenThread microsecond timestamps
250250
* to 64-bit Zephyr network subsystem nanosecond timestamps.
@@ -320,7 +320,7 @@ static net_time_t convert_32bit_us_wrapped_to_64bit_ns(uint32_t target_time_us_w
320320
__ASSERT_NO_MSG(result <= INT64_MAX / NSEC_PER_USEC);
321321
return (net_time_t)result * NSEC_PER_USEC;
322322
}
323-
#endif /* CONFIG_NET_PKT_TXTIME || CONFIG_OPENTHREAD_CSL_RECEIVER */
323+
#endif /* CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME || CONFIG_OPENTHREAD_CSL_RECEIVER */
324324

325325
static void dataInit(void)
326326
{
@@ -416,7 +416,7 @@ void transmit_message(struct k_work *tx_job)
416416

417417
if ((radio_caps & IEEE802154_HW_TXTIME) &&
418418
(sTransmitFrame.mInfo.mTxInfo.mTxDelay != 0)) {
419-
#if defined(CONFIG_NET_PKT_TXTIME)
419+
#if defined(CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME)
420420
uint32_t tx_at = sTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime +
421421
sTransmitFrame.mInfo.mTxInfo.mTxDelay;
422422
net_pkt_set_timestamp_ns(tx_pkt, convert_32bit_us_wrapped_to_64bit_ns(tx_at));
@@ -833,7 +833,7 @@ otError otPlatRadioReceiveAt(otInstance *aInstance, uint8_t aChannel,
833833
}
834834
#endif
835835

836-
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
836+
#if defined(CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS)
837837
otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
838838
{
839839
if (radio_api->continuous_carrier == NULL) {
@@ -884,7 +884,7 @@ otError platformRadioTransmitModulatedCarrier(otInstance *aInstance, bool aEnabl
884884
return OT_ERROR_NONE;
885885
}
886886

887-
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
887+
#endif /* CONFIG_OPENTHREAD_PLATFORM_CARRIER_FUNCTIONS */
888888

889889
otRadioState otPlatRadioGetState(otInstance *aInstance)
890890
{
@@ -998,7 +998,7 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
998998
}
999999
#endif
10001000

1001-
#if defined(CONFIG_NET_PKT_TXTIME)
1001+
#if defined(CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME)
10021002
if (radio_caps & IEEE802154_HW_TXTIME) {
10031003
caps |= OT_RADIO_CAPS_TRANSMIT_TIMING;
10041004
}
@@ -1263,7 +1263,7 @@ uint64_t otPlatTimeGet(void)
12631263
}
12641264
}
12651265

1266-
#if defined(CONFIG_NET_PKT_TXTIME)
1266+
#if defined(CONFIG_OPENTHREAD_PLATFORM_PKT_TXTIME)
12671267
uint64_t otPlatRadioGetNow(otInstance *aInstance)
12681268
{
12691269
ARG_UNUSED(aInstance);

0 commit comments

Comments
 (0)