Giter Club home page Giter Club logo

esp-aws-iot's Introduction

ESP-AWS-IoT

IMPORTANT: Please choose the branch of this repo, based on the FreeRTOS-LTS release that you would like to base your application on.

If you are using the older (3.x.x) aws-iot-device-sdk-embedded-C release, please checkout the release/v3.1.x branch.

This SDK enables AWS IoT cloud connectivity with ESP32-based platforms using the libraries provided as a part of the AWS IoT Device Embedded C SDK.

Getting Started

  • Please clone this branch of the repository using
    git clone -b "<name_of_the_release_branch>" --recursive https://github.com/espressif/esp-aws-iot
    
    For example: To clone just release/202210.01-LTS, you may run:
    git clone -b "release/202210.01-LTS" --recursive https://github.com/espressif/esp-aws-iot
    
  • Please refer to https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html for setting up ESP-IDF
    • ESP-IDF can be downloaded from https://github.com/espressif/esp-idf/
    • This SDK supports release/v5.2, release/v5.1, release/v5.0, release/v4.4 and release/v4.3 of ESP-IDF.
    • Please set your branch to the IDF release that you would like to use, and pull in the latest changes.

    Note: Please read Support Policy below for more details.

  • Please refer to the example README for more information on setting up examples.
  • For a production-ready starting point for making applications that connect to AWS IoT Core using esp-aws-iot, refer to the reference example.
  • Please refer to the Security Guide for steps to enable Security Features on your Espressif chip.
    • This SDK supports multiple ways to securely store the PKI credentials.
    • The default method is to use PKI credentials which are embedded in the binary, using the certs from the certs/ in every example.
    • For using Secure Element (ATECC608A), you will need to use esp-cryptoauthlib.
    • The Security Guide includes detailed steps and pointers to configure and use the Digital Signature Peripheral on supported chips, using esp_secure_cert_mgr.

Supported SoCs

The following table shows esp-aws-iot support with the ESP-IDF support of Espressif SoCs:
alt text and alt text denote supported and unsupported status, respectively.

SoC Supported IDF Version esp-aws-iot Release
202012.04-LTS 202210.01-LTS master branch
ESP32 IDF v4.3 Image Image Image
IDF v4.4 Image Image Image
IDF v5.0 Image Image
IDF v5.1 Image Image
IDF v5.2 Image
ESP32-S2 IDF v4.3 Image Image Image
IDF v4.4 Image Image Image
IDF v5.0 Image Image
IDF v5.1 Image Image
IDF v5.2 Image
ESP32-C3 IDF v4.3 Image Image Image
IDF v4.4 Image Image Image
IDF v5.0 Image Image
IDF v5.1 Image Image
IDF v5.2 Image
ESP32-S3 IDF v4.4 Image Image Image
IDF v5.0 Image Image
IDF v5.1 Image Image
IDF v5.2 Image
ESP32-C2 IDF v5.0 Image Image
IDF v5.1 Image Image
IDF v5.2 Image
ESP32-C6 IDF v5.1 Image Image
IDF v5.2 Image

Support Policy

IDF version support for esp-aws-iot releases is based on IDF Release Support Schedule.
For example, support for IDF v4.3 for Release 202210.01-LTS will expire on 15th Dec 2023.

esp-aws-iot's People

Contributors

actoryou avatar adityahpatwardhan avatar avsheth avatar brucejcooper avatar dhavalgujar avatar jasonpcarroll avatar kvp1703 avatar mahavirj avatar nathanjphillips avatar pritam-shelke avatar shahpiyushv avatar shivani-tipnis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-aws-iot's Issues

Timeout error occured when waiting large size packet (CA-110)

I think that timeout_ms of aws_iot_mqtt_yield should be specified short time because task called this function is blocked long time.
But, if timeout_ms is short, timeout error occur when waiting large size packet. (ex. OTA)

I think iot_tls_read function should be improved as the below.

IoT_Error_t iot_tls_read(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *read_len) {
    TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
    mbedtls_ssl_context *ssl = &(tlsDataParams->ssl);
    mbedtls_ssl_config *ssl_conf = &(tlsDataParams->conf);
    uint32_t read_timeout;
    size_t rxLen = 0;
    int ret;
    Timer readTimer = *timer;

    read_timeout = ssl_conf->read_timeout;

    while (len > 0) {

        /* Make sure we never block on read for longer than timer has left,
         but also that we don't block indefinitely (ie read_timeout > 0) */
        mbedtls_ssl_conf_read_timeout(ssl_conf, MAX(1, MIN(read_timeout, left_ms(timer))));

        ret = mbedtls_ssl_read(ssl, pMsg, len);

        /* Restore the old timeout */
        mbedtls_ssl_conf_read_timeout(ssl_conf, read_timeout);

        if (ret > 0) {

	    /* Successfully received data, so reset the timeout */
	    init_timer(&readTimer);
            countdown_ms(&readTimer, IOT_SSL_READ_RETRY_TIMEOUT_MS);

            rxLen += ret;
            pMsg += ret;
            len -= ret;
        } else if (ret == 0 || (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_TIMEOUT)) {
            return NETWORK_SSL_READ_ERROR;
        }

        // Evaluate timeout after the read to make sure read is done at least once
        if (has_timer_expired(&readTimer)) {
            break;
        }
    }

    if (len == 0) {
        *read_len = rxLen;
        return SUCCESS;
    }

    if (rxLen == 0) {
        return NETWORK_SSL_NOTHING_TO_READ;
    } else {
        return NETWORK_SSL_READ_TIMEOUT_ERROR;
    }
}

IOT_SSL_READ_RETRY_TIMEOUT_MS is user configuration parameter.

#define IOT_SSL_READ_RETRY_TIMEOUT_MS   3000

esp-aws-iot crashes on esp8266 (CA-53)

Hi,
I am working on a project which involves connecting esp8266 to AWS IOT, I am using the HEAD version of ESP8266_RTOS_SDK and using esp-aws-IOT as an external component . After flashing the firmware I get "Task watchdog got triggered." error followed by a crash . I tried disabling task watchdog but this causes some wifi related issues . Following is the crash log, kindly guide


> I (3097) mqtt_controller: Connecting to AWS...clientid: 1234
> I (3107) mqtt_controller: stage2
> Task watchdog got triggered.
> 
> Guru Meditation Error: Core  0 panic'ed (unknown). Exception was unhandled.
> Core 0 register dump:
> PC      : 0x402638f0  PS      : 0x00000030  A0      : 0x402468ba  A1      : 0x3fff46f0  
> 0x402638f0: mpi_mul_hlp at /home/akki/esp/axsiot_base/components/mbedtls/mbedtls/library/bignum.c:1364 (discriminator 2)
> 
> 0x402468ba: mpi_montmul at /home/akki/esp/axsiot_base/components/mbedtls/mbedtls/library/bignum.c:737
> 
> A2      : 0x00000021  A3      : 0x3fffc208  A4      : 0x3fffe6a4  A5      : 0xa9cc47da  
> A6      : 0x560f939c  A7      : 0x0f2ec1b0  A8      : 0x0f2f6977  A9      : 0x00000000  
> A10     : 0xa67b8d12  A11     : 0xba280000  A12     : 0x11c80000  A13     : 0xbe000000  
> A14     : 0x0000000c  A15     : 0x4609f695  SAR     : 0x00000020  EXCCAUSE: 0x3fffe69c  
> 
> Backtrace: 0x402638f0:0x3fff46f0 
> 0x402638f0: mpi_mul_hlp at /home/akki/esp/axsiot_base/components/mbedtls/mbedtls/library/bignum.c:1364 (discriminator 2)
> 
> 
>  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
> 
> load 0x40100000, len 7168, room 16 
> tail 0
> chksum 0x90
> load 0x3ffe8408, len 24, room 8 
> tail 0
> chksum 0x19
> load 0x3ffe8420, len 3532, room 8 
> tail 4
> chksum 0x03

Regards
Akshay

AWS IoT error NETWORK_SSL_READ_ERROR (CA-60)

Hi i am using AWS IoT sdk as esp-idf, I am facing issue with error returning (-12). Which on searching out returned to be NETWORK_SSL_READ_ERROR. My program needs to be connected to up-to 12 MQTT topics other than device shadow. I have verified my policy on server side as well as configuration on my program... My device gets connected to AWS IoT console also few number of topics too, but it randomly call this error for remaining number of Topic ... However the error is not constantly occurring sometimes... the program is correctly connected to all topics and perform their functionality

At the end to be mention, Increasing number of topics my device shadow update always return timeout, However i have changed the menu config parameters for increasing number of topics also my program is based on FreeRTOS , where i use two task at different cores and Aws_IoT_task is triggering Watchdog timer which i am clearing using esp_task_wdt_reset()

Eclipse IDF include syntax error (CA-52)

When importing the project in eclipse, it compiles and runs fine. However all .h files in the aws-iot-sdk have

#ifdef __cplusplus
extern "C" {
#endif

This breaks eclipse parser and everything glows red and shows as error. I don't seem to have any access in the eclipse project to set the compiler. Any suggestions

segfault on the 65535th call to iotc_publish() (CA-80)

Able to recreate the crash every time when calling iotc_publish around the 65535 call.
v1.0.2
git sha1 32b0316899adc1bc2185729cb843dd021b814e7c

322 } else {
323 /* sanity checks */
324 assert(layer_data->current_q0_task != 0);
325 assert(layer_data->current_q0_task->logic.handle_type !=
326 IOTC_EVENT_HANDLE_UNSET);
327
328 layer_data->current_q0_task->logic.handlers.h4.a4 = recvd_msg;
329 layer_data->current_q0_task->logic.handlers.h4.a3 = in_out_state;
330
331 return iotc_evtd_execute_handle(&layer_data->current_q0_task->logic);
332 }

publish 64896 in 1196 for 54.260870 waitCount=29
publish 65152 in 1199 for 54.338616 waitCount=34
publish 65408 in 1202 for 54.415973 waitCount=25

Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400e2b73 PS : 0x00060130 A0 : 0x800e08e2 A1 : 0x3ffe8170
0x400e2b73: iotc_mqtt_logic_layer_pull at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c:328

A2 : 0x3ffe0ef4 A3 : 0x3ffe10b8 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000040 A9 : 0x3ffedb30
A10 : 0x00000000 A11 : 0xfffffff0 A12 : 0x3ffbfd1c A13 : 0x400e2998
0x400e2998: iotc_mqtt_logic_layer_pull at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c:239

A14 : 0x00000000 A15 : 0x400e2998 SAR : 0x00000018 EXCCAUSE: 0x0000001d
0x400e2998: iotc_mqtt_logic_layer_pull at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c:239

EXCVADDR: 0x0000001c LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000

ELF file SHA256: 031b5476160f0ec08ff5af313bd2fa5fe1416ead260871b7559a023788f0546f

Backtrace: 0x400e2b70:0x3ffe8170 0x400e08df:0x3ffe8200 0x400e094c:0x3ffe8220 0x400e09bb:0x3ffe8240 0x400e1011:0x3ffe8270 0x400df534:0x3ffe82c0 0x400dece8:0x3ffe82e0
0x400e2b70: iotc_mqtt_logic_layer_pull at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c:328

0x400e08df: iotc_evtd_execute_handle at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/event_dispatcher/iotc_event_dispatcher.c:309

0x400e094c: iotc_evtd_single_step at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/event_dispatcher/iotc_event_dispatcher.c:367

0x400e09bb: iotc_evtd_step at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/event_dispatcher/iotc_event_dispatcher.c:428 (discriminator 1)

0x400e1011: iotc_event_loop_with_evtds at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/event_loop/iotc_event_loop.c:257 (discriminator 3)

0x400df534: iotc_events_process_blocking at HPN101-tracker/app/components/google-iot/iot-device-sdk-embedded-c/src/libiotc/iotc.c:338

