Hi, I tested "Simple_coap_client" and "simple_coap_server" on NRF52840 using Threading SDK.
I want to change the transmit power, so I used "otPlatRadioSetTransmitPower ()".
The power consumption and communication distance were measured, but there was no change.
This is my code.
How do I use "otPlatRadioSetTransmitPower ()"?
I'm sorry in poor English.
void thread_coap_utils_multicast_light_request_send(uint8_t command,
thread_coap_utils_multicast_scope_t scope)
{
NRF_LOG_INFO("thread_coap_utils_multicast_light_request_send");
otError error = OT_ERROR_NONE;
otMessage * p_request;
otMessageInfo message_info;
const char * p_scope = NULL;
otInstance * p_instance = thread_ot_instance_get();
int8_t TX_power = 8;
char *send_data = "hello world";
do
{
p_request = otCoapNewMessage(p_instance, NULL);
if (p_request == NULL)
{
NRF_LOG_INFO("Failed to allocate message for CoAP Request\r\n");
break;
}
otCoapMessageInit(p_request, OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_PUT);
error = otCoapMessageAppendUriPathOptions(p_request, "light");
ASSERT(error == OT_ERROR_NONE);
error = otCoapMessageSetPayloadMarker(p_request);
ASSERT(error == OT_ERROR_NONE);
error = otMessageAppend(p_request, send_data, 12);
//NRF_LOG_INFO("send_data : %s", send_data);
if (error != OT_ERROR_NONE)
{
break;
}
switch (scope)
{
case THREAD_COAP_UTILS_MULTICAST_LINK_LOCAL:
p_scope = "ff02::1";
break;
case THREAD_COAP_UTILS_MULTICAST_REALM_LOCAL:
p_scope = "ff03::1";
break;
default:
ASSERT(false);
}
memset(&message_info, 0, sizeof(message_info));
message_info.mPeerPort = OT_DEFAULT_COAP_PORT;
error = otIp6AddressFromString(p_scope, &message_info.mPeerAddr);
ASSERT(error == OT_ERROR_NONE);
error = otPlatRadioSetTransmitPower(p_instance, TX_power);
NRF_LOG_INFO("error: %d", error);
error = otCoapSendRequest(p_instance, p_request, &message_info, NULL, NULL);
} while (false);
if (error != OT_ERROR_NONE && p_request != NULL)
{
NRF_LOG_INFO("Failed to send CoAP Request: %d\r\n", error);
otMessageFree(p_request);
}
}