espressif / esp-aws-iot

AWS IoT SDK for ESP32 based chipsets
Apache License 2.0
266 stars 157 forks source link

ESP-AWS-IoT support for fleet provisioning (CA-182) #87

Open helaagardabbou opened 2 years ago

helaagardabbou commented 2 years ago

Hello please when the ESP-AWS-IoT component will support fleet provisioning ?

SolidStateLEDLighting commented 2 years ago

If you count all the characters from a provisioning response, it will be around 3,500. Set your buffer to at least 4k (4096). Give that a try. Buffer over-flows don't crash the application, you just don't receive the data. This LoadProhibited error is from something else -- like a bad pointer.

Remember to always circle back around to MQTT_ProcessLoop() for the results of each action (construct a large state driven super loop). You will receive a response in the loop for pretty much everything you do.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:37 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

I have attempted to follow the example as @twlawrencekohttps://github.com/twlawrenceko has mentioned, where when processing MQTT_ProcessLoop() will cause LoadProhibited error to show up. The exact linehttps://github.com/lawrenceko-intecular/esp-aws-iot-for-fleet-provisioning/blob/b4e7158efaa831131e1b32208d450fb828c3714f/examples/fleet_prov_simple/main/shadow_demo_main.c#L1019

I have read some issues mentioning the buffer size, currently is set to 2048 and still crashing. However, when commented out the publishing topic, the crash occurs less often but still happens overtime.

Below is the log:

Info: Establishing MQTT session with claim certificate... I (5603) coreMQTT: Establishing a TLS session to a3s528xxxxxx4b-ats.iot.us-east-1.amazonaws.com:8883. I (7763) coreMQTT: Packet received. ReceivedBytes=2. I (7763) coreMQTT: CONNACK session present bit set. I (7763) coreMQTT: Connection accepted. I (7763) coreMQTT: Received MQTT CONNACK successfully from broker. I (7773) coreMQTT: MQTT connection established with the broker. I (7783) coreMQTT: MQTT connection successfully established with broker. I (7793) coreMQTT: An MQTT session with broker is re-established. Resending unacked publishes. Info: Established connection with claim credentials. I (7803) coreMQTT: SUBSCRIBE topic $aws/certificates/create/json/accepted to broker. I (7963) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (10963) coreMQTT: SUBSCRIBE topic $aws/certificates/create/json/rejected to broker. I (11143) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (13403) coreMQTT: SUBSCRIBE topic $aws/provisioning-templates/IVO1-FleetProvisioning/provision/json/accepted to broker. I (13533) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (16533) coreMQTT: SUBSCRIBE topic $aws/provisioning-templates/IVO1-FleetProvisioning/provision/json/rejected to broker. I (16673) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (19673) coreMQTT: Published payload: I (19673) coreMQTT: PUBLISH sent for topic $aws/certificates/create/json to broker with packet ID 5. I (19843) coreMQTT: Packet received. ReceivedBytes=2. I (19843) coreMQTT: Ack packet deserialized with result: MQTTSuccess. I (19853) coreMQTT: State record updated. New state=MQTTPublishDone. Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump: PC : 0x4000c619 PS : 0x00060f30 A0 : 0x800da214 A1 : 0x3ffbb350 A2 : 0x00000000 A3 : 0x3f4065e8 A4 : 0x00000022 A5 : 0x0000ff00 A6 : 0x0000000f A7 : 0xff000000 A8 : 0x00000002 A9 : 0x3ffbb000 A10 : 0x3ffbb020 A11 : 0x3f405952 A12 : 0x3ffbb284 A13 : 0x3ffaf02c A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x0000001c EXCVADDR: 0x00000002 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffb

Backtrace:0x4000c616:0x3ffbb3500x400da211:0x3ffbb370 0x400da330:0x3ffbb390 0x400da434:0x3ffbb3c0 0x400d70b6:0x3ffbb3e0 0x400d8b41:0x3ffbb410 0x400d8bd6:0x3ffbb450 0x400d8cd7:0x3ffbb480 0x400d8d15:0x3ffbb4b0 0x400d775d:0x3ffbb4d0 0x400d7202:0x3ffbb4f0 0x400d72a4:0x3ffbb510 0x400d70a5:0x3ffbb530 0x40156b1d:0x3ffbb550 0x4008b525:0x3ffbb570 0x400da211: consumeIfMatch at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:587

0x400da330: parseCreateCertificateFromCsrTopic at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:458

0x400da434: FleetProvisioning_MatchTopic at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:744