0x400dece8: iotStackTask at HPN101-tracker/app/main/iot_google.c:97


aws-iot fleet provisioning (IDFGH-3718) (CA-95)

The problem is that aws have launched fleet prov only 3 months ago due to which espressif have not yet announced a library component which supports fleet prov. The most recent component ( https://github.com/espressif/esp-aws-iot ) points to the stable version of aws-iot-device-sdk-embedded-C sdk (https://github.com/espressif/aws-iot-device-sdk-embedded-C/tree/61f25f34712b1513bf1cb94771620e9b2b001970).

In the aws page for fleet provisioning they point to the sdk that supports fleet provisioning ---> https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html#iot-c-sdk

When I go to the v4_beta branch, I can see that it is totally different than what espressif is providing currently.

Secondly this readme.md file on the github page also mentions the following:
"Please be aware that v4 beta may have bugs and performance issues. Additionally, there are currently missing features compared to v3.0.1. See the README on the v4_beta branch for more information."

My question is if espressif is working towards adding aws-iot fleet provisioning in their esp-aws-iot component or waiting for aws to make their aws-iot-device-sdk-embedded-C sdk stable first?

Aws disconnection crash or loops (CA-97)

Hi, I've a similar issue: if I try to connect and disconnect for n times from AWS Mqtt broker, sometimes the esp32 module reset when is executed "aws_iot_mqtt_disconnect(&hdl_mqtt_Client);" or loops into the function and never returns.

I posted this issue in a comment #29, but I'm not sure about the connection of the two issue so I decided to open a new one.

The error:

Disconnect Mqtt
C:.platformio\packages\framework-espidf\components\freertos\queue.c:720 (xQueueGenericSend)- assert failed!
abort() was called at PC 0x40098a7c on core 1

ELF file SHA256: f997dde20128e6df

Backtrace: 0x4008da79:0x3ffe2f60 0x4008ddfd:0x3ffe2f80 0x40098a7c:0x3ffe2fa0 0x4012f822:0x3ffe2fe0 0x40133210:0x3ffe3000 >0x4013331d:0x3ffe3030 0x40135dde:0x3ffe3050 0x40136801:0x3ffe3080 0x40130445:0x3ffe30a0 0x401304ec:0x3ffe30c0 >0x40098381:0x3ffe30f0

Rebooting...

Decoding stack results:

0x40133185: select_check_waiters at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\api\sockets.c line 2672
0x4013331d: event_callback at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\api\sockets.c line 2623
0x40135fa1: recv_tcp at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\api\api_msg.c line 351
0x40124d2d: tcp_input at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\core\tcp_in.c line 501
0x40129e16: ip4_input at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\core\ipv4\ip4.c line 784
0x4012f6b2: ethernet_input at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\netif\ethernet.c line 186
0x4013046d: tcpip_thread_handle_msg at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\api\tcpip.c line 180
0x401304ec: tcpip_thread at C:.platformio\packages\framework-espidf\components\lwip\lwip\src\api\tcpip.c line 154
0x40098381: vPortTaskWrapper at C:.platformio\packages\framework-espidf\components\freertos\port.c line 143

The code:

void hdl_mqtt_deinit(void)
{
    printf("Delete Task\n");
    vTaskDelete(hdl_mqtt_taskHandler); //Delete the mqtt main task with yeld function
    printf("Disconnect Mqtt\n");
    IoT_Error_t err = aws_iot_mqtt_disconnect(&hdl_mqtt_Client); //Disconnect from AWS
    if(err!=SUCCESS)
        printf("Disc Unsuccess\n");
    else
        printf("Disc Success\n");
    err = aws_iot_mqtt_free(&hdl_mqtt_Client); //Free memory
    if(err!=SUCCESS)
        printf("free Unsuccess\n");
    else
        printf("free Success\n");
}

Originally posted by @romocitto88 in #29 (comment)

Change json data in thing_shadow_sample.c

Hi,

About change json data(document) in thing_shadow_sample.c

image

How to fix it?

I want to put the my data in the "char JsonDocumentBuffer"
(I do not know when the data is initialized.)

Thank you for reading.
Yours faithfully.

AWS_IOT_MQTT_TX_BUF_LEN limited to 65536 bytes (CA-264)

Why is the KConfig variable AWS_IOT_MQTT_TX_BUF_LEN limited to max 65536 bytes?

We have a project that requires uploads of ~80000 bytes.

I tested by editing the esp-aws-iot component and changing the max value to 80000 and I could successfully publish my 76000 bytes of data. I am storing the aws iot client in spiram so there are no concerns with running out of RAM.

MQTT spec defines max payload as 268,435,456 bytes.

config AWS_IOT_MQTT_TX_BUF_LEN
int "MQTT TX Buffer Length"
default 512
range 32 65536
help
Maximum MQTT transmit buffer size. This is the maximum MQTT
message length (including protocol overhead) which can be sent.

    Sending longer messages will fail.

aws-iot last will (IDFGH-644) (CA-10)

I am fighting for some time with aws-iot last will. When i set plain text in last will there is no issue, but when i am trying to set simple json string then most of the time data is corrupted. Usually its missing 1 or 2 leading chars or sometimes leading bytes (1-2) are replaced with other random char.
I could add leading space if not the problem that sometimes 2 chars are corrupted and in very rare case there is no corruption in string.

Any advice or help will be appreciated because its in production app.

AWS IOT core OTA (CA-57)

Hi there,

Thank you for the Library. Can you provide example for the OTA with AWS IOT core?

Regards

Update Time Out

I have adapted the aws code for my needs, everything works perfectly if I only have uptil 7 JsonStruct_t in the aws iot shadow add reported function. Once I surpass 7 and add the 8th JsonStruct handler I start getting update time out error. I've tried increasing the update time from 4 seconds to almost 10 seconds but it does nothing. Also even though it shows update time out the shadow update is being accepted on aws and I can see the updated parameters.

Please help! This isnt really an error because everything is still working okay, but I just don't like seeing the update time out error message.

@shahpiyushv
@mahavirj

Just In Time registration on AWS (CA-132)

Hello,

We have a requirement like below:
We will be having multiple devices which needs to be connected to the AWS IoT cloud. Each one of them has a unique device ID. We need to register all the devices using Just In Time registration, such that a unique thing name is created when the robot is connected to the cloud first time. The thingname can be the device ID which is unique.
Here we want to implement the feature mentioned in the below link:
https://docs.aws.amazon.com/iot/latest/developerguide/auto-register-device-cert.html
The question here is, is this possible with this example code? And if it is, then how we can enable this?

Thanks in advance!

Not Able to include new header

I am new to this environment .I am planning to make project in which esp32 scans bluetooth beacons and send the rssi value to the aws cloud. So i am trying to take subcribe publish example as basecode and merging the gatt_client code in this code in which I am trying to include the header files.It is expected that all files of components under esp-idf can be built without any perticular chnage in makefile or component.mk.
Please let me know where i am wrong ,all suggestions are welcome .
This is the error:

C:/msys32/home/monika/esp/esp-aws-iot-master/examples/subscribe_publish/main/subscribe_publish_sample.c:53:29: fatal error: esp_gap_ble_api.h: No such file or directory

ESP-SOLO 1 board which is single core ,IDF-Version v3.2.

shadow: aws_iot_shadow_connect returned error -12, aborting...

I don't think shadow_thing example works anymore. I got thing setup on AWS cloud and its certificates downloaded and activated. The thing has wide open policy. Certificates are embedded into source.

I got following error message after Shadow Init step:

E (5978) shadow: aws_iot_shadow_connect returned error -12, aborting...

ESP-IDF: v4.0-dev-667-gda13efc17

Registering delta after aws_iot_shadow_update call with persistent flag set to false, times-out (CA-113)

This piece of code is failing with time out error:

rc = aws_iot_shadow_update(&mqttClient, AWS_IOT_MY_THING_NAME, JsonDocumentBuffer, ShadowUpdateStatusCallback, NULL, 4, false);
rc = aws_iot_shadow_register_delta(&mqttClient, &carDoor);
    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "Shadow Register Delta Error");
    }

But this piece of code runs without problem:

rc = aws_iot_shadow_update(&mqttClient, AWS_IOT_MY_THING_NAME, JsonDocumentBuffer, ShadowUpdateStatusCallback, NULL, 4, true);
rc = aws_iot_shadow_register_delta(&mqttClient, &carDoor);
    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "Shadow Register Delta Error");
    }   

Is it a bug?

AWS-IOT Fleet Provisioning (CA-75)

The problem is that aws have launched fleet prov only 3 months ago due to which espressif have not yet announced a library component which supports fleet prov. The most recent component ( https://github.com/espressif/esp-aws-iot ) points to the stable version of aws-iot-device-sdk-embedded-C sdk (https://github.com/espressif/aws-iot-device-sdk-embedded-C/tree/61f25f34712b1513bf1cb94771620e9b2b001970).

In the aws page for fleet provisioning they point to the sdk that supports fleet provisioning ---> https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html#iot-c-sdk

When I go to the v4_beta branch, I can see that it is totally different than what espressif is providing currently.

Secondly this readme.md file on the github page also mentions the following:
"Please be aware that v4 beta may have bugs and performance issues. Additionally, there are currently missing features compared to v3.0.1. See the README on the v4_beta branch for more information."

My question is if espressif is working towards adding aws-iot fleet provisioning in their esp-aws-iot component or waiting for aws to make their aws-iot-device-sdk-embedded-C sdk stable first?

Cannot compile project with CMakeLists.txt

Hi, I am trying to compile my project but it is not finding aws_iot_config.h

/home/borch/Documents/Robotica/esp/esp32-reedswitch/aws_iot/thing_shadow/main/thing_shadow_sample.c:43:28: fatal error: aws_iot_config.h: No such file or directory
compilation terminated.

I already updated my project's CMakeLists.txt with the following parameters:

$ cat CMakeLists.txt 
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set (EXTRA_COMPONENT_DIRS "/home/borch/Documents/Robotica/esp/esp-aws-iot/")
project(thing_shadow)

If I run make inside esp-aws-iot/examples/thing_shadow the project is compiled successfully.
I am using ESP IDF master branch as well.

Thanks.

undefined reference to "FUNCTION"

Hi,

I am trying to integrate thing_shadow and ble_prov(in esp-idf/example)
( set wifi with ble_prov -> shadow_get )

Add
#include <esp_bt.h>
and make command there are problems like below
image

It looks like it doesn't refer to a function due to a library problem.
Can I link library??

Thanks to read!!
best regards.

Shadow update Timed out, but shadow was updated correctly. (CA-98)

I'm starting to use shadows and I'm doing so based on the examples.

I'm able to use the example and it's working correctly, but every time I update the shadow I always get a time out (SHADOW_ACK_TIMEOUT). I already tested changing the the timeout_seconds parameter with several values but it did not help.

When I google for this issue I saw that some people solved it by changing the MQTT_RX_BUFFER and MQTT_TX_BUFFER but in my case it didn't help.

Any hints of what be causing this?

Failed in parse JSON in shadow (CA-131)

Hi,

I am trying to receive a shadow with the following in aws:

{ "desired": { "action": "on", "config": { "pages": [ { "buttons": [ { "functionality": 0, "color": "gray", "brightness": 7 }, { "functionality": 0, "color": "red", "brightness": 7 }, { "functionality": 0, "color": "blue", "brightness": 7 }, { "functionality": 0, "color": "magenta", "brightness": 7 }, { "functionality": 0, "color": "lime", "brightness": 7 }, { "functionality": 0, "color": "yellow", "brightness": 7 }, { "functionality": 0, "color": "cyan", "brightness": 7 }, { "functionality": 0, "color": "white", "brightness": 7 } ] } ] } }, "reported": { "connected": true, "version": { "mayor": 0, "minor": 0, "patch": 2, "tag": "dev" } }, "delta": { "action": "on", "config": { "pages": [ { "buttons": [ { "functionality": 0, "color": "gray", "brightness": 7 }, { "functionality": 0, "color": "red", "brightness": 7 }, { "functionality": 0, "color": "blue", "brightness": 7 }, { "functionality": 0, "color": "magenta", "brightness": 7 }, { "functionality": 0, "color": "lime", "brightness": 7 }, { "functionality": 0, "color": "yellow", "brightness": 7 }, { "functionality": 0, "color": "cyan", "brightness": 7 }, { "functionality": 0, "color": "white", "brightness": 7 } ] } ] } } }

but the app show warn with the message:
aws_iot: Failed to parse JSON: -1
aws_iot: Received JSON is not valid

looking through the code, find that the warining message is send from the file aws_iot_shadow_json.c in the function isJsonValidAndParse() when you try to parse json doc with jsmn.

I printed the json doc received when the warning occurred and the message received was:

{"version":839,"timestamp":1618073884,"state":{"action":"on","config":{"pages":[{"buttons":[{"functionality":0,"color":"gray","brightness":7},{"functionality":0,"color":"red","brightness":7},{"functionality":0,"color":"blue","brightness":7},{"functionality":0,"color":"magenta","brightness":7},{"functionality":0,"color":"lime","brightness":7},{"functionality":0,"color":"yellow","brightness":7},{"functionality":0,"color":"cyan","brightness":7},{"functionality":0,"color":"white","brightness":7}]}]}},"metadata":{"action":{"timestamp":1618071704},"config":{"pages":[{"buttons":[{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}},{"functionality":{"timestamp":1618071721},"color":{"timestamp":1618071721},"brightness":{"timestamp":1618071721}}]}]}},"clientToken":"ThingFab01-0"}

