Closed ashwanipal01 closed 7 years ago
I am having the same issue: "Please start SNTP first"
put configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
in your setup to get rid of the Please start sntp first message, It is however not going to solve your problem. The sntp message can be ignored
please help me on connecting with aws iot services with esp8266 12e. i am using example aws-mqtt-websocket example not able to connect with dashboard of aws iot the code is as follow and the error i get is (please start sntp first ! error connection to the websocket server)
`#include
include
include
//AWS
include "sha256.h"
include "Utils.h"
include "AWSClient2.h"
//WEBSockets
include
include
//MQTT PAHO
include
include
include
include
//AWS MQTT Websocket
include "Client.h"
include "AWSWebSocketClient.h"
include "CircularByteBuffer.h"
//AWS IOT config, change these:
const char ssid = "NPSE"; const char password = "P/W070415"; char aws_endpoint[] = "aph0r6gk1etz5.iot.us-east-1.amazonaws.com"; char aws_key[] = "AKIAJDJA6HPCGZXG7N6Q"; char aws_secret[] = "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"; char aws_region[] = "us-east-1"; const char* aws_topic = "$aws/things/tutorial/shadow/update"; int port = 443;
//MQTT config const int maxMQTTpackageSize = 512; const int maxMQTTMessageHandlers = 1;
WiFiClientSecure espclient;
AWSWebSocketClient awsWSclient(1000);
IPStack ipstack(awsWSclient);
MQTT::Client<IPStack, Countdown, maxMQTTpackageSize, maxMQTTMessageHandlers> *client = NULL;
//# of connections long connection = 0;
//generate random mqtt clientID char generateClientID () { char cID = new char[23](); for (int i=0; i<22; i+=1) cID[i]=(char)random(1, 256); return cID; }
//count messages arrived int arrivedcount = 0;
//callback to handle mqtt messages void messageArrived(MQTT::MessageData& md) { MQTT::Message &message = md.message;
}
//connects to websocket layer and mqtt layer bool connect () {
}
//subscribe to a mqtt topic void subscribe () { //subscript to a topic int rc = client->subscribe(aws_topic, MQTT::QOS0, messageArrived); Serial.println(rc); if (rc != 0) { Serial.print("rc from MQTT subscribe is "); Serial.println(rc); return; } Serial.println("MQTT subscribed"); }
//send a message to a mqtt topic void sendmessage () { //send a message MQTT::Message message; char buf[100]; strcpy(buf, "{\"state\":{\"reported\":{\"on\": false}, \"desired\":{\"on\": false}}}"); message.qos = MQTT::QOS0; message.retained = false; message.dup = false; message.payload = (void*)buf; message.payloadlen = strlen(buf)+1; int rc = client->publish(aws_topic, message); }
void setup_wifi() {
}
void setup() { Serial.begin (115200); setup_wifi();
}
void loop() { //keep the mqtt up and running if (awsWSclient.connected ()) {
client->yield(); } else { //handle reconnection if (connect ()){ subscribe ();
} }
}`![error](https://cloud.githubusercontent.com/assets/22903565/22690709/1a912f9c-ed5d-11e6-9450-b40abccc04f6.jpg)