espressif / esp-protocols

Collection of ESP-IDF components related to networking protocols
188 stars 131 forks source link

esp-modem and esp-aws-iot for MQTT (IDFGH-11430) #423

Closed marchingband closed 11 months ago

marchingband commented 11 months ago

Answers checklist.

General issue report

I am using BG96 to connect to AWS iot Core over MQTT.

I am using the newest libs foir boith esp-modem and esp-aws-iot I am trying to combine pppos_client axample from esp-modem with mqtt_demo_mutual_auth from esp-aws-iot.

I have all the appropriate certs and keys embedded, and the modem initializes well, and I get an IP address.

The demo file mqtt_demo_mutual_auth.c calls xTlsConnect and this fails with TLS_TRANSPORT_CONNECT_FAILURE.

Researching online, it looks like there is an issue that esp-modem uses lwip, but the esp-aws-iot wants TCP. Indeed, the example files in esp-modem all use the esp-mqtt library, which appears to use lwip. My assumption is that xTlsConnect is not finding the network connection at all.

One problem with trying to learn using the example files is that most of them use C++, so trying to emulate ex. modem_tcp_client for a C context is very hard.

How can I use these 2 powerful libraries together? Would it be possible to publish an example file using C, and not C++?

marchingband commented 11 months ago

it turns out xTlsConnect requires a very long timeout. In coreMQTT/port/network_transport.c, I changed xEspTlsConfig.timeout_ms = 10000. Now everything works well.