Using the mini-config settings for free ram needs for the rest of the program. The certs seem to work as suggested by the output.
void callback(char* topic, byte* payload, unsigned int length) {
char p[length + 1];
memcpy(p, payload, length);
p[length] = NULL;
String message(p);
Serial.println("callback contains:");
Serial.println(message);
delay(1000);
}
#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)
unsigned long lastSync = millis();
int counter = 0;
void setup() {
if (millis() - lastSync > ONE_DAY_MILLIS) {
Particle.syncTime();
lastSync = millis();
}
if(!WiFi.ready()) {Serial.println("Error, wifi not connected");}
int ret;
// enable tls. set Root CA pem, private key file.
if((ret = client.enableTls(amazonIoTRootCaPem, sizeof(amazonIoTRootCaPem),
clientKeyCrtPem, sizeof(clientKeyCrtPem),
clientKeyPem, sizeof(clientKeyPem)))<0){
Serial.printlnf("client.enableTls failed with code: %d", ret);
};
Serial.println("tls enable");
// connect to the server
if ( (ret >= 0) && ((ret = client.connect(ClientID)) < 0) ) { // if client enable tls succeeded, attempt connect. Can block for up to 60 seconds
Serial.printlnf("client.connect failed with code: %d", ret);
}
// publish/subscribe
if (client.isConnected()) {
Serial.println("client connected");
}
if (client.isConnected()) {
int d_id = 1;
float s_v = 50.500;
float tp_v= -25.5;
char tm[] = "2019/6/20/14/30/59";
char payload[255];
snprintf(payload, sizeof(payload), "{ \"d_id\": %d, \"n_dat\": { \"s_v\": %.2f, \"tp_v\": %.2f, \"tm\": \"%s\"}}", d_id, s_v, tp_v, tm);
Serial.println(payload);
client.publish("Node_Data", payload);
client.subscribe("Node_Data");
}
}
void loop() {
if (client.isConnected()) {
client.loop();
}
delay(200);
}
And here is what I get in VS terminal using serial monitor:
Serial monitor opened successfully:
tls enable
hand shake start
Verify requested for (Depth 2):
cert. version : 3
serial number : 06:6C:9F:...no idea if this is identifying info.....36:5B:CA
issuer name : C=US, O=Amazon, CN=Amazon Root CA 1
subject name : C=US, O=Amazon, CN=Amazon Root CA 1
issued on : 2015-05-26 00:00:00
expires on : 2038-01-17 00:00:00
signed using : RSA with SHA-256
RSA key size : 2048 bits
basic constraints : CA=true
key usage : Digital Signature, Key Cert Sign, CRL Sign
This certificate has no flags
Verify requested for (Depth 1):
cert. version : 3
serial number : 06:7F:94:57:...no idea if this is identifying info....:99:8B:56:0D
issuer name : C=US, O=Amazon, CN=Amazon Root CA 1
subject name : C=US, O=Amazon, OU=Server CA 1B, CN=Amazon
issued on : 2015-10-22 00:00:00
expires on : 2025-10-19 00:00:00
signed using : RSA with SHA-256
RSA key size : 2048 bits
basic constraints : CA=true, max_pathlen=0
key usage : Digital Signature, Key Cert Sign, CRL Sign
This certificate has no flags
Verify requested for (Depth 0):
cert. version : 3
serial number : 0A:AC:B3... no idea if this is identifying info..... 3B:FB:C7
issuer name : C=US, O=Amazon, OU=Server CA 1B, CN=Amazon
subject name : CN=*.iot.us-east-2.amazonaws.com
issued on : 2019-05-07 00:00:00
expires on : 2020-04-10 12:00:00
signed using : RSA with SHA-256
RSA key size : 2048 bits
basic constraints : CA=false
subject alt name : *.iot.us-east-2.amazonaws.com, iot.us-east-2.amazonaws.com
key usage : Digital Signature, Key Encipherment
ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
This certificate has no flags
handshake done, ret = 0
tls connected
netWrite!!
MQTT connected.
client connected
{ "d_id": 1, "n_dat": { "s_v": 50.50, "tp_v": -25.50, "tm": "2019/6/20/14/30/59"}}
netWrite!!
netWrite!!
netWrite!!
netWrite!!
netWrite!!
netWrite!!
netWrite!!
netWrite!!
netWrite!!
netWrite!!
mqtt disconnected
netWrite!!
tls close
Serial connection closed.
If this is tied to the mini-config file, what should I recommend as a necessary step for the AWS team to get things working?
Thank you in advance,
Sincerely,
Bob