Add "TARGET_RZ_A1H"as target of using Ethernet IF.
Fork of Milkcocoa_EthernetIF by
Milkcocoa.h@0:23e533c4b1ec, 2015-12-15 (annotated)
- Committer:
- jksoft
- Date:
- Tue Dec 15 09:56:32 2015 +0000
- Revision:
- 0:23e533c4b1ec
- Child:
- 1:4a634c06c5dc
??; Subscribe?1?????; ?Milkcocoa::on???????????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:23e533c4b1ec | 1 | #ifndef _MILKCOCOA_H_ |
jksoft | 0:23e533c4b1ec | 2 | #define _MILKCOCOA_H_ |
jksoft | 0:23e533c4b1ec | 3 | |
jksoft | 0:23e533c4b1ec | 4 | #include "mbed.h" |
jksoft | 0:23e533c4b1ec | 5 | #include "MQTTESP8266.h" |
jksoft | 0:23e533c4b1ec | 6 | #include "MQTTClient.h" |
jksoft | 0:23e533c4b1ec | 7 | |
jksoft | 0:23e533c4b1ec | 8 | #define RECV_TIMEOUT 500 |
jksoft | 0:23e533c4b1ec | 9 | |
jksoft | 0:23e533c4b1ec | 10 | class DataElement { |
jksoft | 0:23e533c4b1ec | 11 | public: |
jksoft | 0:23e533c4b1ec | 12 | DataElement(); |
jksoft | 0:23e533c4b1ec | 13 | DataElement(char *json_string); |
jksoft | 0:23e533c4b1ec | 14 | void setValue(const char *key, const char *v); |
jksoft | 0:23e533c4b1ec | 15 | void setValue(const char *key, int v); |
jksoft | 0:23e533c4b1ec | 16 | void setValue(const char *key, double v); |
jksoft | 0:23e533c4b1ec | 17 | char *toCharArray(); |
jksoft | 0:23e533c4b1ec | 18 | char *getString(const char *key); |
jksoft | 0:23e533c4b1ec | 19 | int getInt(const char *key); |
jksoft | 0:23e533c4b1ec | 20 | float getFloat(const char *key); |
jksoft | 0:23e533c4b1ec | 21 | |
jksoft | 0:23e533c4b1ec | 22 | private: |
jksoft | 0:23e533c4b1ec | 23 | char json_msg[256]; |
jksoft | 0:23e533c4b1ec | 24 | }; |
jksoft | 0:23e533c4b1ec | 25 | |
jksoft | 0:23e533c4b1ec | 26 | typedef void (*GeneralFunction) (MQTT::MessageData& elem); |
jksoft | 0:23e533c4b1ec | 27 | |
jksoft | 0:23e533c4b1ec | 28 | class Milkcocoa { |
jksoft | 0:23e533c4b1ec | 29 | public: |
jksoft | 0:23e533c4b1ec | 30 | |
jksoft | 0:23e533c4b1ec | 31 | Milkcocoa(MQTTESP8266 *ipstack, const char *host, uint16_t port, const char *_app_id, const char *client_id); |
jksoft | 0:23e533c4b1ec | 32 | Milkcocoa(MQTTESP8266 *ipstack, const char *host, uint16_t port, const char *_app_id, const char *client_id, char *_session); |
jksoft | 0:23e533c4b1ec | 33 | static Milkcocoa* createWithApiKey(MQTTESP8266 *ipstack, const char *host, uint16_t port, const char *_app_id, const char *client_id, char *key, char *secret); |
jksoft | 0:23e533c4b1ec | 34 | void connect(); |
jksoft | 0:23e533c4b1ec | 35 | void loop(); |
jksoft | 0:23e533c4b1ec | 36 | bool push(const char *path, DataElement dataelement); |
jksoft | 0:23e533c4b1ec | 37 | bool send(const char *path, DataElement dataelement); |
jksoft | 0:23e533c4b1ec | 38 | bool on(const char *path, const char *event, GeneralFunction cb); |
jksoft | 0:23e533c4b1ec | 39 | |
jksoft | 0:23e533c4b1ec | 40 | private: |
jksoft | 0:23e533c4b1ec | 41 | char servername[64]; |
jksoft | 0:23e533c4b1ec | 42 | int16_t portnum; |
jksoft | 0:23e533c4b1ec | 43 | char _clientid[64]; |
jksoft | 0:23e533c4b1ec | 44 | char username[32]; |
jksoft | 0:23e533c4b1ec | 45 | char password[32]; |
jksoft | 0:23e533c4b1ec | 46 | const char *app_id; |
jksoft | 0:23e533c4b1ec | 47 | |
jksoft | 0:23e533c4b1ec | 48 | MQTTESP8266 *_ipstack; |
jksoft | 0:23e533c4b1ec | 49 | MQTT::Client<MQTTESP8266, Countdown> client; |
jksoft | 0:23e533c4b1ec | 50 | GeneralFunction _cb; |
jksoft | 0:23e533c4b1ec | 51 | }; |
jksoft | 0:23e533c4b1ec | 52 | |
jksoft | 0:23e533c4b1ec | 53 | |
jksoft | 0:23e533c4b1ec | 54 | #endif |