MQTT fork
Fork of MQTT by
Revision 50:558985f7f210, committed 2017-09-07
- Comitter:
- vcoubard
- Date:
- Thu Sep 07 11:18:53 2017 +0000
- Parent:
- 49:08571008b958
- Commit message:
- Revert Countdown changes and fix invalid use (copy assignment/copy construction) of it in client .
Changed in this revision
MQTTClient.h | Show annotated file Show diff for this revision Revisions of this file |
MQTTmbed.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 08571008b958 -r 558985f7f210 MQTTClient.h --- a/MQTTClient.h Thu Sep 07 09:55:54 2017 +0100 +++ b/MQTTClient.h Thu Sep 07 11:18:53 2017 +0000 @@ -276,8 +276,6 @@ template<class Network, class Timer, int a, int MAX_MESSAGE_HANDLERS> MQTT::Client<Network, Timer, a, MAX_MESSAGE_HANDLERS>::Client(Network& network, unsigned int command_timeout_ms) : ipstack(network), packetid() { - last_sent = Timer(); - last_received = Timer(); this->command_timeout_ms = command_timeout_ms; cleanSession(); } @@ -504,7 +502,7 @@ int MQTT::Client<Network, Timer, a, b>::yield(unsigned long timeout_ms) { int rc = SUCCESS; - Timer timer = Timer(); + Timer timer; timer.countdown_ms(timeout_ms); while (!timer.expired())
diff -r 08571008b958 -r 558985f7f210 MQTTmbed.h --- a/MQTTmbed.h Thu Sep 07 09:55:54 2017 +0100 +++ b/MQTTmbed.h Thu Sep 07 11:18:53 2017 +0000 @@ -3,36 +3,29 @@ #include "mbed.h" -class Countdown +class Countdown : private mbed::NonCopyable<Countdown> { public: - Countdown() + Countdown() : t() { - t = new Timer(); } - Countdown(int ms) + Countdown(int ms) : t() { - t = new Timer(); countdown_ms(ms); } - ~Countdown() - { - delete t; - } - bool expired() { - return t->read_ms() >= interval_end_ms; + return t.read_ms() >= interval_end_ms; } void countdown_ms(unsigned long ms) { - t->stop(); + t.stop(); interval_end_ms = ms; - t->reset(); - t->start(); + t.reset(); + t.start(); } void countdown(int seconds) @@ -42,11 +35,11 @@ int left_ms() { - return interval_end_ms - t->read_ms(); + return interval_end_ms - t.read_ms(); } private: - Timer *t; + Timer t; unsigned long interval_end_ms; };