Added support to NetworkSocket API with Wifi.

Dependencies:   FP MQTTPacket

Dependents:   IDW01M1_Cloud_IBM IDW01M1-MQTT IDW01M1-MQTT-1 IDW01M1-MQTT3 ... more

Fork of MQTT by ST Expansion SW Team

Committer:
mapellil
Date:
Mon Oct 30 13:50:53 2017 +0100
Revision:
49:c66fdbb9eb83
Parent:
43:21da1f744243
Fixed NonCopyable for Mbed-os 5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icraggs 29:833386b16f3e 1 #if !defined(MQTT_MBED_H)
icraggs 29:833386b16f3e 2 #define MQTT_MBED_H
icraggs 29:833386b16f3e 3
icraggs 29:833386b16f3e 4 #include "mbed.h"
icraggs 29:833386b16f3e 5
icraggs 29:833386b16f3e 6 class Countdown
icraggs 29:833386b16f3e 7 {
icraggs 29:833386b16f3e 8 public:
mapellil 49:c66fdbb9eb83 9 Countdown() {
mapellil 49:c66fdbb9eb83 10 t = new Timer();
mapellil 49:c66fdbb9eb83 11 if (t == NULL) printf ("Countdown newfail\n\r");
icraggs 29:833386b16f3e 12 }
icraggs 29:833386b16f3e 13
mapellil 49:c66fdbb9eb83 14 Countdown(int ms) {
mapellil 49:c66fdbb9eb83 15 t = new Timer();
mapellil 49:c66fdbb9eb83 16 if (t == NULL) printf ("Countdown newfail\n\r");
icraggs 29:833386b16f3e 17 countdown_ms(ms);
icraggs 29:833386b16f3e 18 }
icraggs 29:833386b16f3e 19
mapellil 49:c66fdbb9eb83 20 ~Countdown() {
mapellil 49:c66fdbb9eb83 21 delete t;
mapellil 49:c66fdbb9eb83 22 }
icraggs 29:833386b16f3e 23
mapellil 49:c66fdbb9eb83 24 bool expired() {
mapellil 49:c66fdbb9eb83 25 return t->read_ms() >= interval_end_ms;
icraggs 29:833386b16f3e 26 }
icraggs 29:833386b16f3e 27
mapellil 49:c66fdbb9eb83 28 void countdown_ms(unsigned long ms) {
mapellil 49:c66fdbb9eb83 29 t->stop();
icraggs 29:833386b16f3e 30 interval_end_ms = ms;
mapellil 49:c66fdbb9eb83 31 t->reset();
mapellil 49:c66fdbb9eb83 32 t->start();
icraggs 29:833386b16f3e 33 }
icraggs 29:833386b16f3e 34
mapellil 49:c66fdbb9eb83 35 void countdown(int seconds) {
icraggs 43:21da1f744243 36 countdown_ms((unsigned long)seconds * 1000L);
icraggs 29:833386b16f3e 37 }
icraggs 29:833386b16f3e 38
mapellil 49:c66fdbb9eb83 39 int left_ms() {
mapellil 49:c66fdbb9eb83 40 return interval_end_ms - t->read_ms();
icraggs 29:833386b16f3e 41 }
icraggs 29:833386b16f3e 42
icraggs 29:833386b16f3e 43 private:
mapellil 49:c66fdbb9eb83 44 Timer *t;
icraggs 43:21da1f744243 45 unsigned long interval_end_ms;
icraggs 29:833386b16f3e 46 };
icraggs 29:833386b16f3e 47
icraggs 29:833386b16f3e 48 #endif