for WIZwiki-W7500 board
Dependents: IBMIoTClientEthernetExample_WIZnet
Fork of MQTT by
MQTTEthernet.h@47:0f7cec2a7058, 2015-09-07 (annotated)
- Committer:
- hkjung
- Date:
- Mon Sep 07 00:03:23 2015 +0000
- Revision:
- 47:0f7cec2a7058
- Parent:
- 46:72659bc4048b
- Child:
- 48:1de971b62543
Commented out: IP info
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
icraggs | 29:833386b16f3e | 1 | |
icraggs | 29:833386b16f3e | 2 | #if !defined(MQTTETHERNET_H) |
icraggs | 29:833386b16f3e | 3 | #define MQTTETHERNET_H |
icraggs | 29:833386b16f3e | 4 | |
icraggs | 43:21da1f744243 | 5 | #include "MQTTmbed.h" |
icraggs | 29:833386b16f3e | 6 | #include "EthernetInterface.h" |
icraggs | 31:a51dd239b78e | 7 | #include "MQTTSocket.h" |
icraggs | 29:833386b16f3e | 8 | |
hkjung | 45:d8c12dce71b9 | 9 | //uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x1D, 0x69, 0xF3}; |
hkjung | 45:d8c12dce71b9 | 10 | uint8_t mac_addr[6] = {0x00, 0x02, 0xf7, 0xf2, 0x05, 0x00}; |
hkjung | 47:0f7cec2a7058 | 11 | //const char * ip_addr = "222.98.173.213"; |
hkjung | 47:0f7cec2a7058 | 12 | //const char * gw_addr = "222.98.173.254"; |
hkjung | 47:0f7cec2a7058 | 13 | //const char * snmask = "255.255.255.192"; |
hkjung | 45:d8c12dce71b9 | 14 | |
icraggs | 31:a51dd239b78e | 15 | class MQTTEthernet : public MQTTSocket |
icraggs | 29:833386b16f3e | 16 | { |
icraggs | 29:833386b16f3e | 17 | public: |
icraggs | 29:833386b16f3e | 18 | MQTTEthernet() |
icraggs | 29:833386b16f3e | 19 | { |
hkjung | 45:d8c12dce71b9 | 20 | wait(1); |
hkjung | 45:d8c12dce71b9 | 21 | this->createSocket(); |
hkjung | 46:72659bc4048b | 22 | //eth.init(mac_addr,ip_addr,snmask,gw_addr); // Use Static IP |
hkjung | 46:72659bc4048b | 23 | eth.init(mac_addr); // Use DHCP |
icraggs | 29:833386b16f3e | 24 | eth.connect(); |
icraggs | 29:833386b16f3e | 25 | } |
icraggs | 29:833386b16f3e | 26 | |
icraggs | 41:b7e86fa6dbb8 | 27 | EthernetInterface& getEth() |
icraggs | 41:b7e86fa6dbb8 | 28 | { |
icraggs | 41:b7e86fa6dbb8 | 29 | return eth; |
icraggs | 41:b7e86fa6dbb8 | 30 | } |
icraggs | 41:b7e86fa6dbb8 | 31 | |
icraggs | 41:b7e86fa6dbb8 | 32 | void reconnect() |
icraggs | 41:b7e86fa6dbb8 | 33 | { |
icraggs | 41:b7e86fa6dbb8 | 34 | eth.connect(); // nothing I've tried actually works to reconnect |
icraggs | 41:b7e86fa6dbb8 | 35 | } |
icraggs | 41:b7e86fa6dbb8 | 36 | |
icraggs | 29:833386b16f3e | 37 | private: |
icraggs | 29:833386b16f3e | 38 | |
icraggs | 29:833386b16f3e | 39 | EthernetInterface eth; |
icraggs | 29:833386b16f3e | 40 | |
icraggs | 29:833386b16f3e | 41 | }; |
icraggs | 29:833386b16f3e | 42 | |
icraggs | 29:833386b16f3e | 43 | |
icraggs | 29:833386b16f3e | 44 | #endif |