I dont know why the parse json failed? i checked the json and everything looks fine.

Any idea what the problem may be?

Thanks.

aws iot returns MQTT_RX_BUFFER_TOO_SHORT_ERROR when a bad key is created in shadow (CA-91)

If I set a key name in the aws iot shadow and that key had not been previously registered with the aws_iot_shadow_register_delta command, the it returns a -32 MQTT_RX_BUFFER_TOO_SHORT_ERROR error. This was very misleading and took quite some time to debug, probably could be something more meaningful.

Tip, make sure to call aws_iot_shadow_yield after this and restart the aws_iot_shadow_yield loop.

Error compiling subscribe publish example - timer_platform.h no such file

Hi, today I git cloned the repository:

$ git clone https://github.com/espressif/esp-aws-iot.git

I changed directory to examples/subscribe_publish and executed make command however I got this:

/home/borch/Documents/Robotica/esp/esp-aws-iot/port/include/**timer_platform.h:25:29: fatal error: timer_interface.h**: No such file or directory
compilation terminated.
/home/borch/Documents/Robotica/esp/esp-idf-master/esp-idf/make/component_wrapper.mk:289: recipe for target 'port/network_mbedtls_wrapper.o' failed
make[1]: *** [port/network_mbedtls_wrapper.o] Error 1
/home/borch/Documents/Robotica/esp/esp-idf-master/esp-idf/make/project.mk:582: recipe for target 'component-esp-aws-iot-build' failed
make: *** [component-esp-aws-iot-build] Error 2

The last commit id is:

git rev-parse HEAD
7a5d204da1bdf7a3d3d8ee7f7287ce87acf29048

The version of the IDF I am using is located at:

$ printenv IDF_PATH
/home/borch/Documents/Robotica/esp/esp-idf-master/esp-idf

$cd /home/borch/Documents/Robotica/esp/esp-idf-master/esp-idf
$ git rev-parse HEAD
a20d02b7f196c407bc9f39b781e31a0a4f665968 <== This is the last commit id of the master branch. 

ERROR: mbedtls_ssl_handshake returned -0x50 (with AWS IOT SDK ) (CA-63)

Hi,
I recently started working on mbedtls for AWS IoT SDK based applications.

Issue: I am planning to run AWS IoT SDK sample applications on my memory constrained (6MB RAM) embedded hardware
Usage: AWS IOT SDK(3.0.1 release version) and mbedtls (2.16.5)
Note: This filesystem is Read-Only file system.

I have tried on Ubuntu 18.04 setup first to make things clear. It was not working with "AmazonRootCA1.pem" and working perfectly fine with cross-signed "G2-RootCA1.pem".
Ref: https://docs.aws.amazon.com/iot/latest/developerguide/iot-embedded-c-sdk.html

So I have cross-compiled for my target board using ARM toolchain and copied the binary and certificates.
I have downloaded device certificate, private key and RootCA from AWS IOT Core to my device. Nothing on
my device except copying the above 3 files.

On my Embedded platform, whenever run my application, mbedtls is throwing the error "mbedtls_ssl_handshake returned -0x50"
So I have enabled the debug in mbedtls library and ran below command to dig into the problem.

$ ./ssl_client2 server_name=a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com serv
er_port=443 ca_file=/certs/G2-RootCA1.pem crt_file=/certs/4960bd2f6b-certificate
.pem.crt key_file=/certs/4960bd2f6b-private.pem.key

Output:
$ ./ssl_client2 server_name=a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com serv
er_port=443 ca_file=/certs/G2-RootCA1.pem crt_file=/certs/4960bd2f6b-certificate
.pem.crt key_file=/certs/4960bd2f6b-private.pem.key

. Seeding the random number generator... ok
. Loading the CA root certificate ... ok (0 skipped)
. Loading the client cert. and key... ok
. Connecting to tcp/a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com/443... ok
. Setting up the SSL/TLS structure...ssl_tls.c:0081: |3| set_timer to 0 ms
ok
. Performing the SSL/TLS handshake...ssl_tls.c:8084: |2| => handshake
ssl_cli.c:3510: |2| client state: 0
ssl_tls.c:2755: |2| => flush output
ssl_tls.c:2767: |2| <= flush output
ssl_cli.c:3510: |2| client state: 1
ssl_tls.c:2755: |2| => flush output
ssl_tls.c:2767: |2| <= flush output
ssl_cli.c:0774: |2| => write client hello
ssl_cli.c:0811: |3| client hello, max version: [3:3]
ssl_cli.c:0703: |3| client hello, current time: 1540981791
ssl_cli.c:0821: |3| dumping 'client hello, random bytes' (32 bytes)
ssl_cli.c:0821: |3| 0000: 5b d9 84 1f 2f 33 35 54 ea 0b 5d e1 dc 42 0c 99 [.../35T..]..B..
ssl_cli.c:0821: |3| 0010: d4 a1 25 72 6f 0f cf 8e 56 0d ab f5 10 e4 47 46 ..%ro...V.....GF
ssl_cli.c:0874: |3| client hello, session id len.: 0
ssl_cli.c:0875: |3| dumping 'client hello, session id' (0 bytes)
ssl_cli.c:0921: |3| client hello, add ciphersuite: cca8
ssl_cli.c:0921: |3| client hello, add ciphersuite: cca9
ssl_cli.c:0921: |3| client hello, add ciphersuite: ccaa
ssl_cli.c:0921: |3| client hello, add ciphersuite: c02c
ssl_cli.c:0921: |3| client hello, add ciphersuite: c030
ssl_cli.c:0921: |3| client hello, add ciphersuite: 009f
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0ad
ssl_cli.c:0921: |3| client hello, add ciphersuite: c09f
ssl_cli.c:0921: |3| client hello, add ciphersuite: c024
ssl_cli.c:0921: |3| client hello, add ciphersuite: c028
ssl_cli.c:0921: |3| client hello, add ciphersuite: 006b
ssl_cli.c:0921: |3| client hello, add ciphersuite: c00a
ssl_cli.c:0921: |3| client hello, add ciphersuite: c014
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0039
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0af
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a3
ssl_cli.c:0921: |3| client hello, add ciphersuite: c087
ssl_cli.c:0921: |3| client hello, add ciphersuite: c08b
ssl_cli.c:0921: |3| client hello, add ciphersuite: c07d
ssl_cli.c:0921: |3| client hello, add ciphersuite: c073
ssl_cli.c:0921: |3| client hello, add ciphersuite: c077
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00c4
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0088
ssl_cli.c:0921: |3| client hello, add ciphersuite: c02b
ssl_cli.c:0921: |3| client hello, add ciphersuite: c02f
ssl_cli.c:0921: |3| client hello, add ciphersuite: 009e
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0ac
ssl_cli.c:0921: |3| client hello, add ciphersuite: c09e
ssl_cli.c:0921: |3| client hello, add ciphersuite: c023
ssl_cli.c:0921: |3| client hello, add ciphersuite: c027
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0067
ssl_cli.c:0921: |3| client hello, add ciphersuite: c009
ssl_cli.c:0921: |3| client hello, add ciphersuite: c013
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0033
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0ae
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a2
ssl_cli.c:0921: |3| client hello, add ciphersuite: c086
ssl_cli.c:0921: |3| client hello, add ciphersuite: c08a
ssl_cli.c:0921: |3| client hello, add ciphersuite: c07c
ssl_cli.c:0921: |3| client hello, add ciphersuite: c072
ssl_cli.c:0921: |3| client hello, add ciphersuite: c076
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00be
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0045
ssl_cli.c:0921: |3| client hello, add ciphersuite: ccac
ssl_cli.c:0921: |3| client hello, add ciphersuite: ccad
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00ab
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a7
ssl_cli.c:0921: |3| client hello, add ciphersuite: c038
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00b3
ssl_cli.c:0921: |3| client hello, add ciphersuite: c036
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0091
ssl_cli.c:0921: |3| client hello, add ciphersuite: c091
ssl_cli.c:0921: |3| client hello, add ciphersuite: c09b
ssl_cli.c:0921: |3| client hello, add ciphersuite: c097
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0ab
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00aa
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a6
ssl_cli.c:0921: |3| client hello, add ciphersuite: c037
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00b2
ssl_cli.c:0921: |3| client hello, add ciphersuite: c035
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0090
ssl_cli.c:0921: |3| client hello, add ciphersuite: c090
ssl_cli.c:0921: |3| client hello, add ciphersuite: c096
ssl_cli.c:0921: |3| client hello, add ciphersuite: c09a
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0aa
ssl_cli.c:0921: |3| client hello, add ciphersuite: 009d
ssl_cli.c:0921: |3| client hello, add ciphersuite: c09d
ssl_cli.c:0921: |3| client hello, add ciphersuite: 003d
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0035
ssl_cli.c:0921: |3| client hello, add ciphersuite: c032
ssl_cli.c:0921: |3| client hello, add ciphersuite: c02a
ssl_cli.c:0921: |3| client hello, add ciphersuite: c00f
ssl_cli.c:0921: |3| client hello, add ciphersuite: c02e
ssl_cli.c:0921: |3| client hello, add ciphersuite: c026
ssl_cli.c:0921: |3| client hello, add ciphersuite: c005
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a1
ssl_cli.c:0921: |3| client hello, add ciphersuite: c07b
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00c0
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0084
ssl_cli.c:0921: |3| client hello, add ciphersuite: c08d
ssl_cli.c:0921: |3| client hello, add ciphersuite: c079
ssl_cli.c:0921: |3| client hello, add ciphersuite: c089
ssl_cli.c:0921: |3| client hello, add ciphersuite: c075
ssl_cli.c:0921: |3| client hello, add ciphersuite: 009c
ssl_cli.c:0921: |3| client hello, add ciphersuite: c09c
ssl_cli.c:0921: |3| client hello, add ciphersuite: 003c
ssl_cli.c:0921: |3| client hello, add ciphersuite: 002f
ssl_cli.c:0921: |3| client hello, add ciphersuite: c031
ssl_cli.c:0921: |3| client hello, add ciphersuite: c029
ssl_cli.c:0921: |3| client hello, add ciphersuite: c00e
ssl_cli.c:0921: |3| client hello, add ciphersuite: c02d
ssl_cli.c:0921: |3| client hello, add ciphersuite: c025
ssl_cli.c:0921: |3| client hello, add ciphersuite: c004
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a0
ssl_cli.c:0921: |3| client hello, add ciphersuite: c07a
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00ba
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0041
ssl_cli.c:0921: |3| client hello, add ciphersuite: c08c
ssl_cli.c:0921: |3| client hello, add ciphersuite: c078
ssl_cli.c:0921: |3| client hello, add ciphersuite: c088
ssl_cli.c:0921: |3| client hello, add ciphersuite: c074
ssl_cli.c:0921: |3| client hello, add ciphersuite: ccae
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00ad
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00b7
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0095
ssl_cli.c:0921: |3| client hello, add ciphersuite: c093
ssl_cli.c:0921: |3| client hello, add ciphersuite: c099
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00ac
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00b6
ssl_cli.c:0921: |3| client hello, add ciphersuite: 0094
ssl_cli.c:0921: |3| client hello, add ciphersuite: c092
ssl_cli.c:0921: |3| client hello, add ciphersuite: c098
ssl_cli.c:0921: |3| client hello, add ciphersuite: ccab
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00a9
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a5
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00af
ssl_cli.c:0921: |3| client hello, add ciphersuite: 008d
ssl_cli.c:0921: |3| client hello, add ciphersuite: c08f
ssl_cli.c:0921: |3| client hello, add ciphersuite: c095
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a9
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00a8
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a4
ssl_cli.c:0921: |3| client hello, add ciphersuite: 00ae
ssl_cli.c:0921: |3| client hello, add ciphersuite: 008c
ssl_cli.c:0921: |3| client hello, add ciphersuite: c08e
ssl_cli.c:0921: |3| client hello, add ciphersuite: c094
ssl_cli.c:0921: |3| client hello, add ciphersuite: c0a8
ssl_cli.c:0934: |3| client hello, got 127 ciphersuites (excluding SCSVs)
ssl_cli.c:0943: |3| adding EMPTY_RENEGOTIATION_INFO_SCSV
ssl_cli.c:0992: |3| client hello, compress len.: 1
ssl_cli.c:0993: |3| client hello, compress alg.: 0
ssl_cli.c:0068: |3| client hello, adding server name extension: a2g7twmqo7hg82-ats.iot.ap-south-1.amazonaws.com
ssl_cli.c:0186: |3| client hello, adding signature_algorithms extension
ssl_cli.c:0271: |3| client hello, adding supported_elliptic_curves extension
ssl_cli.c:0336: |3| client hello, adding supported_point_formats extension
ssl_cli.c:0517: |3| client hello, adding encrypt_then_mac extension
ssl_cli.c:0551: |3| client hello, adding extended_master_secret extension
ssl_cli.c:0585: |3| client hello, adding session ticket extension
ssl_cli.c:1070: |3| client hello, total extension length: 128
ssl_tls.c:3184: |2| => write handshake message
ssl_tls.c:3343: |2| => write record
ssl_tls.c:3420: |3| output record: msgtype = 22, version = [3:1], msglen = 429
ssl_tls.c:3425: |4| dumping 'output record sent to network' (434 bytes)
ssl_tls.c:3425: |4| 0000: 16 03 01 01 ad 01 00 01 a9 03 03 5b d9 84 1f 2f ...........[.../
ssl_tls.c:3425: |4| 0010: 33 35 54 ea 0b 5d e1 dc 42 0c 99 d4 a1 25 72 6f 35T..]..B....%ro
ssl_tls.c:3425: |4| 0020: 0f cf 8e 56 0d ab f5 10 e4 47 46 00 01 00 cc a8 ...V.....GF.....
ssl_tls.c:3425: |4| 0030: cc a9 cc aa c0 2c c0 30 00 9f c0 ad c0 9f c0 24 .....,.0.......$
ssl_tls.c:3425: |4| 0040: c0 28 00 6b c0 0a c0 14 00 39 c0 af c0 a3 c0 87 .(.k.....9......
ssl_tls.c:3425: |4| 0050: c0 8b c0 7d c0 73 c0 77 00 c4 00 88 c0 2b c0 2f ...}.s.w.....+./
ssl_tls.c:3425: |4| 0060: 00 9e c0 ac c0 9e c0 23 c0 27 00 67 c0 09 c0 13 .......#.'.g....
ssl_tls.c:3425: |4| 0070: 00 33 c0 ae c0 a2 c0 86 c0 8a c0 7c c0 72 c0 76 .3.........|.r.v
ssl_tls.c:3425: |4| 0080: 00 be 00 45 cc ac cc ad 00 ab c0 a7 c0 38 00 b3 ...E.........8..
ssl_tls.c:3425: |4| 0090: c0 36 00 91 c0 91 c0 9b c0 97 c0 ab 00 aa c0 a6 .6..............
ssl_tls.c:3425: |4| 00a0: c0 37 00 b2 c0 35 00 90 c0 90 c0 96 c0 9a c0 aa .7...5..........
ssl_tls.c:3425: |4| 00b0: 00 9d c0 9d 00 3d 00 35 c0 32 c0 2a c0 0f c0 2e .....=.5.2.*....
ssl_tls.c:3425: |4| 00c0: c0 26 c0 05 c0 a1 c0 7b 00 c0 00 84 c0 8d c0 79 .&.....{.......y
ssl_tls.c:3425: |4| 00d0: c0 89 c0 75 00 9c c0 9c 00 3c 00 2f c0 31 c0 29 ...u.....<./.1.)
ssl_tls.c:3425: |4| 00e0: c0 0e c0 2d c0 25 c0 04 c0 a0 c0 7a 00 ba 00 41 ...-.%.....z...A
ssl_tls.c:3425: |4| 00f0: c0 8c c0 78 c0 88 c0 74 cc ae 00 ad 00 b7 00 95 ...x...t........
ssl_tls.c:3425: |4| 0100: c0 93 c0 99 00 ac 00 b6 00 94 c0 92 c0 98 cc ab ................
ssl_tls.c:3425: |4| 0110: 00 a9 c0 a5 00 af 00 8d c0 8f c0 95 c0 a9 00 a8 ................
ssl_tls.c:3425: |4| 0120: c0 a4 00 ae 00 8c c0 8e c0 94 c0 a8 00 ff 01 00 ................
ssl_tls.c:3425: |4| 0130: 00 80 00 00 00 34 00 32 00 00 2f 61 32 67 37 74 .....4.2../a2g7t
ssl_tls.c:3425: |4| 0140: 77 6d 71 6f 37 68 67 38 32 2d 61 74 73 2e 69 6f wmqo7hg82-ats.io
ssl_tls.c:3425: |4| 0150: 74 2e 61 70 2d 73 6f 75 74 68 2d 31 2e 61 6d 61 t.ap-south-1.ama
ssl_tls.c:3425: |4| 0160: 7a 6f 6e 61 77 73 2e 63 6f 6d 00 0d 00 16 00 14 zonaws.com......
ssl_tls.c:3425: |4| 0170: 06 03 06 01 05 03 05 01 04 03 04 01 03 03 03 01 ................
ssl_tls.c:3425: |4| 0180: 02 03 02 01 00 0a 00 18 00 16 00 19 00 1c 00 18 ................
ssl_tls.c:3425: |4| 0190: 00 1b 00 17 00 16 00 1a 00 15 00 14 00 13 00 12 ................
ssl_tls.c:3425: |4| 01a0: 00 0b 00 02 01 00 00 16 00 00 00 17 00 00 00 23 ...............#
ssl_tls.c:3425: |4| 01b0: 00 00 ..
ssl_tls.c:2755: |2| => flush output
ssl_tls.c:2773: |2| message length: 434, out_left: 434
ssl_tls.c:2779: |2| ssl->f_send() returned 434 (-0xfffffe4e)
ssl_tls.c:2807: |2| <= flush output
ssl_tls.c:3476: |2| <= write record
ssl_tls.c:3320: |2| <= write handshake message
ssl_cli.c:1106: |2| <= write client hello
ssl_cli.c:3510: |2| client state: 2
ssl_tls.c:2755: |2| => flush output
ssl_tls.c:2767: |2| <= flush output
ssl_cli.c:1499: |2| => parse server hello
ssl_tls.c:4311: |2| => read record
ssl_tls.c:2536: |2| => fetch input
ssl_tls.c:2696: |2| in_left: 0, nb_want: 5
ssl_tls.c:2720: |2| in_left: 0, nb_want: 5
ssl_tls.c:2722: |2| ssl->f_recv(_timeout)() returned -80 (-0x0050)
ssl_tls.c:4973: |1| mbedtls_ssl_fetch_input() returned -80 (-0x0050)
ssl_tls.c:4344: |1| ssl_get_next_record() returned -80 (-0x0050)
ssl_cli.c:1506: |1| mbedtls_ssl_read_record() returned -80 (-0x0050)
ssl_tls.c:8094: |2| <= handshake
failed
! mbedtls_ssl_handshake returned -0x50

Last error was: -0x50 - NET - Connection was reset by peer

ssl_tls.c:8934: |2| => free
ssl_tls.c:8999: |2| <= free

I request you to help me in resolving this issue.

Thanks in advance,
Srinivas.

Publish/Subscribe: aws_iot failed! mbedtls_ssl_handshake returned -0x10

Hi,
I tried to connect AWS IoT for testing but got this issue, could you have any suggestions?
Here is logs:

...
I (157526) mbedtls: ssl_tls.c:2770 message length: 877, out_left: 877
I (157536) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 877 (-0xfffffc93)
I (157546) mbedtls: ssl_tls.c:2803 <= flush output
I (157546) mbedtls: ssl_tls.c:3470 <= write record
I (157556) mbedtls: ssl_tls.c:3314 <= write handshake message
I (157566) mbedtls: ssl_tls.c:5427 <= write certificate
I (157566) mbedtls: ssl_cli.c:3405 client state: 8
I (157576) mbedtls: ssl_tls.c:2751 => flush output
I (157576) mbedtls: ssl_tls.c:2763 <= flush output
I (157586) mbedtls: ssl_cli.c:2851 => write client key exchange
W (158606) mbedtls: ssl_cli.c:2924 mbedtls_ecdh_calc_secret() returned -16 (-0x0010)
I (158606) mbedtls: ssl_tls.c:8031 <= handshake
E (158616) aws_iot: failed! mbedtls_ssl_handshake returned -0x10
I (158616) mbedtls: ssl_tls.c:8662 => write close notify
I (158626) mbedtls: ssl_tls.c:8678 <= write close notify
I (158636) mbedtls: ssl_tls.c:8866 => free
I (158636) mbedtls: ssl_tls.c:8931 <= free

Thank you.

ESP32 + Alexa echo project (CA-9)

Hello,
I have to develop a smart product based on ESP32 able to receive vocal commands from the Alexa Echo. I found on google many example projects based on Arduino and open source libraries, but I cannot use those environments for a market product.

  • Is the esp-aws-iot a good starting point to develop the communication between Alexa Echo and my product?
  • Do I need to use the Amazon FreeRTOS?
  • Is there any related example project base only on code published in Espressif repository?

Thank you,
Paul

v4_beta (CA-92)

I think the link in the README for thev4_beta branch has been broken. Would it be possible to get an update on this please, as my team would like to migrate to v4 asap.

AWS IoT sdk - device Shadow Update Timeout (CA-59)

Hi I am using the example code for device shadow where i need to update my device shadow json document, which includes strings,boolean and int values... but device shadow is not updating my device and return Update Timeout

aws_iot: failed! mbedtls_ssl_handshake returned -0x6800 (IDFGH-3542) (CA-207)

Environment

  • Development Kit: [none]
  • Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4]
  • Module or chip used: [ESP32]
  • IDF version (run git describe --tags to find it): v3.3
  • Build System: [Make]
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): 1.22.0-80-g6c4433a
  • Operating System: [Linux]
  • (Windows only) environment type:
  • Using an IDE?: [No]
  • Power Supply: [external 3.3V]

Problem Description

After power up, sometimes device can not connect to AWS, then i make it restart use esp_restart, usually it is work well, i din't know where is the problem

Expected Behavior

Actual Behavior

Steps to reproduce

just power up device, usually i can get this problem

Code to reproduce this issue

void app_main()
{
    somecode;
    xTaskCreate(aws_iot_task, "aws_iot_task", 5120, NULL, 8, &pTaskAWSIotHandle);
}

void aws_iot_task(void *param) 
{
    somecode;
    connectParams.keepAliveIntervalInSec = 60;
    connectParams.isCleanSession = true;
    connectParams.MQTTVersion = MQTT_3_1_1;
    /* Client ID is set in the menuconfig of the example */
    connectParams.pClientID = thingID;
    connectParams.clientIDLen = (uint16_t) strlen(thingID);
    connectParams.isWillMsgPresent = false;

    ESP_LOGI(TAG, "Connecting to AWS...");
    ESP_LOGD(TAG, "Stack remaining for task '%s' is '%d' bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));
    ESP_LOGD(TAG, "Free memory for application is '%d' bytes", esp_get_free_heap_size());
    // uint8_t conn_retry_cnt = 0;
    do {
        rc = aws_iot_mqtt_connect(&client, &connectParams);
        if(SUCCESS != rc) {
            ESP_LOGE(TAG, "Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
            vTaskDelay(1000 / portTICK_RATE_MS);

            // if (++conn_retry_cnt > 15){
                // ESP_LOGE(TAG, "Failed to connecting to AWS more than 15 times, AWS task is going to be delete");
                ESP_LOGE(TAG, "Failed to connecting to AWS, reboot device");
                vTaskDelay(1000 / portTICK_RATE_MS);
                esp_restart();
            // }
        }
    } while(SUCCESS != rc);
}

Debug Logs

I (3861) main: Device connected to ap
I (3871) AWS Iot: AWS IoT SDK Version 3.0.1-
I (3871) tcp handle: master socket create success, socket fd: 54
I (3871) AWS Iot: Connecting to AWS...
I (3881) tcp handle: master socket bind success
D (3881) AWS Iot: Stack remaining for task 'aws_iot_task' is '3396' bytes
I (3891) tcp handle: master socket is listening on port 10000
D (3891) AWS Iot: Free memory for application is '4340516' bytes
I (3901) tcp handle: Waiting for TCP connections ...
D (3911) tcp handle: update readfds:        0
E (15291) aws_iot: failed! mbedtls_ssl_handshake returned -0x6800
E (15291) AWS Iot: Error(-4) connecting to a2f8ob0zg2vz65.iot.ap-northeast-1.amazonaws.com:8883
E (16291) AWS Iot: Failed to connecting to AWS, reboot device
I (17291) wifi: state: run -> init (0)
I (17291) wifi: pm stop, total sleep time: 7051647 us / 15152406 us

I (17291) wifi: new:<2,0>, old:<2,0>, ap:<255,255>, sta:<2,0>, prof:1
E (17291) event: system_event_sta_disconnected_handle_default 294 esp_wifi_internal_reg_rxcb ret=0x3014
E (17301) wifi: esp_wifi_connect 1134 wifi not start
I (17311) wifi: flush txq
I (17311) wifi: stop sw txq
I (17311) wifi: lmac stop hw txq
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6356
load:0x40078000,len:11624
load:0x40080400,len:6648
entry 0x40080764
I (29) boot: ESP-IDF v3.3-dirty 2nd stage bootloader
I (29) boot: compile time 18:03:31
I (29) boot: Enabling RNG early entropy source...
I (34) boot: SPI Speed      : 40MHz
I (38) boot: SPI Mode       : DIO
I (42) boot: SPI Flash Size : 4MB
I (46) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (64) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (72) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  3 ota_0            OTA app          00 10 00010000 001d0000
I (87) boot:  4 ota_1            OTA app          00 11 001e0000 001d0000
I (94) boot:  5 custom_data      unknown          40 00 003b0000 00020000
I (102) boot: End of partition table
I (106) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x33c08 (211976) map
I (190) esp_image: segment 1: paddr=0x00043c30 vaddr=0x3ffb0000 size=0x045b0 ( 17840) load
I (197) esp_image: segment 2: paddr=0x000481e8 vaddr=0x40080000 size=0x00400 (  1024) load
I (198) esp_image: segment 3: paddr=0x000485f0 vaddr=0x40080400 size=0x07a20 ( 31264) load
I (218) esp_image: segment 4: paddr=0x00050018 vaddr=0x400d0018 size=0xb20f4 (729332) map
I (474) esp_image: segment 5: paddr=0x00102114 vaddr=0x40087e20 size=0x0db7c ( 56188) load
I (511) boot: Loaded app from partition at offset 0x10000
I (511) boot: Disabling RNG early entropy source...
I (512) psram: This chip is ESP32-D0WD
I (517) spiram: Found 64MBit SPI RAM device
I (521) spiram: SPI RAM mode: flash 40m sram 40m
I (526) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (533) cpu_start: Pro cpu up.
I (537) cpu_start: Application information:
I (542) cpu_start: Project name:     IR_extender_ESP32
I (548) cpu_start: App version:      c909cff-dirty
I (553) cpu_start: Compile time:     Jun 24 2020 10:12:41
I (559) cpu_start: ELF file SHA256:  2348dc17122ab4da...
I (565) cpu_start: ESP-IDF:          v3.3-dirty
I (570) cpu_start: Starting app cpu, entry point is 0x400816ac
I (562) cpu_start: App cpu up.
I (1461) spiram: SPI SRAM memory test OK
I (1719) heap_init: Initializing. RAM available for dynamic allocation:
D (1726) heap_init: New heap initialised at 0x3ffae6e0
I (1732) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
D (1738) heap_init: New heap initialised at 0x3ffbdd68
I (1743) heap_init: At 3FFBDD68 len 00022298 (136 KiB): DRAM
I (1749) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1756) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (1762) heap_init: New heap initialised at 0x4009599c
I (1767) heap_init: At 4009599C len 0000A664 (41 KiB): IRAM
I (1774) cpu_start: Pro cpu start user code
I (1779) spiram: Adding pool of 4096K of external SPI memory to heap allocator
D (1794) clk: RTC_SLOW_CLK calibration value: 3247526
D (126) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (126) intr_alloc: Connected src 57 to int 3 (cpu 0)
D (127) intr_alloc: Connected src 24 to int 9 (cpu 0)
D (132) efuse: coding scheme 0
D (135) efuse: In EFUSE_BLK0__DATA3_REG is used 1 bits starting with 15 bit
D (142) efuse: coding scheme 0
D (145) efuse: In EFUSE_BLK0__DATA5_REG is used 1 bits starting with 20 bit
I (152) cpu_start: Chip Revision: 1
W (156) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.
I (166) cpu_start: Starting scheduler on PRO CPU.
D (0) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (0) cpu_start: Starting scheduler on APP CPU.
D (182) heap_init: New heap initialised at 0x3ffe0440
D (192) heap_init: New heap initialised at 0x3ffe4350
I (202) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
D (202) spiram: Allocating block of size 32768 bytes
D (212) intr_alloc: Connected src 16 to int 12 (cpu 0)
I (262) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (262) gpio: GPIO[26]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (262) gpio: GPIO[27]| InputEn: 1|int is not set, use default
I (352) wifi: wifi driver task: 3ffce01c, prio:23, stack:3584, core=0
I (352) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (352) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (392) wifi: wifi firmware version: aeed694
I (392) wifi: config NVS flash: enabled
I (392) wifi: config nano formating: disabled
I (392) wifi: Init dynamic tx buffer num: 32
I (392) wifi: Init data frame dynamic rx buffer num: 32
I (402) wifi: Init
                   I (532) phy: phy_version: 4102, 2fa7a43, Jul 15 2019, 13:06:06, 0, 0
