MQTTClient select timeout cleanup (closes #123)

Also sets example task priorities to maximum 2, as higher priorities
seem to mess with the network stack.
This commit is contained in:
Angus Gratton 2016-05-28 16:21:53 +10:00
parent 0734fa4166
commit 9b21c54fc5
2 changed files with 6 additions and 8 deletions

View file

@ -216,6 +216,6 @@ void user_init(void)
vSemaphoreCreateBinary(wifi_alive); vSemaphoreCreateBinary(wifi_alive);
publish_queue = xQueueCreate(3, PUB_MSG_LEN); publish_queue = xQueueCreate(3, PUB_MSG_LEN);
xTaskCreate(&wifi_task, (int8_t *)"wifi_task", 256, NULL, 2, NULL); xTaskCreate(&wifi_task, (int8_t *)"wifi_task", 256, NULL, 2, NULL);
xTaskCreate(&beat_task, (int8_t *)"beat_task", 256, NULL, 3, NULL); xTaskCreate(&beat_task, (int8_t *)"beat_task", 256, NULL, 2, NULL);
xTaskCreate(&mqtt_task, (int8_t *)"mqtt_task", 1024, NULL, 4, NULL); xTaskCreate(&mqtt_task, (int8_t *)"mqtt_task", 1024, NULL, 2, NULL);
} }

View file

@ -72,9 +72,8 @@ int mqtt_esp_read(Network* n, unsigned char* buffer, int len, int timeout_ms)
int rcvd = 0; int rcvd = 0;
FD_ZERO(&fdset); FD_ZERO(&fdset);
FD_SET(n->my_socket, &fdset); FD_SET(n->my_socket, &fdset);
// It seems tv_sec actually means FreeRTOS tick tv.tv_sec = timeout_ms / 1000;
tv.tv_sec = timeout_ms / portTICK_RATE_MS; tv.tv_usec = (timeout_ms % 1000) * 1000;
tv.tv_usec = 0;
rc = select(n->my_socket + 1, &fdset, 0, 0, &tv); rc = select(n->my_socket + 1, &fdset, 0, 0, &tv);
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset))) if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
{ {
@ -97,9 +96,8 @@ int mqtt_esp_write(Network* n, unsigned char* buffer, int len, int timeout_ms)
FD_ZERO(&fdset); FD_ZERO(&fdset);
FD_SET(n->my_socket, &fdset); FD_SET(n->my_socket, &fdset);
// It seems tv_sec actually means FreeRTOS tick tv.tv_sec = timeout_ms / 1000;
tv.tv_sec = timeout_ms / portTICK_RATE_MS; tv.tv_usec = (timeout_ms % 1000) * 1000;
tv.tv_usec = 0;
rc = select(n->my_socket + 1, 0, &fdset, 0, &tv); rc = select(n->my_socket + 1, 0, &fdset, 0, &tv);
if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset))) if ((rc > 0) && (FD_ISSET(n->my_socket, &fdset)))
{ {