Sending payload to AWS IOT using MQTT causes an error
Posted: Tue Aug 14, 2018 9:38 am
I have been trying to send sensor readings that I have gathered on a spiffs file using the subscribe publish example. AWS docs say that the maximum size for the payload is 128kb. When I try to send the default message "hello from ESP32 (QOS0) : 0" in the example it gets posted just fine and I can see messages in my IoT console. But when I try to send my own chars it exits with the error
My code for the aws_iot_task(void *param) is pretty much the same as the example with the slight variation in the payload area
and my call to this function in app_main() is
What am I doing wrong here?
Code: Select all
I (42606) mbedtls: ssl_tls.c:2616 ssl->f_recv(_timeout)() returned -26624 (-0x6800)
W (42609) mbedtls: ssl_tls.c:4134 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)
W (42618) mbedtls: ssl_tls.c:3998 mbedtls_ssl_read_record_layer() returned -26624 (-0x6800)
W (42627) mbedtls: ssl_tls.c:7205 mbedtls_ssl_read_record() returned -26624 (-0x6800)
I (42636) Example: Stack remaining for task 'aws_iot_task' is 892 bytes
Payload sent to AWS IOT: 32768, +0.00, +0.00, +0.00, +0.00, +0.00, +0.00
32769, +0.00, +0.00, +0.00, +0.00, +0.00, +0.00
32770, +0.00, +0.00, +0.00, +0.00, +0.00, +0.00
32830, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
32832, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
32833, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
32836, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
32837, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
32840, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
32841, +0.42, -0.04, +0.91, -8.97, +3.01, -21.68
Size of: 4
E (43679) Example: An error occurred in the main loop.
abort() was called at PC 0x400d341b on core 0
My code for the aws_iot_task(void *param) is pretty much the same as the example with the slight variation in the payload area
Code: Select all
while((NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc)) {
//Max time the yield function will wait for read messages
rc = aws_iot_mqtt_yield(&client, 100);
if(NETWORK_ATTEMPTING_RECONNECT == rc) {
// If the client is attempting to reconnect we will skip the rest of the loop.
continue;
}
ESP_LOGI(TAG, "Stack remaining for task '%s' is %d bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));
vTaskDelay(1000 / portTICK_RATE_MS);
// sprintf(cPayload, "%s : %d ", "hello from ESP32 (QOS0)", i++);
char *payload = (char*)param;
printf("Payload sent to AWS IOT: %s", payload);
printf("Size of: %i/n", sizeof(payload));
sprintf(cPayload, "%s", payload);
paramsQOS0.payloadLen = strlen(cPayload);
rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, ¶msQOS0);
if (rc == MQTT_REQUEST_TIMEOUT_ERROR) {
ESP_LOGW(TAG, "QOS1 publish ack not received.");
rc = SUCCESS;
}
}
Code: Select all
char *filename = (char*)"/spiffs/mpu_6050.txt";
char *content = readFile(filename);
xTaskCreate(&aws_iot_task, "aws_iot_task", 9216, (void*)content, 5, NULL);