0x400d70b6: provisioningPublishCallback at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_main.c:870

0x400d8b41: handlePublishAcks at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:1195

0x400d8bd6: handleIncomingAck at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:1241

0x400d8cd7: receiveSingleIteration at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:1342

0x400d8d15: MQTT_ProcessLoop at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:2185

0x400d775d: ProcessLoop at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_helpers.c:941

0x400d7202: waitForResponse at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_main.c:776

0x400d72a4: aws_iot_demo_main at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_main.c:1019

0x400d70a5: app_main at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/app_main.c:58 (discriminator 2)

0x40156b1d: main_task at /home/espuser/esp/esp-idf/components/freertos/port/port_common.c:129 (discriminator 2)

0x4008b525: vPortTaskWrapper at /home/espuser/esp/esp-idf/components/freertos/port/xtensa/port.c:131

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149451470, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKEYGTX3ZYEXVMIVOZY3VOAPP7ANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

law-ko commented 2 years ago

We have also noticed that is is around 3500, but the idf.py menuconfig limits to 2048, so we should manually change it to 4096?

One thing we have is this receiving messages after each subscribe, is this correct behavior?

I (14213) coreMQTT: Packet received. ReceivedBytes=3.
Warn: Unexpected publish message received. Topic: .
SolidStateLEDLighting commented 2 years ago

HEY -- One more thing --- increase your stack size in that IOT task handler to about 16k (16,384) and examine if you like the HighWaterMark to analyze your memory usage as needed.

If you run out of memory in the task handler, you will crash.


From: keith ssledlighting.com @.> Sent: Wednesday, June 8, 2022 12:46 PM To: espressif/esp-aws-iot @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

If you count all the characters from a provisioning response, it will be around 3,500. Set your buffer to at least 4k (4096). Give that a try. Buffer over-flows don't crash the application, you just don't receive the data. This LoadProhibited error is from something else -- like a bad pointer.

Remember to always circle back around to MQTT_ProcessLoop() for the results of each action (construct a large state driven super loop). You will receive a response in the loop for pretty much everything you do.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:37 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

I have attempted to follow the example as @twlawrencekohttps://github.com/twlawrenceko has mentioned, where when processing MQTT_ProcessLoop() will cause LoadProhibited error to show up. The exact linehttps://github.com/lawrenceko-intecular/esp-aws-iot-for-fleet-provisioning/blob/b4e7158efaa831131e1b32208d450fb828c3714f/examples/fleet_prov_simple/main/shadow_demo_main.c#L1019

I have read some issues mentioning the buffer size, currently is set to 2048 and still crashing. However, when commented out the publishing topic, the crash occurs less often but still happens overtime.

Below is the log:

Info: Establishing MQTT session with claim certificate... I (5603) coreMQTT: Establishing a TLS session to a3s528xxxxxx4b-ats.iot.us-east-1.amazonaws.com:8883. I (7763) coreMQTT: Packet received. ReceivedBytes=2. I (7763) coreMQTT: CONNACK session present bit set. I (7763) coreMQTT: Connection accepted. I (7763) coreMQTT: Received MQTT CONNACK successfully from broker. I (7773) coreMQTT: MQTT connection established with the broker. I (7783) coreMQTT: MQTT connection successfully established with broker. I (7793) coreMQTT: An MQTT session with broker is re-established. Resending unacked publishes. Info: Established connection with claim credentials. I (7803) coreMQTT: SUBSCRIBE topic $aws/certificates/create/json/accepted to broker. I (7963) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (10963) coreMQTT: SUBSCRIBE topic $aws/certificates/create/json/rejected to broker. I (11143) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (13403) coreMQTT: SUBSCRIBE topic $aws/provisioning-templates/IVO1-FleetProvisioning/provision/json/accepted to broker. I (13533) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (16533) coreMQTT: SUBSCRIBE topic $aws/provisioning-templates/IVO1-FleetProvisioning/provision/json/rejected to broker. I (16673) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . I (19673) coreMQTT: Published payload: I (19673) coreMQTT: PUBLISH sent for topic $aws/certificates/create/json to broker with packet ID 5. I (19843) coreMQTT: Packet received. ReceivedBytes=2. I (19843) coreMQTT: Ack packet deserialized with result: MQTTSuccess. I (19853) coreMQTT: State record updated. New state=MQTTPublishDone. Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump: PC : 0x4000c619 PS : 0x00060f30 A0 : 0x800da214 A1 : 0x3ffbb350 A2 : 0x00000000 A3 : 0x3f4065e8 A4 : 0x00000022 A5 : 0x0000ff00 A6 : 0x0000000f A7 : 0xff000000 A8 : 0x00000002 A9 : 0x3ffbb000 A10 : 0x3ffbb020 A11 : 0x3f405952 A12 : 0x3ffbb284 A13 : 0x3ffaf02c A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x0000001c EXCVADDR: 0x00000002 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffb

Backtrace:0x4000c616:0x3ffbb3500x400da211:0x3ffbb370 0x400da330:0x3ffbb390 0x400da434:0x3ffbb3c0 0x400d70b6:0x3ffbb3e0 0x400d8b41:0x3ffbb410 0x400d8bd6:0x3ffbb450 0x400d8cd7:0x3ffbb480 0x400d8d15:0x3ffbb4b0 0x400d775d:0x3ffbb4d0 0x400d7202:0x3ffbb4f0 0x400d72a4:0x3ffbb510 0x400d70a5:0x3ffbb530 0x40156b1d:0x3ffbb550 0x4008b525:0x3ffbb570 0x400da211: consumeIfMatch at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:587

0x400da330: parseCreateCertificateFromCsrTopic at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:458

0x400da434: FleetProvisioning_MatchTopic at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:744

0x400d70b6: provisioningPublishCallback at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_main.c:870

0x400d8b41: handlePublishAcks at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:1195

0x400d8bd6: handleIncomingAck at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:1241

0x400d8cd7: receiveSingleIteration at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:1342

0x400d8d15: MQTT_ProcessLoop at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/libraries/coreMQTT/coreMQTT/source/core_mqtt.c:2185

0x400d775d: ProcessLoop at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_helpers.c:941

0x400d7202: waitForResponse at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_main.c:776

0x400d72a4: aws_iot_demo_main at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/shadow_demo_main.c:1019

0x400d70a5: app_main at /home/espuser/esp-public-git/esp-aws-iot-for-fleet-provisioning/examples/fleet_prov_simple/build/../main/app_main.c:58 (discriminator 2)

0x40156b1d: main_task at /home/espuser/esp/esp-idf/components/freertos/port/port_common.c:129 (discriminator 2)

0x4008b525: vPortTaskWrapper at /home/espuser/esp/esp-idf/components/freertos/port/xtensa/port.c:131

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149451470, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKEYGTX3ZYEXVMIVOZY3VOAPP7ANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

SolidStateLEDLighting commented 2 years ago

If my memory serves me well today, that 2048 limit is just set by another file in the system. Do a search in files for "2048" and you'll find it -- change it.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:49 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

We have also noticed that is is around 3500, but the idf.py menuconfig limits to 2048, so we should manually change it to 4096?

One thing we have is this receiving messages after each subscribe, is this correct behavior?

I (14213) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: .

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149457742, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE6PJ3QBUX3KJLSF5I3VOAQ5FANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

SolidStateLEDLighting commented 2 years ago

In addition to a successful result in your subscriptions/publishing -- you should always receive back a message and that message will only be received in the MQTT_ProcessLoop(). Always return to that loop between actions and handle all incoming message or error results.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:49 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

We have also noticed that is is around 3500, but the idf.py menuconfig limits to 2048, so we should manually change it to 4096?

One thing we have is this receiving messages after each subscribe, is this correct behavior?

I (14213) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: .

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149457742, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE6PJ3QBUX3KJLSF5I3VOAQ5FANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

SolidStateLEDLighting commented 2 years ago

HEY -- this error message says: Warn: Unexpected publish message received. Topic: .

You sent a publish message that was unexpected....

And the topic was "."

So, you may not have been subscribed to anything?... and you didn't send a full string message.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:49 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

We have also noticed that is is around 3500, but the idf.py menuconfig limits to 2048, so we should manually change it to 4096?

One thing we have is this receiving messages after each subscribe, is this correct behavior?

I (14213) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: .

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149457742, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE6PJ3QBUX3KJLSF5I3VOAQ5FANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

law-ko commented 2 years ago

HEY -- this error message says: Warn: Unexpected publish message received. Topic: . You sent a publish message that was unexpected.... And the topic was "." So, you may not have been subscribed to anything?... and you didn't send a full string message. ____ From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:49 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87) We have also noticed that is is around 3500, but the idf.py menuconfig limits to 2048, so we should manually change it to 4096? One thing we have is this receiving messages after each subscribe, is this correct behavior? I (14213) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . — Reply to this email directly, view it on GitHub<#87 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE6PJ3QBUX3KJLSF5I3VOAQ5FANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

The log shows

I (14325) coreMQTT: Packet received. ReceivedBytes=3.
Warn: Unexpected publish message received. Topic: .

So I thought it was receiving messages from AWS IoT, not me publishing other topics to AWS IoT.

SolidStateLEDLighting commented 2 years ago

Oh... yea... your hardware received 3 bytes identified as a response to your publish request and it is so small that it doesn't specify the Topic responded to.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 1:26 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

HEY -- this error message says: Warn: Unexpected publish message received. Topic: . You sent a publish message that was unexpected.... And the topic was "." So, you may not have been subscribed to anything?... and you didn't send a full string message. … ____ From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 12:49 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87https://github.com/espressif/esp-aws-iot/issues/87) We have also noticed that is is around 3500, but the idf.py menuconfig limits to 2048, so we should manually change it to 4096? One thing we have is this receiving messages after each subscribe, is this correct behavior? I (14213) coreMQTT: Packet received. ReceivedBytes=3. Warn: Unexpected publish message received. Topic: . — Reply to this email directly, view it on GitHub<#87 (comment)https://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149457742>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE6PJ3QBUX3KJLSF5I3VOAQ5FANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

The log shows

I (14325) coreMQTT: Packet received. ReceivedBytes=3.

Warn: Unexpected publish message received. Topic: .

So I thought it was receiving messages from AWS IoT, not me publishing other topics to AWS IoT.

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149477849, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE5E66HOT2NFGVJDZ3TVOAVHRANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

law-ko commented 2 years ago

The LoadProhibited error occurs when I am trying to print out the JSON payload. I have increased the main task heap size to 8192, is there any other portion that needs to be taken care of giving more space?

SolidStateLEDLighting commented 2 years ago

I have my IOT task heap set to 16k.

I can't quite recall why I set it up that high, except to say that I experimented to come up that number.

Larger is better to get the thing running and then determine how much you can reduce later.


From: lawrenceko-intecular @.> Sent: Wednesday, June 8, 2022 2:22 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

The LoadProhibited error occurs when I am trying to print out the JSON payload. I have increased the main task heap size to 8192, is there any other portion that needs to be taken care of giving more space?

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1149510452, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKEZS4QXFGSOLIFTQCLTVOA3YXANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

law-ko commented 2 years ago

@SolidStateLEDLighting , how did you import the certificates and private keys into PKCS11Session?

/* Insert the claim credentials into the PKCS #11 module */
            pkcs11Status = loadClaimCredentials( p11Session,
                                                CLAIM_CERT_PATH,
                                                "Claim Cert",
                                                CLAIM_PRIVATE_KEY_PATH,
                                                "Claim Key" );

This is what AWS embedded C has provided, however, within ESP, the path would not be valid as it cannot find where the certificate is located.

SolidStateLEDLighting commented 2 years ago

I do not recognize the loadClaimCredentials command that you use here.

What is the loadClaimCredentials doing for you?

In my work the provisioning credentials arrive in a text file and are immediately usable.

Why do the credentials need to be loaded into PKCS11?


From: lawrenceko-intecular @.> Sent: Thursday, June 9, 2022 11:53 AM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

@SolidStateLEDLightinghttps://github.com/SolidStateLEDLighting , how did you import the certificates and private keys into PKCS11Session?

/ Insert the claim credentials into the PKCS #11 module / pkcs11Status = loadClaimCredentials( p11Session, CLAIM_CERT_PATH, "Claim Cert", CLAIM_PRIVATE_KEY_PATH, "Claim Key" );

This is what AWS embedded C has provided, however, within ESP, the path would not be valid as it cannot find where the certificate is located.

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1150639717, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE7I3VR6HLHMMUVMSF3VOFTEZANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

law-ko commented 2 years ago

How did you load the incoming credentials inside EstablishMqttSession?

In ESP's example, they put the client.crt and client.key before hand and I do not see where in the code it loads the certificates and keys. In AWS' example, they use PKCS11 to load the new credentials after getting from Fleet Provisioning topics.

SolidStateLEDLighting commented 2 years ago

Keep in mind that I did not provision with a csr

NetworkCredentials_t opensslCredentials = (NetworkCredentials_t )malloc(sizeof(NetworkCredentials_t));

serverInfo.pHostName = AWS_IOT_ENDPOINT; // Initialize information to connect to the MQTT broker. ESP_LOGI(TAG, "Connecting to %s", AWS_IOT_ENDPOINT);

serverInfo.hostNameLength = AWS_IOT_ENDPOINT_LENGTH;

