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.
Dependencies: C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed
Fork of IBMIoTClientEthernetExample by
MQTT/MQTT_mbed.h@7:63a7aa4deaf8, 2014-08-20 (annotated)
- Committer:
- samdanbury
- Date:
- Wed Aug 20 13:46:35 2014 +0000
- Revision:
- 7:63a7aa4deaf8
- Parent:
- 6:37b6d0d56190
Add AUTH_METHOD credential
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| samdanbury | 6:37b6d0d56190 | 1 | #if !defined(MQTT_MBED_H) |
| samdanbury | 6:37b6d0d56190 | 2 | #define MQTT_MBED_H |
| samdanbury | 6:37b6d0d56190 | 3 | |
| samdanbury | 6:37b6d0d56190 | 4 | #include "mbed.h" |
| samdanbury | 6:37b6d0d56190 | 5 | |
| samdanbury | 6:37b6d0d56190 | 6 | class Countdown |
| samdanbury | 6:37b6d0d56190 | 7 | { |
| samdanbury | 6:37b6d0d56190 | 8 | public: |
| samdanbury | 6:37b6d0d56190 | 9 | Countdown() |
| samdanbury | 6:37b6d0d56190 | 10 | { |
| samdanbury | 6:37b6d0d56190 | 11 | t = Timer(); |
| samdanbury | 6:37b6d0d56190 | 12 | } |
| samdanbury | 6:37b6d0d56190 | 13 | |
| samdanbury | 6:37b6d0d56190 | 14 | Countdown(int ms) |
| samdanbury | 6:37b6d0d56190 | 15 | { |
| samdanbury | 6:37b6d0d56190 | 16 | t = Timer(); |
| samdanbury | 6:37b6d0d56190 | 17 | countdown_ms(ms); |
| samdanbury | 6:37b6d0d56190 | 18 | } |
| samdanbury | 6:37b6d0d56190 | 19 | |
| samdanbury | 6:37b6d0d56190 | 20 | |
| samdanbury | 6:37b6d0d56190 | 21 | bool expired() |
| samdanbury | 6:37b6d0d56190 | 22 | { |
| samdanbury | 6:37b6d0d56190 | 23 | return t.read_ms() >= interval_end_ms; |
| samdanbury | 6:37b6d0d56190 | 24 | } |
| samdanbury | 6:37b6d0d56190 | 25 | |
| samdanbury | 6:37b6d0d56190 | 26 | void countdown_ms(int ms) |
| samdanbury | 6:37b6d0d56190 | 27 | { |
| samdanbury | 6:37b6d0d56190 | 28 | t.stop(); |
| samdanbury | 6:37b6d0d56190 | 29 | interval_end_ms = ms; |
| samdanbury | 6:37b6d0d56190 | 30 | t.reset(); |
| samdanbury | 6:37b6d0d56190 | 31 | t.start(); |
| samdanbury | 6:37b6d0d56190 | 32 | } |
| samdanbury | 6:37b6d0d56190 | 33 | |
| samdanbury | 6:37b6d0d56190 | 34 | void countdown(int seconds) |
| samdanbury | 6:37b6d0d56190 | 35 | { |
| samdanbury | 6:37b6d0d56190 | 36 | countdown_ms(seconds * 1000); |
| samdanbury | 6:37b6d0d56190 | 37 | } |
| samdanbury | 6:37b6d0d56190 | 38 | |
| samdanbury | 6:37b6d0d56190 | 39 | int left_ms() |
| samdanbury | 6:37b6d0d56190 | 40 | { |
| samdanbury | 6:37b6d0d56190 | 41 | return interval_end_ms - t.read_ms(); |
| samdanbury | 6:37b6d0d56190 | 42 | } |
| samdanbury | 6:37b6d0d56190 | 43 | |
| samdanbury | 6:37b6d0d56190 | 44 | private: |
| samdanbury | 6:37b6d0d56190 | 45 | Timer t; |
| samdanbury | 6:37b6d0d56190 | 46 | int interval_end_ms; |
| samdanbury | 6:37b6d0d56190 | 47 | }; |
| samdanbury | 6:37b6d0d56190 | 48 | |
| samdanbury | 6:37b6d0d56190 | 49 | #endif |