I (532) wifi: mode : sta (c4:4f:33:55:08:31)
I (532) main: ===========Firmware(1.0.0) build time: D (532) intr_alloc: Connected src 15 to int 3 (cpu 1)
Jun 24 2020 16:08:01==========
I (532) main: SYSTEM_EVENT_STA_START
I (532) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:2
 (562) intr_alloc: Connected src 22 to int 4 (cpu 1)
;D (562) intr_alloc: Connected src 14 to int 9 (cpu 1)
32mI (552) main: Found ssid HeyGoogle
I (572) main: Found password remotecvpn
I (582) main: Connecting to HeyGoogle ...
I (702) wifi: new:<2,0>, old:<1,0>, ap:<255,255>, sta:<2,0>, prof:1
I (1842) wifi: state: init -> auth (b0)
I (1872) wifi: state: auth -> assoc (0)
I (1922) wifi: state: assoc -> run (10)
I (2062) wifi: connected with HeyGoogle, channel 2, HT20, bssid = ec:41:18:ef:6a:66
I (2142) wifi: pm start, type: 1

I (2862) event: sta ip: 192.168.18.55, mask: 255.255.255.0, gw: 192.168.18.1
I (2862) main: SYSTEM_EVENT_STA_GOT_IP: 3712a8c0
I (2862) main: Device connected to ap
I (2862) AWS Iot: AWS IoT SDK Version 3.0.1-
I (2862) tcp handle: master socket create success, socket fd: 54
I (2882) AWS Iot: Connecting to AWS...
I (2882) tcp handle: master socket bind success
I (2892) tcp handle: master socket is listening on port 10000
D (2892) AWS Iot: Stack remaining for task 'aws_iot_task' is '3396' bytes
I (2892) tcp handle: Waiting for TCP connections ...
D (2902) tcp handle: update readfds:        0
D (2912) AWS Iot: Free memory for application is '4340520' bytes
D (18832) AWS Iot: sub topic: $aws/things/BW8453_550831/shadow/update/accepted
D (18832) AWS Iot: pub topic: $aws/things/BW8453_550831/shadow/update
I (18832) AWS Iot: Subscribing...
D (18982) AWS Iot: Stack remaining for task 'aws_iot_task' is '1252' bytes
I (18982) AWS Iot: Subscribed, Free memory for application is '4313284' bytes

