Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-wifi-milkcocoa MilkcocoaOsSample_Eth MilkcocoaOsSample_ESP8266 MilkcocoaOsSample_Eth_DigitalIn
Diff: Milkcocoa.cpp
- Revision:
- 9:5c195c1036da
- Parent:
- 8:e2f15b1b4f70
- Child:
- 12:6eafbe763882
--- a/Milkcocoa.cpp Wed Jun 14 07:48:45 2017 +0000
+++ b/Milkcocoa.cpp Wed Sep 06 05:58:26 2017 +0000
@@ -1,4 +1,5 @@
#include "Milkcocoa.h"
+#include "OldTimer.h"
#if 0
extern RawSerial pc;
@@ -100,8 +101,6 @@
for (int i=0; i<MILKCOCOA_SUBSCRIBERS; i++) {
milkcocoaSubscribers[i] = NULL;
}
- connectting = false;
- mqtt_connectting = false;
#ifdef __MILKCOCOA_THREAD
setLoopCycle(5000);
@@ -124,8 +123,6 @@
for (int i=0; i<MILKCOCOA_SUBSCRIBERS; i++) {
milkcocoaSubscribers[i] = NULL;
}
- connectting = false;
- mqtt_connectting = false;
#ifdef __MILKCOCOA_THREAD
setLoopCycle(5000);
@@ -146,14 +143,11 @@
if(client->isConnected())
return;
- connectting = true;
if(client->connect(servername, portnum)!=0) {
DBG(pc.printf("Network connect err\r\n");)
- connectting = false;
return;
}
- connectting = false;
- mqtt_connectting = true;
+
MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
data.keepAliveInterval = 20;
data.cleansession = 1;
@@ -164,15 +158,9 @@
if (client->connect(data) != 0) {
DBG(pc.printf("Milkcocoa connect err\r\n");)
- mqtt_connectting = false;
return;
}
- mqtt_connectting = false;
-}
-void Milkcocoa::close()
-{
- client->disconnect();
}
bool Milkcocoa::push(const char *path, DataElement dataelement) {
@@ -249,7 +237,6 @@
}
void Milkcocoa::loop() {
- if((connectting == true)||(mqtt_connectting == true)) return;
connect();
client->yield(1);
@@ -307,7 +294,7 @@
void Milkcocoa::cycle_Thread1(void) {
cycleThread1.signal_wait(START_THREAD);
while(1) {
- Timer timer;
+ OldTimer timer;
timer.start();
connect();