added mqtt support for sending device controls

merge-requests/1/head
Shabir Mohamed 9 years ago
parent 5b5df161fc
commit 04e4be51a2

@ -65,7 +65,7 @@ void connectHttp() {
if(CON_DEBUG) Serial.println(F("Connected to Wifi network!"));
if(true) Serial.println(F("Request DHCP"));
if(CON_DEBUG) Serial.println(F("Request DHCP"));
while (!cc3000.checkDHCP())
{
delay(100); // ToDo: Insert a DHCP timeout!
@ -78,14 +78,11 @@ void connectHttp() {
pushClient = cc3000.connectTCP(sserver, SERVICE_PORT); //SERVICE_PORT
if (pushClient.connected()) {
if(true) Serial.println(F("pushClient Connected to server"));
if(CON_DEBUG) Serial.println(F("pushClient Connected to server"));
} else {
if(CON_DEBUG) Serial.println(F("pushClient Connection failed"));
}
if(CON_DEBUG) Serial.println(F("-------------------------------------"));
}
@ -148,12 +145,11 @@ bool displayConnectionDetails(void)
void setupClient(){
pushClient = cc3000.connectTCP(sserver, SERVICE_PORT); //SERVICE_PORT
if (pushClient.connected()) {
if(CON_DEBUG) Serial.println(F("client Connected to server"));
if(CON_DEBUG) Serial.println(F("pushClient Connected to server"));
} else {
while( !cc3000.checkConnected() ){
connectHttp();
connectHttp();
}
if(CON_DEBUG) Serial.println(F("client Connection failed"));
if(CON_DEBUG) Serial.println(F("pushClient Connection failed"));
}
}

@ -39,7 +39,7 @@
#define WLAN_SECURITY WLAN_SEC_WPA
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define IDLE_TIMEOUT_MS 3000
//#define IDLE_TIMEOUT_MS 3000
#define DEVICE_OWNER "${DEVICE_OWNER}"
#define DEVICE_ID "${DEVICE_ID}"

@ -44,11 +44,10 @@ void setup() {
void loop() {
while (!cc3000.checkConnected()) {
connectHttp();
}
wdt_reset();
if (millis() - pushTimestamp > PUSH_INTERVAL) {
@ -59,6 +58,7 @@ void loop() {
pushData();
pushTimestamp = millis();
}
readControls();
wdt_reset();

@ -63,7 +63,8 @@ void readControls() {
delay(100);
// Close the connection when done.
Serial.println(F("Client disconnected"));
Serial.println(F("Listener Client disconnected"));
client.flush();
client.close();
wdt_reset();

@ -57,6 +57,7 @@ void readControls()
// Wait a short period to make sure the response had time to send before
// the connection is closed (the CC3000 sends data asyncronously).
delay(200);
client.flush();
client.close();
}

Loading…
Cancel
Save