Subscribed payloads keep repeating when subscribed with QOS1 . (CA-8)

Our usecase expects us to subscribe and publish with QOS of 1 , when the device subscribes with QOS 1 the payloads published to the subscribed topic keep repeating , it looks like the library is not sending the ACK message to the message published and the broker is trying to resend the messages until it gets Acknowledgment. This issue happens randomly the reproducibility rate is 1/5 times.

I tried the latest C sdk from aws on my computer and I didnt find this issue , may I know if there is a release planned with the latest aws sdk ?

Thing Shadow example stops working after 5-10min (IDFGH-1604) (CA-157)

I've ran the thing_shadow example from https://github.com/espressif/esp-aws-iot/tree/master/examples/thing_shadow succesfully. However, after 5-10min of inactivity (meaning that I don't update the device shadow), the device doesn't respond to anymore changes to the shadow. I don't see that it disconnected from AWS on the monitor - so why is this happening and how can I fix this?

I've modified the code slightly so that it only sends a "reported" msg to the device shadow every time there is a delta change. It doesn't update the shadow itself every 1s like the original code.

/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
/**
 * @file thing_shadow_sample.c
 * @brief A simple connected window example demonstrating the use of Thing Shadow
 *
 * See example README for more details.
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_vfs_fat.h"
#include "driver/sdmmc_host.h"

#include "nvs.h"
#include "nvs_flash.h"

#include "aws_iot_config.h"
#include "aws_iot_log.h"
#include "aws_iot_version.h"
#include "aws_iot_mqtt_client_interface.h"
#include "aws_iot_shadow_interface.h"

/*!
 * The goal of this sample application is to demonstrate the capabilities of shadow.
 * This device(say Connected Window) will open the window of a room based on temperature
 * It can report to the Shadow the following parameters:
 *  1. temperature of the room (double)
 *  2. status of the window (open or close)
 * It can act on commands from the cloud. In this case it will open or close the window based on the json object "windowOpen" data[open/close]
 *
 * The two variables from a device's perspective are double temperature and bool windowOpen
 * The device needs to act on only on windowOpen variable, so we will create a primitiveJson_t object with callback
 The Json Document in the cloud will be
 {
 "reported": {
 "temperature": 0,
 "windowOpen": false
 },
 "desired": {
 "windowOpen": false
 }
 }
 */

