I'm trying to run a coap_client example to send i2c data but getting this error code over console while running the build.
I'm trying to run a coap_client example to send i2c data but getting this error code over console while running the build.
Hi,
You request is lacking a lot of information.
Best regards,
Jørgen
im using nrf connect sdk version 2.1.0,
the function is the handler for sending the message.
yep even after removing the modifications it gives me the error.
Can you provide the exact line and function call that returns the error?
Can you provide exact steps to reproduce?
sure,
btw i noticed one thing when i put ot ifconfig up in the console the error goes away,
but the message shows undelivered with error code 28. Here's the code which produces the mentioned error code.
static void coap_send_data_request(void){
otError error = OT_ERROR_NONE;
otMessage * myMessage ;
otMessageInfo myMessageInfo;
otInstance * myInstance = openthread_get_default_instance();
const otMeshLocalPrefix *ml_prefix = otThreadGetMeshLocalPrefix(myInstance);
uint8_t interfaceID[8]= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02};
const char * myMPUJson = data2;
/* const char * serverIpAddr = "fdde:ad00:beef:0:0:0:0:1"; */
do{
//Create a new message
myMessage = otCoapNewMessage(myInstance, NULL);
if (myMessage == NULL) {
printk("Failed to allocate message for CoAP Request\r\n");
return;
}
//Set CoAP type and code in the message
otCoapMessageInit(myMessage, OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_PUT);
//Add the URI path option in the message
error = otCoapMessageAppendUriPathOptions(myMessage, "storedata");
if (error != OT_ERROR_NONE){ break; }
//Add the content format option in the message
error = otCoapMessageAppendContentFormatOption(myMessage, OT_COAP_OPTION_CONTENT_FORMAT_JSON );
if (error != OT_ERROR_NONE){ break; }
//Set the payload delimiter in the message
error = otCoapMessageSetPayloadMarker(myMessage);
if (error != OT_ERROR_NONE){ break; }
///Append the payload to the message
error = otMessageAppend(myMessage, myMPUJson, strlen(myMPUJson));
if (error != OT_ERROR_NONE){ break; }
memset(&myMessageInfo, 0, sizeof(myMessageInfo));
memcpy(&myMessageInfo.mPeerAddr.mFields.m8[0], ml_prefix, 8);
memcpy(&myMessageInfo.mPeerAddr.mFields.m8[8], interfaceID, 8);
/* error = otIp6AddressFromString(serverIpAddr, &myMessageInfo.mPeerAddr);
if (error != OT_ERROR_NONE){ break; } */
myMessageInfo.mPeerPort = OT_DEFAULT_COAP_PORT;
//Send CoAP-request
error = otCoapSendRequest(myInstance, myMessage, &myMessageInfo, coap_send_data_response_cb, NULL);
}while(false);
if (error != OT_ERROR_NONE) {
printk("Failed to send CoAP Request: %d\r\n", error);
otMessageFree(myMessage);
}else{
printk("CoAP data send.\n");
}
}
here's the code that produces error code 20 with message "delivery not confirmed"
static void coap_send_data_response_cb(void * p_context, otMessage * p_message,
const otMessageInfo * p_message_info, otError result){
if (result == OT_ERROR_NONE) {
printk("Delivery confirmed.\n");
} else {
printk("Delivery not confirmed: %d\n", result);
}
}
From what I can see in the OpenThread source code, the error comes from the following:
* @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address.
Can you capture a sniffer trace of the on-air packets when you run this code? Does it send any packets?
Do you have a node in the Thread network with the given peer address?