Hi,
I am using the nxp_ot_cli sample with some of my customizations. Here is main() below. I also added vendor hook for the SPINEL_PROP_VENDOR_NXP_GET_SET_TXPOWERLIMIT_CMD callback from spinel.
I added this for modules/openthread/platform/radio_spinel.cpp
+otError otPlatRadioGetVendorMaxTransmitPower(otInstance *aInstance, uint8_t *aPower)
+{
+ otError error;
+
+ OT_UNUSED_VARIABLE(aInstance);
+
+ if (psRadioSpinel == NULL)
+ {
+ otLogWarnPlat("psRadioSpinel for max tx get is null");
+ return OT_ERROR_GENERIC;
+ }
+
+ VerifyOrExit(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
+ error = psRadioSpinel->GetVendorMaxTransmitPower(*aPower);
+
+exit:
+ return error;
+}
+
+otError otPlatRadioSetVendorMaxTransmitPower(otInstance *aInstance, uint8_t aPower)
+{
+ if (psRadioSpinel == NULL)
+ {
+ otLogWarnPlat("psRadioSpinel for set max Tx power is null");
+ return OT_ERROR_GENERIC;
+ }
+
+ OT_UNUSED_VARIABLE(aInstance);
+ return psRadioSpinel->SetVendorMaxTransmitPower(aPower);
+}
+
The openthread module was modified to support hte vendor hook.
modified: include/openthread/platform/radio.h
modified: src/lib/spinel/CMakeLists.txt
modified: src/lib/spinel/radio_spinel.cpp
modified: src/lib/spinel/radio_spinel.hpp
modified: src/lib/spinel/spinel.h
modified: src/lib/spinel/spinel_driver.cpp
This was added to spinel.h.
SPINEL_PROP_VENDOR_NXP_GET_SET_TXPOWERLIMIT_CMD = (SPINEL_PROP_VENDOR__BEGIN + 0x10B),
int main(void)
{
LOG_INF("nxp_ot_cli entry");
k_sleep(K_MSEC(500));
ot_context = openthread_get_default_context();
__ASSERT(ot_context != NULL, "Fatal: OpenThread context not available!");
ot_instance = openthread_get_default_instance();
__ASSERT(ot_instance != NULL, "Fatal: OpenThread instance not available!");
LOG_INF("Setting openthread leader weight");
otThreadSetLocalLeaderWeight(ot_instance, 2);
LOG_INF("Done setting leaderweight");
k_sleep(K_MSEC(500));
LOG_INF("Setting openthread radio max transmit power to 12/2 dBm ...");
otError err1 = otPlatRadioSetVendorMaxTransmitPower(ot_instance, 12);
LOG_INF("Set openthread radio max transmit power: %s (err=%d)", otThreadErrorToString(err1), err1);
k_sleep(K_MSEC(500));
uint8_t aPower = 0;
LOG_INF("Getting openthread radio transmit power ...");
otError err2 = otPlatRadioGetVendorMaxTransmitPower(ot_instance, &aPower);
if ((aPower % 2 == 0))
{
LOG_INF("Getting openthread radio transmit power is %u or %u.0 dBm, %s (err=%d)", aPower, aPower/2, otThreadErrorToString(err2), err2);
}
else
{
LOG_INF("Getting openthread radio transmit power is %u or %u.5 dBm, %s (err=%d)", aPower, aPower/2, otThreadErrorToString(err2), err2);
}
//LOG_INF("Loop now");
while (1)
{
LOG_INF("Loop now");
k_sleep(K_MSEC(1000));
}
return 0;
}