static const char *TAG = "shadow";

#define ROOMTEMPERATURE_UPPERLIMIT 32.0f
#define ROOMTEMPERATURE_LOWERLIMIT 25.0f
#define STARTING_ROOMTEMPERATURE ROOMTEMPERATURE_LOWERLIMIT

#define MAX_LENGTH_OF_UPDATE_JSON_BUFFER 200

/* The examples use simple WiFi configuration that you can set via
   'make menuconfig'.

   If you'd rather not, just change the below entries to strings with
   the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid"
*/
#define EXAMPLE_WIFI_SSID CONFIG_WIFI_SSID
#define EXAMPLE_WIFI_PASS CONFIG_WIFI_PASSWORD


/* FreeRTOS event group to signal when we are connected & ready to make a request */
static EventGroupHandle_t wifi_event_group;

/* The event group allows multiple bits for each event,
   but we only care about one event - are we connected
   to the AP with an IP? */
const int CONNECTED_BIT = BIT0;


/* CA Root certificate, device ("Thing") certificate and device
 * ("Thing") key.

   Example can be configured one of two ways:

   "Embedded Certs" are loaded from files in "certs/" and embedded into the app binary.

   "Filesystem Certs" are loaded from the filesystem (SD card, etc.)

   See example README for more details.
*/
#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)

extern const uint8_t aws_root_ca_pem_start[] asm("_binary_aws_root_ca_pem_start");
extern const uint8_t aws_root_ca_pem_end[] asm("_binary_aws_root_ca_pem_end");
extern const uint8_t certificate_pem_crt_start[] asm("_binary_certificate_pem_crt_start");
extern const uint8_t certificate_pem_crt_end[] asm("_binary_certificate_pem_crt_end");
extern const uint8_t private_pem_key_start[] asm("_binary_private_pem_key_start");
extern const uint8_t private_pem_key_end[] asm("_binary_private_pem_key_end");

#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)

static const char * DEVICE_CERTIFICATE_PATH = CONFIG_EXAMPLE_CERTIFICATE_PATH;
static const char * DEVICE_PRIVATE_KEY_PATH = CONFIG_EXAMPLE_PRIVATE_KEY_PATH;
static const char * ROOT_CA_PATH = CONFIG_EXAMPLE_ROOT_CA_PATH;

#else
#error "Invalid method for loading certs"
#endif

static esp_err_t event_handler(void *ctx, system_event_t *event)
{
    switch(event->event_id) {
    case SYSTEM_EVENT_STA_START:
        esp_wifi_connect();
        break;
    case SYSTEM_EVENT_STA_GOT_IP:
        xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
        break;
    case SYSTEM_EVENT_STA_DISCONNECTED:
        /* This is a workaround as ESP32 WiFi libs don't currently
           auto-reassociate. */
        esp_wifi_connect();
        xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
        break;
    default:
        break;
    }
    return ESP_OK;
}

static void simulateRoomTemperature(float *pRoomTemperature) {
    static float deltaChange;

    if(*pRoomTemperature >= ROOMTEMPERATURE_UPPERLIMIT) {
        deltaChange = -0.5f;
    } else if(*pRoomTemperature <= ROOMTEMPERATURE_LOWERLIMIT) {
        deltaChange = 0.5f;
    }

    *pRoomTemperature += deltaChange;
}

static bool shadowUpdateInProgress;

void ShadowUpdateStatusCallback(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status,
                                const char *pReceivedJsonDocument, void *pContextData) {
    IOT_UNUSED(pThingName);
    IOT_UNUSED(action);
    IOT_UNUSED(pReceivedJsonDocument);
    IOT_UNUSED(pContextData);

    shadowUpdateInProgress = false;

    if(SHADOW_ACK_TIMEOUT == status) {
        ESP_LOGE(TAG, "Update timed out");
    } else if(SHADOW_ACK_REJECTED == status) {
        ESP_LOGE(TAG, "Update rejected");
    } else if(SHADOW_ACK_ACCEPTED == status) {
        ESP_LOGI(TAG, "Update accepted");
    }
}

bool awsReady = false;
bool reportBack = true;
void windowActuate_Callback(const char *pJsonString, uint32_t JsonStringDataLen, jsonStruct_t *pContext) {
    IOT_UNUSED(pJsonString);
    IOT_UNUSED(JsonStringDataLen);

    if(pContext != NULL) {
        ESP_LOGI(TAG, "Delta - Window state changed to %d", *(bool *) (pContext->pData));
        reportBack = true;
    }
}

void aws_iot_task(void *param) {
    IoT_Error_t rc = FAILURE;

    char JsonDocumentBuffer[MAX_LENGTH_OF_UPDATE_JSON_BUFFER];
    size_t sizeOfJsonDocumentBuffer = sizeof(JsonDocumentBuffer) / sizeof(JsonDocumentBuffer[0]);
    float temperature = 0.0;

    bool windowOpen = false;
    jsonStruct_t windowActuator;
    windowActuator.cb = windowActuate_Callback;
    windowActuator.pData = &windowOpen;
    windowActuator.pKey = "windowOpen";
    windowActuator.type = SHADOW_JSON_BOOL;
    windowActuator.dataLength = sizeof(bool);

    jsonStruct_t temperatureHandler;
    temperatureHandler.cb = NULL;
    temperatureHandler.pKey = "temperature";
    temperatureHandler.pData = &temperature;
    temperatureHandler.type = SHADOW_JSON_FLOAT;
    temperatureHandler.dataLength = sizeof(float);

    ESP_LOGI(TAG, "AWS IoT SDK Version %d.%d.%d-%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);

    // initialize the mqtt client
    AWS_IoT_Client mqttClient;

    ShadowInitParameters_t sp = ShadowInitParametersDefault;
    sp.pHost = AWS_IOT_MQTT_HOST;
    sp.port = AWS_IOT_MQTT_PORT;

#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)
    sp.pClientCRT = (const char *)certificate_pem_crt_start;
    sp.pClientKey = (const char *)private_pem_key_start;
    sp.pRootCA = (const char *)aws_root_ca_pem_start;
#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)
    sp.pClientCRT = DEVICE_CERTIFICATE_PATH;
    sp.pClientKey = DEVICE_PRIVATE_KEY_PATH;
    sp.pRootCA = ROOT_CA_PATH;
#endif
    sp.enableAutoReconnect = false;
    sp.disconnectHandler = NULL;

#ifdef CONFIG_EXAMPLE_SDCARD_CERTS
    ESP_LOGI(TAG, "Mounting SD card...");
    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
    esp_vfs_fat_sdmmc_mount_config_t mount_config = {
        .format_if_mount_failed = false,
        .max_files = 3,
    };
    sdmmc_card_t* card;
    esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
    if (ret != ESP_OK) {
        ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
        abort();
    }
#endif

    /* Wait for WiFI to show as connected */
    xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,
                        false, true, portMAX_DELAY);

    ESP_LOGI(TAG, "Shadow Init");
    rc = aws_iot_shadow_init(&mqttClient, &sp);
    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "aws_iot_shadow_init returned error %d, aborting...", rc);
        abort();
    }

    ShadowConnectParameters_t scp = ShadowConnectParametersDefault;
    scp.pMyThingName = CONFIG_AWS_EXAMPLE_THING_NAME;
    scp.pMqttClientId = CONFIG_AWS_EXAMPLE_CLIENT_ID;
    scp.mqttClientIdLen = (uint16_t) strlen(CONFIG_AWS_EXAMPLE_CLIENT_ID);

    ESP_LOGI(TAG, "Shadow Connect");
    rc = aws_iot_shadow_connect(&mqttClient, &scp);
    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "aws_iot_shadow_connect returned error %d, aborting...", rc);
        abort();
    }

    /*
     * Enable Auto Reconnect functionality. Minimum and Maximum time of Exponential backoff are set in aws_iot_config.h
     *  #AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL
     *  #AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
     */
    rc = aws_iot_shadow_set_autoreconnect_status(&mqttClient, true);
    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "Unable to set Auto Reconnect to true - %d, aborting...", rc);
        abort();
    }

    rc = aws_iot_shadow_register_delta(&mqttClient, &windowActuator);

    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "Shadow Register Delta Error");
    }
    temperature = STARTING_ROOMTEMPERATURE;

    ESP_LOGI(TAG, "AWS setup finished");
    awsReady = true;
    // loop and publish a change in temperature
    while(NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc) {
        rc = aws_iot_shadow_yield(&mqttClient, 200);
        if(NETWORK_ATTEMPTING_RECONNECT == rc || shadowUpdateInProgress) {
            rc = aws_iot_shadow_yield(&mqttClient, 1000);
            // If the client is attempting to reconnect, or already waiting on a shadow update,
            // we will skip the rest of the loop.
            continue;
        }
        /*ESP_LOGI(TAG, "=======================================================================================");
        ESP_LOGI(TAG, "On Device: window state %s", windowOpen ? "true" : "false");
        simulateRoomTemperature(&temperature);

        rc = aws_iot_shadow_init_json_document(JsonDocumentBuffer, sizeOfJsonDocumentBuffer);
        if(SUCCESS == rc) {
            rc = aws_iot_shadow_add_reported(JsonDocumentBuffer, sizeOfJsonDocumentBuffer, 2, &temperatureHandler,
                                             &windowActuator);
            if(SUCCESS == rc) {
                rc = aws_iot_finalize_json_document(JsonDocumentBuffer, sizeOfJsonDocumentBuffer);
                if(SUCCESS == rc) {
                    ESP_LOGI(TAG, "Update Shadow: %s", JsonDocumentBuffer);
                    rc = aws_iot_shadow_update(&mqttClient, CONFIG_AWS_EXAMPLE_THING_NAME, JsonDocumentBuffer,
                                               ShadowUpdateStatusCallback, NULL, 4, true);
                    shadowUpdateInProgress = true;
                }
            }
        }
        ESP_LOGI(TAG, "*****************************************************************************************");
        ESP_LOGI(TAG, "Stack remaining for task '%s' is %d bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));
        */

        if(reportBack){
            reportBack = false;

            rc = aws_iot_shadow_init_json_document(JsonDocumentBuffer, sizeOfJsonDocumentBuffer);
            if(SUCCESS == rc) {
                rc = aws_iot_shadow_add_reported(JsonDocumentBuffer, sizeOfJsonDocumentBuffer, 2,
                                                    &temperatureHandler,
                                                    &windowActuator);
                if(SUCCESS == rc) {
                    rc = aws_iot_shadow_add_desired(JsonDocumentBuffer, sizeOfJsonDocumentBuffer, 2,
                                                    &temperatureHandler,
                                                    &windowActuator);
                    if(SUCCESS == rc) {
                        rc = aws_iot_finalize_json_document(JsonDocumentBuffer, sizeOfJsonDocumentBuffer);
                        if(SUCCESS == rc) {
                            ESP_LOGI(TAG, "Update Shadow: %s", JsonDocumentBuffer);
                            rc = aws_iot_shadow_update(&mqttClient, CONFIG_AWS_EXAMPLE_THING_NAME, JsonDocumentBuffer,
                                                       ShadowUpdateStatusCallback, NULL, 4, true);
                            shadowUpdateInProgress = true;
                        }
                    }
                }
            }
        }

        vTaskDelay(1000 / portTICK_RATE_MS);
    }

    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "An error occurred in the loop %d", rc);
    }

    ESP_LOGI(TAG, "Disconnecting");
    rc = aws_iot_shadow_disconnect(&mqttClient);

    if(SUCCESS != rc) {
        ESP_LOGE(TAG, "Disconnect error %d", rc);
    }

    esp_restart();

    vTaskDelete(NULL);
}

