net: mqtt: Refactor because of timeout overhaul

Align MQTT with timeout API changes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-04-07 14:52:58 +02:00 committed by Jukka Rissanen
commit 073ec8d4aa
6 changed files with 10 additions and 10 deletions

View file

@ -419,7 +419,7 @@ struct mqtt_transport {
/** Socket descriptor */
int sock;
/** Websocket timeout */
/** Websocket timeout, in milliseconds. */
s32_t timeout;
} websocket;
#endif

View file

@ -337,7 +337,7 @@ static void client_init(struct mqtt_client *client)
client->transport.websocket.config.tmp_buf = temp_ws_rx_buf;
client->transport.websocket.config.tmp_buf_len =
sizeof(temp_ws_rx_buf);
client->transport.websocket.timeout = K_SECONDS(5);
client->transport.websocket.timeout = 5 * MSEC_PER_SEC;
#endif
#if defined(CONFIG_SOCKS)
@ -360,7 +360,7 @@ static int try_to_connect(struct mqtt_client *client)
rc = mqtt_connect(client);
if (rc != 0) {
PRINT_RESULT("mqtt_connect", rc);
k_sleep(APP_SLEEP_MSECS);
k_sleep(K_MSEC(APP_SLEEP_MSECS));
continue;
}

View file

@ -96,7 +96,7 @@ int mqtt_client_websocket_write(struct mqtt_client *client, const u8_t *data,
ret = websocket_send_msg(client->transport.websocket.sock,
data + offset, datalen - offset,
WEBSOCKET_OPCODE_DATA_BINARY,
true, true, K_FOREVER);
true, true, NET_WAIT_FOREVER);
if (ret < 0) {
return -errno;
}
@ -125,7 +125,7 @@ int mqtt_client_websocket_write_msg(struct mqtt_client *client,
ret = websocket_send_msg(client->transport.websocket.sock,
message->msg_iov[i].iov_base,
message->msg_iov[i].iov_len, opcode,
true, final, K_FOREVER);
true, final, NET_WAIT_FOREVER);
if (ret < 0) {
return ret;
}
@ -140,12 +140,12 @@ int mqtt_client_websocket_write_msg(struct mqtt_client *client,
int mqtt_client_websocket_read(struct mqtt_client *client, u8_t *data,
u32_t buflen, bool shall_block)
{
s32_t timeout = K_FOREVER;
s32_t timeout = NET_WAIT_FOREVER;
u32_t message_type = 0U;
int ret;
if (!shall_block) {
timeout = K_NO_WAIT;
timeout = 0;
}
ret = websocket_recv_msg(client->transport.websocket.sock,

View file

@ -209,7 +209,7 @@ static int try_to_connect(struct mqtt_client *client)
rc = mqtt_connect(client);
if (rc != 0) {
k_sleep(APP_SLEEP_MSECS);
k_sleep(K_MSEC(APP_SLEEP_MSECS));
continue;
}

View file

@ -280,7 +280,7 @@ static int try_to_connect(struct mqtt_client *client)
rc = mqtt_connect(client);
if (rc != 0) {
k_sleep(APP_SLEEP_MSECS);
k_sleep(K_MSEC(APP_SLEEP_MSECS));
continue;
}

View file

@ -206,7 +206,7 @@ static int try_to_connect(struct mqtt_client *client)
rc = mqtt_connect(client);
if (rc != 0) {
k_sleep(APP_SLEEP_MSECS);
k_sleep(K_MSEC(APP_SLEEP_MSECS));
continue;
}