|
|
@ -23,37 +23,44 @@ void readControls() {
|
|
|
|
Serial.println("Started..");
|
|
|
|
Serial.println("Started..");
|
|
|
|
|
|
|
|
|
|
|
|
client.fastrprint(F("GET "));
|
|
|
|
client.fastrprint(F("GET "));
|
|
|
|
client.fastrprint(SERVICE_EPOINT);
|
|
|
|
client.fastrprint(IOT_SERVICE_EPOINT);
|
|
|
|
client.fastrprint(F("readcontrols"));
|
|
|
|
|
|
|
|
client.fastrprint(F(" HTTP/1.1"));
|
|
|
|
client.fastrprint(F(" HTTP/1.1"));
|
|
|
|
client.fastrprint(F("\n"));
|
|
|
|
client.fastrprint(F("\n"));
|
|
|
|
client.fastrprint(host.c_str());
|
|
|
|
client.fastrprint(host.c_str());client.fastrprint(F("\n"));
|
|
|
|
|
|
|
|
client.fastrprint(F("Authorization: Bearer ")); client.fastrprint(F(DEVICE_TOKEN)); client.fastrprint(F("\n"));
|
|
|
|
|
|
|
|
client.fastrprint(F("Content-Type: application/json")); client.fastrprint(F("\n"));
|
|
|
|
|
|
|
|
client.fastrprint(F("Accept: application/json")); client.fastrprint(F("\n"));
|
|
|
|
client.fastrprint(F("\n"));
|
|
|
|
client.fastrprint(F("\n"));
|
|
|
|
client.fastrprint(DEVICE_ID);
|
|
|
|
|
|
|
|
client.fastrprint(F("owner: "));
|
|
|
|
|
|
|
|
client.fastrprint(DEVICE_OWNER);
|
|
|
|
|
|
|
|
client.fastrprint(F("\n"));
|
|
|
|
|
|
|
|
client.fastrprint(F("deviceId: "));
|
|
|
|
|
|
|
|
client.fastrprint(F(DEVICE_ID));
|
|
|
|
|
|
|
|
client.fastrprint(F("\n"));
|
|
|
|
|
|
|
|
client.fastrprint(F("deviceId: "));
|
|
|
|
|
|
|
|
client.fastrprint(F("protocol: HTTP\n"));
|
|
|
|
client.fastrprint(F("protocol: HTTP\n"));
|
|
|
|
|
|
|
|
|
|
|
|
client.println();
|
|
|
|
client.println();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(DEBUG) {
|
|
|
|
|
|
|
|
Serial.print("GET ");
|
|
|
|
|
|
|
|
Serial.print(IOT_SERVICE_EPOINT);
|
|
|
|
|
|
|
|
Serial.print(" HTTP/1.1"); Serial.println();
|
|
|
|
|
|
|
|
Serial.print(host); Serial.println();
|
|
|
|
|
|
|
|
Serial.print("Content-Type: application/json"); Serial.println();
|
|
|
|
|
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delay(1000);
|
|
|
|
delay(1000);
|
|
|
|
Serial.println("Ended..");
|
|
|
|
|
|
|
|
while (client.available()) {
|
|
|
|
while (client.available()) {
|
|
|
|
char response = client.read();
|
|
|
|
char response = client.read();
|
|
|
|
|
|
|
|
if(DEBUG) Serial.print(response);
|
|
|
|
responseMsg += response;
|
|
|
|
responseMsg += response;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
Serial.println("Ended..");
|
|
|
|
int index = responseMsg.lastIndexOf(":");
|
|
|
|
int index = responseMsg.lastIndexOf(":");
|
|
|
|
int newLine = responseMsg.lastIndexOf("\n");
|
|
|
|
int newLine = responseMsg.lastIndexOf("\n");
|
|
|
|
subStrn = responseMsg.substring(index + 1);
|
|
|
|
subStrn = responseMsg.substring(index + 1);
|
|
|
|
responseMsg = responseMsg.substring(newLine + 1, index);
|
|
|
|
responseMsg = responseMsg.substring(newLine + 1, index);
|
|
|
|
|
|
|
|
|
|
|
|
if(DEBUG) {
|
|
|
|
if(DEBUG) {
|
|
|
|
|
|
|
|
Serial.print("Polling Response: ");
|
|
|
|
Serial.print(responseMsg);
|
|
|
|
Serial.print(responseMsg);
|
|
|
|
Serial.println();
|
|
|
|
Serial.println();
|
|
|
|
Serial.println("-------------------------------");
|
|
|
|
Serial.println("-------------------------------");
|
|
|
|