STM32L4_Discovery_Kit - WiFi connection fails

amveeq wrote on April 24, 2018:

I’ve been working on the AWS example with the above mentioned STM32 board but I have problems to get the WiFi initialized/power on.
I have been successful with another (non-FreeRTOS) example to get the WiFi to work and connect to AP but the AWS example “Connect to AWS IoT - ST” refuses to co-operate.
I’m using Atollic TrueStudio (v9.0) as tool chain and I’m able to success fully compile the package and get the example running but there are weird things happening (and/or expected things not happening). I can see that my certificate etc. configuration should be OK and also from the debugger I can see that WiFi AP configuration should be OK. But I only get the following (official) trace to the terminal:


0 0 [Tmr Svc] Starting key provisioning...
1 3 [Tmr Svc] Write root certificate...
2 7 [Tmr Svc] Write device private key...
3 16 [Tmr Svc] Write device certificate...
4 25 [Tmr Svc] Key provisioning done...

I’ve been able to debug that code runs to function WIFI_ON (in file “aws_wifi.c”) but after the line - if( ES_WIFI_Init( it doesn’t return…

Anybody having any idea why and where things fall apart?

Edited by: amveeq on Apr 23, 2018 10:52 PM

Edited by: amveeq on Apr 23, 2018 10:52 PM

Edited by: amveeq on Apr 23, 2018 10:52 PM

Edited by: amveeq on Apr 23, 2018 10:57 PM

Edited by: amveeq on Apr 23, 2018 11:15 PM

Tiangang-AWS wrote on April 24, 2018:

Hello,

We’re running our tests with a WPA2 enabled access point. Could you provide more detail of your configuration?

  1. Which WiFi security type are you using?
  2. Have you tried GCC for ARM toolchain? It is bundled with System Workbench for STM32, and it’s the only compiler toolchain that we have tested for STM32.

Thanks,
Tiangang

amveeq wrote on April 25, 2018:

I’m using WPA2 AP, tried also with open network with no diffference.

OK, the magic word was the tool chain. I finally gave up the Atollic TrueStudio and tried with the traditional STM32 Workbench. With that I at least get the WiFi connected and MQTT echo working in some level. There is still some issues as the trace shows following and I cannot see any messages on the AWS side.


0 0 [Tmr Svc] Starting key provisioning...
1 3 [Tmr Svc] Write root certificate...
2 7 [Tmr Svc] Write device private key...
3 15 [Tmr Svc] Write device certificate...
4 23 [Tmr Svc] Key provisioning done...
5 608 [Tmr Svc] WiFi module initialized.
6 9070 [Tmr Svc] WiFi connected to AP XXXX.
7 9074 [Tmr Svc] IP Address acquired 192.168.1.15
8 9079 [Tmr Svc] Creating MQTT Echo Task...
9 9083 [MQTTEcho] MQTT echo attempting to connect to "yyyyy".iot.eu-central-1.amazonaws.com.10 9092 [MQTTEcho] Sending command to MQTT task.
11 9096 [MQTT] Received message 10000 from queue.
12 33262 [MQTT] About to close socket.
13 33500 [MQTT] Socket closed.
14 33502 [MQTT] Notifying task.
15 33505 [MQTTEcho] Command sent to MQTT task failed.
16 33510 [MQTTEcho] ERROR:  MQTT echo failed to connect.
17 33516 [MQTTEcho] MQTT echo test could not connect to broker.
18 33521 [MQTTEcho] Sending command to MQTT task.
19 33526 [MQTT] Received message 20000 from queue.
20 33531 [MQTT] Notifying task.
21 33534 [MQTTEcho] Command sent to MQTT task passed.
22 33539 [MQTTEcho] MQTT echo demo finished.

According to the code it should be sending message every 5sec during 1 min.

Edited by: amveeq on Apr 25, 2018 8:41 AM

Tiangang-AWS wrote on April 25, 2018:

Hi,

Could you verify that your endpoint, thing, certificate and policy are all configured correctly in your AWS IoT console? You can follow the getting started guide here, https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_st.html. Look for “Configure Your Project” in the middle of the doc.

Make sure you have permission to connect to AWS IoT, your policy is attached to certificate, and certificate is attached to the thing you created. You can find information here, https://docs.aws.amazon.com/freertos/latest/userguide/freertos-prereqs.html. Look for “Registering Your MCU Board with AWS IoT”

Let me know if you’re still having problem and need further assist to debug.

Thanks,
Tiangang

amveeq wrote on April 30, 2018:

Sorry for the longish reply time, I was occupied with some other stuff so was able to come back to this project today.
I did follow (again) the instructions pointed and assume everything should be OK, but the results are still the same. Terminal traces giving the same output as above. From the IoT console’s “Monitor”-dashboard I can though see (as I did with my previous configuration too) some successful connections, both MQTT and HTTP messages, connect/ping/publish/subscribe types etc.
But in “Test”-view I cannot see any messages/topics as I would expect based on the example description, using topic freertos/demos/echo. When opening the “test”-view I do get pop-up "Connected to Device Gateway on client ID “iotconsole-numberstring”. Also I can seen there that “+Custom endpoint Enabled. This is your custom endpoint that allows you to connect to AWS IoT. Each of your Things has a REST API available at this endpoint. This is also an important property to insert when using an MQTT client or the AWS IoT Device SDK.+
+Your endpoint is provisioned and ready to use. You can now start to publish and subscribe to topics.+”

Tiangang-AWS wrote on April 30, 2018:

Hi,

A quick way to verify if your cert and key are working is to try mosquitto https://mosquitto.org/download/. This command will publish a message to AWS IoT, mosquitto_pub -d --cafile [root certficate] --cert [your device certificate] --key [private key] -h [AWS IoT endpoint] -p 8883 -m “a test message” -t “test/topic” -q 1.

Meanwhile, can you also check if your cert is activated or not? On the certificate page, the status will be displayed under the certificate name.

Thanks,
Tiangang