/* Basic MQTT example (with SSL!) This sketch demonstrates the basic capabilities of the library. It connects to an MQTT server then: - publishes "hello world" to the topic "outTopic" - subscribes to the topic "inTopic", printing out any messages it receives. NB - it assumes the received payloads are strings not binary It will reconnect to the server if the connection is lost using a blocking reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to achieve the same result without blocking the main loop. You will need to populate "certificates.h" with your trust anchors (see https://github.com/OPEnSLab-OSU/SSLClient/blob/master/TrustAnchors.md) and my_cert/my_key with your certificate/private key pair (see https://github.com/OPEnSLab-OSU/SSLClient#mtls). */ #include #include #include #include "certificates.h" // This file must be regenerated #include const char my_cert[] = "FIXME"; const char my_key[] = "FIXME"; SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key); byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; const char* mqttServer = "broker.example"; // Broker address IPAddress ip (192, 168, 1, 2); // Custom client static IP void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i=0;i