Hi Jonathan,
Thanks for answering my questions. Actually, my coap server needs to both send and receive coap packages. The nrf52840 coap server needs to send a registration package to the cloud server first, then I can receive a reply package from the cloud. So, I can confirm that the whole network is working. Previously, you suggested me to capturing packets on both the wpan0 interface as well as a sniffer packet capture from the Thread network.
This picture is the captured packages, you can see the first and second packages is the interaction between the cloud server and nrf52840 coap server. nrf52840 coap server address is fd11:22::2d65:6cbb:4e63:ef8. I think the nrf52840 coap server should receive this package. The last package is the one that sent from the cloud to the coap server.
Here is my code extract:
static otCoapResource m_property_set_request_resource =
{
.mUriPath = "/$sys/CxD2hb4NHT/tttt/thing/property/set",
.mHandler = property_set_request_handler,
.mContext = NULL,
.mNext = NULL
};
static void thread_coap_init(void)
{
thread_coap_utils_configuration_t thread_coap_configuration =
{
.coap_server_enabled = true,
.coap_client_enabled = true,
.configurable_led_blinking_enabled = false,
};
thread_coap_utils_init(&thread_coap_configuration);
}
void thread_coap_utils_init(const thread_coap_utils_configuration_t * p_config)
{
otInstance * p_instance = thread_ot_instance_get();
otError error = otCoapStart(p_instance, OT_DEFAULT_COAP_PORT);
ASSERT(error == OT_ERROR_NONE);
otCoapSetDefaultHandler(p_instance, coap_default_handler, NULL);
m_config = *p_config;
m_light_command_handler = light_changed_default;
if (m_config.coap_server_enabled)
{
retval = app_timer_create(&m_provisioning_timer,
APP_TIMER_MODE_SINGLE_SHOT,
provisioning_timer_handler);
ASSERT(retval == NRF_SUCCESS);
m_light_resource.mContext = p_instance;
m_property_set_request_resource.mContext = p_instance;
error = otCoapAddResource(p_instance, &m_light_resource);
ASSERT(error == OT_ERROR_NONE);
error = otCoapAddResource(p_instance, &m_property_set_request_resource);
ASSERT(error == OT_ERROR_NONE);
}
}
static void property_set_request_handler(void * p_context,
otMessage * p_message,
const otMessageInfo * p_message_info)
{
printf("property_set_request_handler\n");
}
The function property_set_request_handler is not called.
Is there some problems with my code that caused the received coap package handle improperly?
Best,
tao