board : nRF9160DK
SDK : nrf connect SDK v1.5.0
sample : \v1.5.0\nrf\samples\nrf9160\lwm2m_client
Hi, i am testing lwm2m_client example and
Q1. i dont know how to add data in payload field.
i used 2 functions coap_packet_append_payload_marker, coap_packet_append_payload
- coap packet below
time => 20210422180918256
type => coapRequest
mid => 6671
method => POST
uri => ...
options => {...}
payload => null <---- here
- source below
static int sm_send_bootstrap_registration(void)
{
struct lwm2m_message *msg;
int ret;
msg = lwm2m_get_message(client.ctx);
if (!msg)
{
LOG_ERR("Unable to get a lwm2m message!");
return -ENOMEM;
}
msg->type = COAP_TYPE_CON;
msg->code = COAP_METHOD_POST;
msg->mid = coap_next_id();
msg->tkl = LWM2M_MSG_TOKEN_GENERATE_NEW;
msg->reply_cb = do_bootstrap_reply_cb;
msg->message_timeout_cb = do_bootstrap_reg_timeout_cb;
ret = lwm2m_init_message(msg);
if (ret)
{
goto cleanup;
}
/* TODO: handle return error */
coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH,
"bs", strlen("bs"));
snprintk(query_buffer, sizeof(query_buffer) - 1, "ep=%s",
client.ep_name);
/* TODO: handle return error */
coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_QUERY,
query_buffer, strlen(query_buffer));
// here is my code
coap_packet_append_payload_marker(&msg->cpkt);
coap_packet_append_payload(&msg->cpkt, "hello", 2);
/* log the bootstrap attempt */
LOG_DBG("Register ID with bootstrap server as '%s'",
log_strdup(query_buffer));
ret = lwm2m_send_message(msg);
if (ret < 0)
{
LOG_ERR("Error sending LWM2M packet (err:%d).",
ret);
goto cleanup;
}
return 0;
cleanup:
lwm2m_reset_message(msg, true);
return ret;
}
Q2. is there any lwm2m bootloader at command ?
in case BG96(quectel LTE chip), there is at command like "AT+QLWM2M="mbsps...""