static void initialise_wifi(void)
{
    tcpip_adapter_init();
    wifi_event_group = xEventGroupCreate();
    ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
    ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
    wifi_config_t wifi_config = {
        .sta = {
            .ssid = EXAMPLE_WIFI_SSID,
            .password = EXAMPLE_WIFI_PASS,
        },
    };
    ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid);
    ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
    ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
    ESP_ERROR_CHECK( esp_wifi_start() );
}


void app_main()
{
    esp_err_t err = nvs_flash_init();
    if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        err = nvs_flash_init();
    }
    ESP_ERROR_CHECK( err );

    initialise_wifi();
    /* Temporarily pin task to core, due to FPU uncertainty */
    xTaskCreatePinnedToCore(&aws_iot_task, "aws_iot_task", 9216, NULL, 5, NULL, 1);
}

How to control AWS IOT devices with Alexa?

Hi,
I have encountered problems with controlling ESP32 via Alexa.

  • ESP32 accesses AWS IOT via aws-iot-device-sdk-embedded-C

Is there any way to control esp32 through alexa?

Using aws-iot shadow along with publish on topic causing tls error -0x4e (IDFGH-3977) (CA-96)

Environment

  • Development Kit: [ESP32-DevKitC]
  • Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4]
  • Module or chip used: [ESP32-WROOM-32]
  • IDF version: v4.1
  • Build System: [idf.py]
  • Compiler version: xtensa-esp32-elf-gcc (crosstool-NG esp-2020r2) 8.2.0
  • Operating System: [Linux]
  • Using an IDE?: [No]
  • Power Supply: [USB]

Problem Description

I am using aws-iot component from here and added to the components folder of esp-idf. I want to use both aws-iot shadow service along with publishing some data to another topic. The problem is that I am facing an mbedtls error -0x4e. Sometimes, aws-shadow disconnects as well. I would be grateful if you kindly help me with this issues.

Expected Behavior

These should be no errors in publishing the message to aws topic along with running shadow in parallel. Both threads should work smoothly.

Actual Behavior

Th

Steps to reproduce

Just use the two components of aws-iot i.e. aws-iot shadow and pubsub in parallel as separate threads in app_main

Code to reproduce this issue

Debug Logs

E (340173) aws_iot: failed! mbedtls_ssl_write returned -0x4e
Published: {"DT":2,"T":53,"S":0,"P":10.1,"F":999.9,"E":999.9,"U":11.1,"A":999,"LO":-122.200682,"LA":37.692625}I (340273) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (340273) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (340283) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (340293) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (340303) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (340323) mbedtls: ssl_tls.c:8270 => read

I (340323) mbedtls: ssl_tls.c:4311 => read record

I (340323) mbedtls: ssl_tls.c:2536 => fetch input

I (340333) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (340433) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (340433) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (340433) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (340443) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (340453) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (340473) mbedtls: ssl_tls.c:8270 => read

I (340473) mbedtls: ssl_tls.c:4311 => read record

I (340473) mbedtls: ssl_tls.c:2536 => fetch input

I (340483) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (340583) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (340583) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (340583) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (340593) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (340603) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (340623) mbedtls: ssl_tls.c:8270 => read

I (340623) mbedtls: ssl_tls.c:4311 => read record

I (340623) mbedtls: ssl_tls.c:2536 => fetch input

I (340633) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (340733) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (340733) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (340733) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (340743) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (340753) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (340773) mbedtls: ssl_tls.c:8270 => read

I (340773) mbedtls: ssl_tls.c:4311 => read record

I (340773) mbedtls: ssl_tls.c:2536 => fetch input

I (340783) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (340883) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (340883) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (340883) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (340893) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (340903) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (340923) mbedtls: ssl_tls.c:8270 => read

I (340923) mbedtls: ssl_tls.c:4311 => read record

I (340923) mbedtls: ssl_tls.c:2536 => fetch input

I (340933) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341033) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341033) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341033) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341043) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341053) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341073) mbedtls: ssl_tls.c:8270 => read

I (341073) mbedtls: ssl_tls.c:4311 => read record

I (341073) mbedtls: ssl_tls.c:2536 => fetch input

I (341083) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341183) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341183) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341183) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341193) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341203) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341223) mbedtls: ssl_tls.c:8270 => read

I (341223) mbedtls: ssl_tls.c:4311 => read record

I (341223) mbedtls: ssl_tls.c:2536 => fetch input

I (341233) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341333) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341333) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341333) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341343) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341353) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341373) mbedtls: ssl_tls.c:8270 => read

I (341373) mbedtls: ssl_tls.c:4311 => read record

I (341373) mbedtls: ssl_tls.c:2536 => fetch input

I (341383) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341483) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341483) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341483) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341493) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341503) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341523) mbedtls: ssl_tls.c:8270 => read

I (341523) mbedtls: ssl_tls.c:4311 => read record

I (341523) mbedtls: ssl_tls.c:2536 => fetch input

I (341533) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341633) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341633) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341633) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341643) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341653) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341673) mbedtls: ssl_tls.c:8270 => read

I (341673) mbedtls: ssl_tls.c:4311 => read record

I (341673) mbedtls: ssl_tls.c:2536 => fetch input

I (341683) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341783) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341783) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341783) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341793) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341803) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341823) mbedtls: ssl_tls.c:8270 => read

I (341823) mbedtls: ssl_tls.c:4311 => read record

I (341823) mbedtls: ssl_tls.c:2536 => fetch input

I (341833) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (341933) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (341933) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (341933) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (341943) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (341953) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (341973) mbedtls: ssl_tls.c:8270 => read

I (341973) mbedtls: ssl_tls.c:4311 => read record

I (341973) mbedtls: ssl_tls.c:2536 => fetch input

I (341983) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342083) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342083) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342083) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342093) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (342103) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (342123) mbedtls: ssl_tls.c:8270 => read

I (342123) mbedtls: ssl_tls.c:4311 => read record

I (342123) mbedtls: ssl_tls.c:2536 => fetch input

I (342133) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342213) RX_UART_TASK: Read 99 bytes: '{"DT":2,"T":53,"S":0,"P":10.1,"F":999.9,"E":999.9,"U":11.1,"A":999,"LO":-122.200682,"LA":37.692625}

I (342233) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342233) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342233) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342243) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (342253) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (342273) mbedtls: ssl_tls.c:8270 => read

I (342273) mbedtls: ssl_tls.c:4311 => read record

I (342273) mbedtls: ssl_tls.c:2536 => fetch input

I (342283) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342383) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342383) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342383) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342393) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (342403) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (342423) mbedtls: ssl_tls.c:8270 => read

I (342423) mbedtls: ssl_tls.c:4311 => read record

I (342423) mbedtls: ssl_tls.c:2536 => fetch input

I (342433) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342533) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342533) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342533) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342543) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (342553) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (342573) mbedtls: ssl_tls.c:8270 => read

I (342573) mbedtls: ssl_tls.c:4311 => read record

I (342573) mbedtls: ssl_tls.c:2536 => fetch input

I (342583) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342683) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342683) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342683) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342693) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (342703) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (342723) mbedtls: ssl_tls.c:8270 => read

I (342723) mbedtls: ssl_tls.c:4311 => read record

I (342723) mbedtls: ssl_tls.c:2536 => fetch input

I (342733) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342833) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342833) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342833) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342843) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (342853) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (342873) mbedtls: ssl_tls.c:8270 => read

I (342873) mbedtls: ssl_tls.c:4311 => read record

I (342873) mbedtls: ssl_tls.c:2536 => fetch input

I (342883) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (342983) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (342983) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (342983) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (342993) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (343003) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (343023) mbedtls: ssl_tls.c:8270 => read

I (343023) mbedtls: ssl_tls.c:4311 => read record

I (343023) mbedtls: ssl_tls.c:2536 => fetch input

I (343033) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (343133) mbedtls: ssl_tls.c:2721 in_left: 0, nb_want: 5

I (343133) mbedtls: ssl_tls.c:2722 ssl->f_recv(_timeout)() returned -26624 (-0x6800)

W (343133) mbedtls: ssl_tls.c:4973 mbedtls_ssl_fetch_input() returned -26624 (-0x6800)

W (343143) mbedtls: ssl_tls.c:4344 ssl_get_next_record() returned -26624 (-0x6800)

W (343153) mbedtls: ssl_tls.c:8335 mbedtls_ssl_read_record() returned -26624 (-0x6800)

I (343173) mbedtls: ssl_tls.c:8270 => read

I (343173) mbedtls: ssl_tls.c:4311 => read record

I (343173) mbedtls: ssl_tls.c:2536 => fetch input

I (343183) mbedtls: ssl_tls.c:2697 in_left: 0, nb_want: 5

I (343193) mbedtls: ssl_tls.c:8682 => write

I (343193) mbedtls: ssl_tls.c:2755 => flush output

I (343193) mbedtls: ssl_tls.c:2774 message length: 168, out_left: 168

I (343203) mbedtls: ssl_tls.c:2779 ssl->f_send() returned -78 (-0x004e)

W (343213) mbedtls: ssl_tls.c:8612 mbedtls_ssl_flush_output() returned -78 (-0x004e)

I (343223) mbedtls: ssl_tls.c:8710 <= write

Other items if possible

  • sdkconfig file (attach the sdkconfig file from your project folder)
  • elf file in the build folder (note this may contain all the code details and symbols of your project.)
  • coredump (This provides stacks of tasks.)

subscribe publish example run time crash.

I am new to this environment and may be not able to understand the output log. This code is crashing i have given the output below,Please take a look, Thanks in advance.
I am working with

  1. ESP-SOLO 1 board which is single core .
  2. IDF-Version v3.2.
  3. I have configured all menuconfig configrations and re-checked the same.
  4. warning in code are unused decleration of 3 variables
    aws_root_ca_pem_end,certificate_pem_crt_end and private_pem_key_end

output is:
$make monitor
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
Python requirements from C:/msys32/home/Chipwire/esp/esp-idf/requirements.txt ar e satisfied.
MONITOR
--- idf_monitor on COM7 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6196
load:0x40078000,len:10180
ho 0 tail 12 room 4
load:0x40080400,len:6640
entry 0x40080760
I (30) boot: ESP-IDF v3.2-dirty 2nd stage bootloader
I (30) boot: compile time 11:07:50
I (30) boot: Enabling RNG early entropy source...
I (35) boot: SPI Speed : 40MHz
I (39) boot: SPI Mode : DIO
I (43) boot: SPI Flash Size : 4MB
I (47) boot: Partition Table:
I (51) boot: ## Label Usage Type ST Offset Length
I (58) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (66) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (73) boot: 2 factory factory app 00 00 00010000 00100000
I (81) boot: End of partition table
I (85) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x18ff8 (102392) map
I (130) esp_image: segment 1: paddr=0x00029020 vaddr=0x3ffb0000 size=0x027f0 ( 10224) load
I (134) esp_image: segment 2: paddr=0x0002b818 vaddr=0x40080000 size=0x00400 ( 1024) load
0x40080000: _WindowOverflow4 at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

I (137) esp_image: segment 3: paddr=0x0002bc20 vaddr=0x40080400 size=0x043f0 ( 17392) load
I (153) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x81838 (530488) map
0x400d0018: _stext at ??:?

