for WIZwiki-W7500 board

Dependencies:   FP MQTTPacket

Dependents:   IBMIoTClientEthernetExample_WIZnet

Fork of MQTT by MQTT

Committer:
hkjung
Date:
Thu Sep 17 04:42:08 2015 +0000
Revision:
49:66f37eda441b
Parent:
48:1de971b62543
Modified the netinfo allocation method

Who changed what in which revision?

UserRevisionLine numberNew 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 49:66f37eda441b 9 // Use DHCP mode
hkjung 49:66f37eda441b 10 // Note: Please fill up the mac_addr array using VALID MAC address
hkjung 49:66f37eda441b 11 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x00, 0x99};
hkjung 49:66f37eda441b 12
hkjung 49:66f37eda441b 13 // Use Static IP
hkjung 49:66f37eda441b 14 // Note: Please fill up the 'xx' field using VALID network information
hkjung 49:66f37eda441b 15 //uint8_t mac_addr[6] = {xx, xx, xx, xx, xx, xx};
hkjung 49:66f37eda441b 16 //const char * ip_addr = "xx.xx.xx.xx";
hkjung 49:66f37eda441b 17 //const char * gw_addr = "xx.xx.xx.xx";
hkjung 49:66f37eda441b 18 //const char * snmask = "xx.xx.xx.xx";
hkjung 45:d8c12dce71b9 19
icraggs 31:a51dd239b78e 20 class MQTTEthernet : public MQTTSocket
icraggs 29:833386b16f3e 21 {
icraggs 29:833386b16f3e 22 public:
icraggs 29:833386b16f3e 23 MQTTEthernet()
icraggs 29:833386b16f3e 24 {
hkjung 45:d8c12dce71b9 25 wait(1);
hkjung 45:d8c12dce71b9 26 this->createSocket();
hkjung 49:66f37eda441b 27 //eth.init(mac_addr, ip_addr, snmask, gw_addr); // Use Static IP
hkjung 49:66f37eda441b 28 eth.init(mac_addr); // Use DHCP
icraggs 29:833386b16f3e 29 eth.connect();
icraggs 29:833386b16f3e 30 }
icraggs 29:833386b16f3e 31
icraggs 41:b7e86fa6dbb8 32 EthernetInterface& getEth()
icraggs 41:b7e86fa6dbb8 33 {
icraggs 41:b7e86fa6dbb8 34 return eth;
icraggs 41:b7e86fa6dbb8 35 }
icraggs 41:b7e86fa6dbb8 36
icraggs 41:b7e86fa6dbb8 37 void reconnect()
icraggs 41:b7e86fa6dbb8 38 {
icraggs 41:b7e86fa6dbb8 39 eth.connect(); // nothing I've tried actually works to reconnect
hkjung 48:1de971b62543 40 }
icraggs 41:b7e86fa6dbb8 41
icraggs 29:833386b16f3e 42 private:
icraggs 29:833386b16f3e 43
icraggs 29:833386b16f3e 44 EthernetInterface eth;
icraggs 29:833386b16f3e 45
icraggs 29:833386b16f3e 46 };
icraggs 29:833386b16f3e 47
icraggs 29:833386b16f3e 48
icraggs 29:833386b16f3e 49 #endif