net: lwm2m: Remove lwm2m_send_message() from public API
lwm2m_send_message() sends a message directly to the socket. Remove the function from public API and combine the code with socket_send_message(). Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
This commit is contained in:
parent
fd9902be2d
commit
1111184b74
3 changed files with 27 additions and 32 deletions
|
@ -633,14 +633,40 @@ static int socket_recv_message(struct lwm2m_ctx *client_ctx)
|
|||
|
||||
static int socket_send_message(struct lwm2m_ctx *client_ctx)
|
||||
{
|
||||
int rc;
|
||||
sys_snode_t *msg_node = sys_slist_get(&client_ctx->pending_sends);
|
||||
struct lwm2m_message *msg;
|
||||
|
||||
if (!msg_node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
msg = SYS_SLIST_CONTAINER(msg_node, msg, node);
|
||||
return lwm2m_send_message(msg);
|
||||
if (!msg || !msg->ctx) {
|
||||
LOG_ERR("LwM2M message is invalid.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->type == COAP_TYPE_CON) {
|
||||
coap_pending_cycle(msg->pending);
|
||||
}
|
||||
|
||||
rc = zsock_send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0);
|
||||
|
||||
if (rc < 0) {
|
||||
LOG_ERR("Failed to send packet, err %d", errno);
|
||||
if (msg->type != COAP_TYPE_CON) {
|
||||
lwm2m_reset_message(msg, true);
|
||||
}
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (msg->type != COAP_TYPE_CON) {
|
||||
lwm2m_reset_message(msg, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void socket_reset_pollfd_events(void)
|
||||
|
|
|
@ -441,36 +441,6 @@ int lwm2m_information_interface_send(struct lwm2m_message *msg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lwm2m_send_message(struct lwm2m_message *msg)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!msg || !msg->ctx) {
|
||||
LOG_ERR("LwM2M message is invalid.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->type == COAP_TYPE_CON) {
|
||||
coap_pending_cycle(msg->pending);
|
||||
}
|
||||
|
||||
rc = zsock_send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0);
|
||||
|
||||
if (rc < 0) {
|
||||
LOG_ERR("Failed to send packet, err %d", errno);
|
||||
if (msg->type != COAP_TYPE_CON) {
|
||||
lwm2m_reset_message(msg, true);
|
||||
}
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (msg->type != COAP_TYPE_CON) {
|
||||
lwm2m_reset_message(msg, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lwm2m_send_empty_ack(struct lwm2m_ctx *client_ctx, uint16_t mid)
|
||||
{
|
||||
struct lwm2m_message *msg;
|
||||
|
|
|
@ -42,7 +42,6 @@ struct lwm2m_message *find_msg(struct coap_pending *pending, struct coap_reply *
|
|||
void lwm2m_reset_message(struct lwm2m_message *msg, bool release);
|
||||
void lm2m_message_clear_allocations(struct lwm2m_message *msg);
|
||||
int lwm2m_init_message(struct lwm2m_message *msg);
|
||||
int lwm2m_send_message(struct lwm2m_message *msg);
|
||||
int lwm2m_send_message_async(struct lwm2m_message *msg);
|
||||
|
||||
int handle_request(struct coap_packet *request, struct lwm2m_message *msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue