/* Connect to AWS IOT using SSLClient and Wiz850io Ethernet Mdoule AWS_Root_CA.h is the trust anchor created using the Root CA from: https://www.amazontrust.com/repository/AmazonRootCA1.pem You can re-create it again using the python file present in SSLClient/tools/pycert_bearssl/pycert_bearssl.py python pycert_bearssl.py convert --no-search refer: https://github.com/OPEnSLab-OSU/SSLClient/issues/17#issuecomment-700143405 Circuit: Ethernet shield WIZ850io: CS 10 MOSI 11 MISO 12 SCK 13 created 10 October 2020 by Ram Rohit Gannavarapu */ #include #include #include #include #include "AWS_Root_CA.h" // This file is created using AmazonRootCA1.pem from https://www.amazontrust.com/repository/AmazonRootCA1.pem #define THING_NAME "" #define MQTT_PACKET_SIZE 1024 void MQTTPublish(const char *topic, char *payload); void updateThing(); const char my_cert[] = \ "-----BEGIN CERTIFICATE-----\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "-----END CERTIFICATE-----\n"; const char my_key[] = \ "-----BEGIN RSA PRIVATE KEY-----\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \ "-----END RSA PRIVATE KEY-----\n"; SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key); const char* mqttServer = "xxxxxxxxxxxx-ats.iot.us-east-1.amazonaws.com"; const char publishShadowUpdate[] = "$aws/things/" THING_NAME "/shadow/update"; char publishPayload[MQTT_PACKET_SIZE]; char *subscribeTopic[5] = { "$aws/things/" THING_NAME "/shadow/update/accepted", "$aws/things/" THING_NAME "/shadow/update/rejected", "$aws/things/" THING_NAME "/shadow/update/delta", "$aws/things/" THING_NAME "/shadow/get/accepted", "$aws/things/" THING_NAME "/shadow/get/rejected" }; void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i=0;i