Giter Club home page Giter Club logo

Comments (14)

gordonwang0 avatar gordonwang0 commented on July 18, 2024

Hi @velbn,

Thanks for bringing this to our attention. We'll take a look.

from amazon-freertos.

JSchaenzle avatar JSchaenzle commented on July 18, 2024

@velbn I'd be interested to see what the output looks like in the failure case if you enable the MQTT debug logs. You can do so like this: #define mqttconfigENABLE_DEBUG_LOGS 1

By the way, how do you "send a reset via command line"? Are you using a JTAG connection?

from amazon-freertos.

JSchaenzle avatar JSchaenzle commented on July 18, 2024

Also, I can say that I've been doing quite a bit of experimenting with this demo as well and I don't recall seeing this issue.

from amazon-freertos.

velbn avatar velbn commented on July 18, 2024

I don't have the time today to get the logs, but i can say. When i do "make flash monitor" and the demo fails, I press CTRL+T then R. This sends a signal to the board to reset it. I use an external USB to Serial board

from amazon-freertos.

velbn avatar velbn commented on July 18, 2024

This is the logs with mqtt debug enabled
3 2683 [IP-task] vDHCPProcess: offer c0a8081aip
4 2684 [main] WiFi Connected to AP. Creating tasks which use network...
5 2685 [main] Creating MQTT Echo Task...
6 2685 [MQTTEcho] MQTT echo attempting to connect to xxxxxxx.iot.eu-west-2.amazonaws.com.
7 2685 [MQTTEcho] Sending command to MQTT task.
8 2686 [MQTT] Received message 10000 from queue.
9 2692 [IP-task] Socket sending wakeup to MQTT task.
I (27411) PKCS11: Initializing SPIFFS
I (27411) PKCS11: Partition size: total: 52961, used: 0
10 3220 [MQTT] About to close socket.
11 3220 [MQTT] Socket closed.
12 3220 [MQTT] Stack high watermark for MQTT task: 4036
13 3220 [MQTT] Notifying task.
14 3221 [MQTTEcho] Command sent to MQTT task failed.
16 3221 [MQTT] Received message 0 from queue.
15 3221 [MQTTEcho] ERROR: MQTT echo failed to connect.
17 3221 [MQTTEcho] MQTT echo test could not connect to broker.
18 3221 [MQTTEcho] Sending command to MQTT task.
19 3221 [MQTT] Received message 20000 from queue.
20 3221 [MQTT] Notifying task.
21 3221 [MQTTEcho] Command sent to MQTT task passed.
22 3221 [MQTTEcho] MQTT echo demo finished.
23 3221 [MQTTEcho] ----Demo finished----

from amazon-freertos.

dcgaws avatar dcgaws commented on July 18, 2024

velbn, hello, in reviewing https://github.com/aws/amazon-freertos/blob/master/demos/espressif/esp32_devkitc_esp_wrover_kit/common/application_code/main.c#L134, I believe there are some problems. For one thing, FreeRTOS_IPInit is being called before prvWifiConnect. Instead, the app start-up logic should attempt to connect to the network (and ideally confirm/wait) prior to bringing up the TCP/IP stack.

Second, the app demo task is being launched without waiting for vApplicationIPNetworkEventHook to signal that the network is up.

A related note is that FreeRTOS+TCP depends on the PKCS#11 crypto library as a source of random numbers (RNG; including for use in DNS and DHCP packet transaction IDs, as well as selection of outbound ports). In other words, that RNG dependency will be hit early in network stack initialization. In turn, the RNG typically (including in the case of Espressif) has a hardware dependency for gathering entropy. Realistically, those factors combine to result in some delay while bringing up TCP/IP during app start-up.

In summary, network-dependent app business logic should wait for the above to complete for launching. For the Espressif port, reordering Wi-Fi connect to happen first is the first step. Then initialize FreeRTOS+TCP and wait for its NetworkUp callback. Then run the demo task.

from amazon-freertos.

snap40ben avatar snap40ben commented on July 18, 2024

Hi,

First boot always work fine, then if I quit miniterm and start again using make monitor, 50% the wifi connection will fail and display following message.

I (233) WIFI: SYSTEM_EVENT_STA_START
I (353) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (1333) wifi: state: init -> auth (b0)
I (1333) wifi: state: auth -> auth (8a0)
I (2333) wifi: state: auth -> init (2)
I (2333) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (2333) WIFI: SYSTEM_EVENT_STA_DISCONNECTED
1 223 [main] WiFi failed to connect to AP.

If I restart, it will work. Then will fail on next restart, etc...

Do somebody else encountered this on the aws_demo?

Thanks

from amazon-freertos.

iwankruger avatar iwankruger commented on July 18, 2024

Hi has, has anybody been able to solve the inconsistent demo results as reported by velbn?

Seeing similar issues. The demo succeeds sometimes to send MQTT messages to AWS, but does fail often to connect to the MQTT broker.

21 5325 [MQTTEcho] MQTT echo attempting to connect to xxxxxxxx.iot.us-east-1.amazonaws.com.
22 5826 [MQTTEcho] ERROR: MQTT echo failed to connect with error 1.
23 5826 [MQTTEcho] MQTT echo test could not connect to broker.
24 5826 [MQTTEcho] MQTT echo demo finished.
25 5826 [MQTTEcho] ----Demo finished----

from amazon-freertos.

sarenameas avatar sarenameas commented on July 18, 2024

Please try a "make erase_flash" before "make flash monitor". This will clear any invalid certificates or other data in flash memory that may be disrupting your socket connection to the broker.

from amazon-freertos.

mradulan avatar mradulan commented on July 18, 2024

Hi @velbn , are you able to get reliable results on doing make erase_flash and then make flash monitor

from amazon-freertos.

velbn avatar velbn commented on July 18, 2024

if i remembered correctly no.
Did it multiple times i think.
I switched over to the aws iot embedded c sdk that is integrated with the ESP-IDF package

from amazon-freertos.

abhidixi11 avatar abhidixi11 commented on July 18, 2024

@velbn have been unblocked now after switching to c sdk ? Thanks

from amazon-freertos.

yuhui-zheng avatar yuhui-zheng commented on July 18, 2024

It seems things are working, and I'm closing this issue to clean up the ticket queue. Please reach out again, if there's still concern.

from amazon-freertos.

borch84 avatar borch84 commented on July 18, 2024

Hi, I am implementing the demo, I am using esp32 devkitc v1. I was able to connect to mqtt broker not it is not. Here is the message from mqtt debug log:

5 848 [main] Write device private key...
6 860 [main] Creating MQTT Echo Task...
7 860 [MQTTEcho] MQTT echo attempting to connect to XXXXXXXXXXiot.us-east-1.amazonaws.com.
8 860 [MQTTEcho] Sending command to MQTT task.
9 860 [MQTT] Received message 10000 from queue.
10 1861 [IP-task] Socket sending wakeup to MQTT task.
11 2361 [MQTT] About to close socket.
12 2361 [MQTT] Socket closed.
13 2361 [MQTT] Stack high watermark for MQTT task: 4696
14 2361 [MQTT] Notifying task.
15 2361 [MQTT] Received message 0 from queue.
16 2361 [MQTTEcho] Command sent to MQTT task failed.
17 2361 [MQTTEcho] ERROR: MQTT echo failed to connect with error 1.
18 2361 [MQTTEcho] MQTT echo test could not connect to broker.
19 2361 [MQTTEcho] Sending command to MQTT task.
20 2362 [MQTT] Received message 20000 from queue.
21 2362 [MQTT] Notifying task.
22 2363 [MQTTEcho] Command sent to MQTT task passed.
23 2363 [MQTTEcho] MQTT echo demo finished.
24 2363 [MQTTEcho] ----Demo finished----

from amazon-freertos.

Related Issues (20)

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.