I (340) esp_image: segment 5: paddr=0x000b1858 vaddr=0x400847f0 size=0x0c430 ( 50224) load
0x400847f0: ieee80211_output_process at ??:?

I (371) boot: Loaded app from partition at offset 0x10000
I (371) boot: Disabling RNG early entropy source...
I (371) cpu_start: Pro cpu up.
I (375) cpu_start: Single core mode
I (379) heap_init: Initializing. RAM available for dynamic allocation:
I (386) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (392) heap_init: At 3FFB8778 len 00027888 (158 KiB): DRAM
I (399) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (405) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (411) heap_init: At 40090C20 len 0000F3E0 (60 KiB): IRAM
I (417) cpu_start: Pro cpu start user code
I (100) cpu_start: Starting scheduler on PRO CPU.
I (123) wifi: wifi driver task: 3ffbf1b8, prio:23, stack:3584, core=0
I (123) wifi: wifi firmware version: 9415913
I (123) wifi: config NVS flash: enabled
I (123) wifi: config nano formating: disabled
I (123) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (133) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (153) wifi: Init dynamic tx buffer num: 32
I (153) wifi: Init data frame dynamic rx buffer num: 32
I (153) wifi: Init management frame dynamic rx buffer num: 32
I (163) wifi: Init static rx buffer size: 1600
I (163) wifi: Init static rx buffer num: 10
I (173) wifi: Init dynamic rx buffer num: 32
I (173) subpub: Setting WiFi configuration SSID Redmi...
I (233) phy: phy_version: 4008, c9ae59f, Jan 25 2019, 16:54:06, 0, 0
I (233) wifi: mode : sta (24:0a:c4:85:ca:64)
C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:1069 (prvAddNewTaskToReadyList)- assert failed!
abort() was called at PC 0x4008b73a on core 0
0x4008b73a: prvAddNewTaskToReadyList at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:3537

Backtrace: 0x4008e564:0x3ffb9a20 0x4008e771:0x3ffb9a40 0x4008b73a:0x3ffb9a60 0x4008b8a3:0x3ffb9a80 0x400d2db9:0x3ffb9ac0 0x400d0e84:0x3ffb9af0 0x4008c4e1:0x3ffb9b10
0x4008e564: invoke_abort at C:/msys32/home/Chipwire/esp/esp-idf/components/esp32/panic.c:707

0x4008e771: abort at C:/msys32/home/Chipwire/esp/esp-idf/components/esp32/panic.c:707

0x4008b73a: prvAddNewTaskToReadyList at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:3537

0x4008b8a3: xTaskCreatePinnedToCore at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:3537

0x400d2db9: app_main at C:/msys32/home/Chipwire/esp/esp-aws-iot-master/examples/subscribe_publish/main/subscribe_publish_sample.c:331

0x400d0e84: main_task at C:/msys32/home/Chipwire/esp/esp-idf/components/esp32/cpu_start.c:494

0x4008c4e1: vPortTaskWrapper at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/port.c:403

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6196
load:0x40078000,len:10180
ho 0 tail 12 room 4
load:0x40080400,len:6640
entry 0x40080760
I (31) boot: ESP-IDF v3.2-dirty 2nd stage bootloader
I (31) boot: compile time 11:07:50
I (31) boot: Enabling RNG early entropy source...
I (36) boot: SPI Speed : 40MHz
I (40) boot: SPI Mode : DIO
I (44) boot: SPI Flash Size : 4MB
I (48) boot: Partition Table:
I (52) boot: ## Label Usage Type ST Offset Length
I (59) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (66) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (74) boot: 2 factory factory app 00 00 00010000 00100000
I (81) boot: End of partition table
I (85) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x18ff8 (102392) map
I (130) esp_image: segment 1: paddr=0x00029020 vaddr=0x3ffb0000 size=0x027f0 ( 10224) load
I (135) esp_image: segment 2: paddr=0x0002b818 vaddr=0x40080000 size=0x00400 ( 100x40080000: _WindowOverflow4 at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

  1. load
    I (137) esp_image: segment 3: paddr=0x0002bc20 vaddr=0x40080400 size=0x043f0 ( 17392) load
    I (153) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x81838 (530488) map
    0x400d0018: _stext at ??:?

I (341) esp_image: segment 5: paddr=0x000b1858 vaddr=0x400847f0 size=0x0c430 ( 50224) load
0x400847f0: ieee80211_output_process at ??:?

I (371) boot: Loaded app from partition at offset 0x10000
I (372) boot: Disabling RNG early entropy source...
I (372) cpu_start: Pro cpu up.
I (376) cpu_start: Single core mode
I (380) heap_init: Initializing. RAM available for dynamic allocation:
I (387) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (393) heap_init: At 3FFB8778 len 00027888 (158 KiB): DRAM
I (399) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (406) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (412) heap_init: At 40090C20 len 0000F3E0 (60 KiB): IRAM
I (418) cpu_start: Pro cpu start user code
I (100) cpu_start: Starting scheduler on PRO CPU.
I (123) wifi: wifi driver task: 3ffbf1b8, prio:23, stack:3584, core=0
I (123) wifi: wifi firmware version: 9415913
I (123) wifi: config NVS flash: enabled
I (123) wifi: config nano formating: disabled
I (123) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (133) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (153) wifi: Init dynamic tx buffer num: 32
I (153) wifi: Init data frame dynamic rx buffer num: 32
I (153) wifi: Init management frame dynamic rx buffer num: 32
I (163) wifi: Init static rx buffer size: 1600
I (163) wifi: Init static rx buffer num: 10
I (173) wifi: Init dynamic rx buffer num: 32
I (173) subpub: Setting WiFi configuration SSID Redmi...
I (233) phy: phy_version: 4008, c9ae59f, Jan 25 2019, 16:54:06, 0, 0
I (233) wifi: mode : sta (24:0a:c4:85:ca:64)
C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:1069 (prvAddNewTaskToReadyList)- assert failed!
abort() was called at PC 0x4008b73a on core 0
0x4008b73a: prvAddNewTaskToReadyList at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:3537

Backtrace: 0x4008e564:0x3ffb9a20 0x4008e771:0x3ffb9a40 0x4008b73a:0x3ffb9a60 0x4008b8a3:0x3ffb9a80 0x400d2db9:0x3ffb9ac0 0x400d0e84:0x3ffb9af0 0x4008c4e1:0x3ffb9b10
0x4008e564: invoke_abort at C:/msys32/home/Chipwire/esp/esp-idf/components/esp32/panic.c:707

0x4008e771: abort at C:/msys32/home/Chipwire/esp/esp-idf/components/esp32/panic.c:707

0x4008b73a: prvAddNewTaskToReadyList at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:3537

0x4008b8a3: xTaskCreatePinnedToCore at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/tasks.c:3537

0x400d2db9: app_main at C:/msys32/home/Chipwire/esp/esp-aws-iot-master/examples/subscribe_publish/main/subscribe_publish_sample.c:331

0x400d0e84: main_task at C:/msys32/home/Chipwire/esp/esp-idf/components/esp32/cpu_start.c:494

0x4008c4e1: vPortTaskWrapper at C:/msys32/home/Chipwire/esp/esp-idf/components/freertos/port.c:403

(Possible) Memory leak in connect/disconnect loop (CA-79)

Hello,

I see that doing this kind of loop, the free heap decreases if an internet loss occurs in the ssl handshake step.
After a few disconnections, this ends up in a device that can never again connect to AWS.

This is the snippet:

while (1) {
	ESP_LOGI(TAG, "Free memory: %d bytes", esp_get_free_heap_size());
	rc = aws_iot_shadow_connect(&mqttClient, &scp);
	if (SUCCESS != rc)
	{
		ESP_LOGE(TAG, "aws_iot_shadow_connect returned error %d", rc);
	}
	ESP_LOGI(TAG, "Free memory: %d bytes", esp_get_free_heap_size());
	vTaskDelay(pdMS_TO_TICKS(500));
	rc = aws_iot_shadow_disconnect(&mqttClient);
	if (SUCCESS != rc)
	{
		ESP_LOGE(TAG, "aws_iot_shadow_disconnect returned error %d", rc);
	}
	vTaskDelay(pdMS_TO_TICKS(500));
}

And here is the output, I commented the disconnection events.

(2609) shadow_manager: Free memory: 117904 bytes
(2979) wifi: Notification of a time synchronization event
(6869) shadow_manager: Free memory: 87896 bytes
(7889) shadow_manager: Free memory: 117232 bytes
(12189) shadow_manager: Free memory: 87900 bytes
(13209) shadow_manager: Free memory: 117236 bytes                        // DISCONNECTION
(21919) aws_iot: failed! mbedtls_ssl_handshake returned -0x6800
(21919) shadow_manager: aws_iot_shadow_connect returned error -4
(21919) shadow_manager: Free memory: 113768 bytes
(22439) aws_iot: failed! mbedtls_ssl_write returned -0x7100
(22939) shadow_manager: Free memory: 113776 bytes                       // RECONNECTION
(29799) shadow_manager: Free memory: 84460 bytes                        // Now Free heap is ~ 3400 less than ~ 117200
(30819) shadow_manager: Free memory: 113776 bytes
(34919) shadow_manager: Free memory: 84456 bytes
(35939) shadow_manager: Free memory: 113776 bytes                      // DISCONNECTION, but no handshake error
(54219) aws_iot: failed! mbedtls_net_connect returned -0x44
(54219) shadow_manager: aws_iot_shadow_connect returned error -24
(54219) shadow_manager: Free memory: 113776 bytes
(54739) aws_iot: failed! mbedtls_ssl_write returned -0x7100
(55239) shadow_manager: Free memory: 113776 bytes                       // RECONNECTION
(65439) shadow_manager: Free memory: 84460 bytes                        // Now Free heap is the same as before ~113700
(66459) shadow_manager: Free memory: 113776 bytes                       // DISCONNECTION
(75369) aws_iot: failed! mbedtls_ssl_handshake returned -0x6800
(75369) shadow_manager: aws_iot_shadow_connect returned error -4
(75369) shadow_manager: Free memory: 110424 bytes
(75889) aws_iot: failed! mbedtls_ssl_write returned -0x7100
(76389) shadow_manager: Free memory: 110424 bytes
(94719) aws_iot: failed! mbedtls_net_connect returned -0x44
(94719) shadow_manager: aws_iot_shadow_connect returned error -24
(94719) shadow_manager: Free memory: 110424 bytes
(95239) aws_iot: failed! mbedtls_ssl_write returned -0x7100
(95739) shadow_manager: Free memory: 110424 bytes                       // RECONNECTION
(102919) shadow_manager: Free memory: 81128 bytes                        // Now Free heap is ~ 3400 less than ~ 113700
(103939) shadow_manager: Free memory: 110424 bytes
(108239) shadow_manager: Free memory: 81128 bytes
(109259) shadow_manager: Free memory: 110424 bytes

Is there any way of cleaning things up ? I trying cleaning the underlying ssl context without luck.

Thank you !

device certificate verification fail (CA-130)

Hello all,

I am facing issue while connecting my esp32s2 device with the AWS cloud. I have followed below steps:

  1. I have created my own root CA and registered in the AWS using below steps:
    https://docs.aws.amazon.com/iot/latest/developerguide/register-CA-cert.html
  2. Created device certificate using the above generated root CA and registered it with my IoT thing. Followed below link for the same.
    https://docs.aws.amazon.com/iot/latest/developerguide/manual-cert-registration.html
  3. Now I am using that device certificate, device private key and generated root CA for communicating with AWS by placing it on the below path:
    https://github.com/espressif/esp-aws-iot/tree/master/examples/thing_shadow/main/certs
    Built it and flashed the bins, the device is trying to communicate with the AWS cloud. But the TLS is failing. Attached the logs for the reference.
    fail.log

Is there something or some steps which I am missing?

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.