serverInfo.port = AWS_MQTT_PORT; ESP_LOGI(TAG, "Port Number to %d", AWS_MQTT_PORT);

opensslCredentials->pClientCert = (const unsigned char )client_cert_pem_start; opensslCredentials->clientCertSize = client_c3_cert_pem_end - client_cert_pem_start; opensslCredentials->pPrivateKey = (const unsigned char )client_key_pem_start; opensslCredentials->privateKeySize = client_c3_key_pem_end - client_key_pem_start;

// Attempt to connect to MQTT broker. If connection fails, retry after a timeout. Timeout value will exponentially increase until maximum attempts are reached. BackoffAlgorithm_InitializeParams(&reconnectParams, CONNECTION_RETRY_BACKOFF_BASE_MS, CONNECTION_RETRY_MAX_BACKOFF_DELAY_MS, CONNECTION_RETRY_MAX_ATTEMPTS);

opensslStatus = TLS_FreeRTOS_Connect(pNetworkContext, serverInfo.pHostName, serverInfo.port, opensslCredentials, TRANSPORT_SEND_RECV_TIMEOUT_MS, TRANSPORT_SEND_RECV_TIMEOUT_MS);

My code is more complicated than this -- but these are fundamentals in that area.


From: lawrenceko-intecular @.> Sent: Thursday, June 9, 2022 12:14 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

How did you load the incoming credentials inside EstablishMqttSession?

In ESP's example, they put the client.crt and client.key before hand and I do not see where in the code it loads the certificates and keys. In AWS' example, they use PKCS11 to load the new credentials after getting from Fleet Provisioning topics.

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1150649261, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKE46KLSQW5YYNFDDZILVOFVTDANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

yucelz commented 1 year ago

@law-ko I appreciate your work, your project helped me to solve my problem.

juanpgg-git commented 1 year ago

Hello there!

this issue has helped me a lot to understand the provisioning by claim.

Is there any documentation on the AWS side that talks about the policies for the certificate and the fleet provisioning policy?

Thanks a lot in advance :)

SolidStateLEDLighting commented 1 year ago

Sure. It is all there on AWS. If you search for it -- there is a workshop that will step you through it.

One area that is confusing is understanding all the dependencies.

Here is a drawing that I made for my own use. You might find this helpful. (I have attached this in email to send back to this thread)


From: Juan Pablo Gomez Garcia @.> Sent: Saturday, April 1, 2023 11:35 PM To: espressif/esp-aws-iot @.> Cc: keith ssledlighting.com @.>; Mention @.> Subject: Re: [espressif/esp-aws-iot] ESP-AWS-IoT support for fleet provisioning (CA-182) (Issue #87)

Hello there!

this issue has helped me a lot to understand the provisioning by claim.

Is there any documentation on the AWS side that talks about the policies for the certificate and the fleet provisioning policy?

Thanks a lot in advance :)

— Reply to this email directly, view it on GitHubhttps://github.com/espressif/esp-aws-iot/issues/87#issuecomment-1493007101, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGGOKEZWGMZJDOHUII3HGYLW7BDNHANCNFSM5LVUHX5A. You are receiving this because you were mentioned.Message ID: @.***>

Ahtasham08 commented 1 year ago

Hi I am trying to compile the example for fleet provisioning using csr but I am getting following error :

C:/Users/ahtas/Documents/GitHub/esp-aws-iot/libraries/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/Fleet-Provisioning-for-AWS-IoT-embedded-sdk/source/fleet_provisioning.c:765:1: fatal error: opening dependency file esp-idf\Fleet-Provisioning-for-AWS-IoT-embedded-sdk\CMakeFiles__idf_Fleet-Provisioning-for-AWS-IoT-embedded-sdk.dir\f7893e654caf0f5cdf916ac2a3b97995\fleet_provisioning.c.obj.d: No such file or directory 765 | } | ^ compilation terminated. ninja: build stopped: subcommand failed.

ithor commented 9 months ago

Hello @Ahtasham08, I was having the same issue. Check your compilation log, I find out that some of the dependencies path where too long; leaving those components off the compilation and then failing the compilation. Go to "C:/Users/ahtas/Documents/GitHub/esp-aws-iot/libraries/" and change the name of the directory Fleet-Provisioning-for-AWS-IoT-embedded-sdk to a shorter name like fleet-provisioning-sdk. Don't forget to also change internal elements like self-named directory and also CMakeLists.txt configuration. Those changes worked to me (with some warnings, but at least it compiled). Hope it helps