No idea why this is forking.

Dependencies:   FP MQTTPacket

Dependents:   MQTTw7500 MQTTw7500 wizwiki_wizfi310_mqtt MQTT_TestByChandana ... more

Fork of MQTT by Bohyun Bang

Committer:
jamesabruce
Date:
Sat Oct 03 10:53:36 2015 +0000
Revision:
47:d3feba7f242a
Parent:
46:88f62eb29442

        

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
bangbh 45:b7cebc104c6c 9
bangbh 45:b7cebc104c6c 10
icraggs 31:a51dd239b78e 11 class MQTTEthernet : public MQTTSocket
icraggs 29:833386b16f3e 12 {
icraggs 29:833386b16f3e 13 public:
icraggs 29:833386b16f3e 14 MQTTEthernet()
icraggs 29:833386b16f3e 15 {
bangbh 45:b7cebc104c6c 16 wait(1);
bangbh 45:b7cebc104c6c 17 this->createSocket();
jamesabruce 47:d3feba7f242a 18 //eth.init(mac_addr,ip_addr,snmask,gw_addr); // Do not use DHCP! If you use DHCP use "eth.init(mac_addr);".
jamesabruce 47:d3feba7f242a 19 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x32, 0x23, 0x42};
jamesabruce 47:d3feba7f242a 20
jamesabruce 47:d3feba7f242a 21 eth.init(mac_addr);
jamesabruce 47:d3feba7f242a 22
jamesabruce 47:d3feba7f242a 23 printf("Check Ethernet Link\r\n");
jamesabruce 47:d3feba7f242a 24 while(1) { //Wait link up
jamesabruce 47:d3feba7f242a 25 if(eth.link() == true)
jamesabruce 47:d3feba7f242a 26 break;
jamesabruce 47:d3feba7f242a 27 }
jamesabruce 47:d3feba7f242a 28 printf("Link up\r\n");
jamesabruce 47:d3feba7f242a 29
jamesabruce 47:d3feba7f242a 30 int ethErr = eth.connect();
jamesabruce 47:d3feba7f242a 31
jamesabruce 47:d3feba7f242a 32
jamesabruce 47:d3feba7f242a 33 if(ethErr < 0)
jamesabruce 47:d3feba7f242a 34 {
jamesabruce 47:d3feba7f242a 35 printf("Error %d in setup.\n", ethErr);
jamesabruce 47:d3feba7f242a 36 }
jamesabruce 47:d3feba7f242a 37 printf("Server IP Address is %s\r\n", eth.getIPAddress());
jamesabruce 47:d3feba7f242a 38
icraggs 29:833386b16f3e 39 }
icraggs 29:833386b16f3e 40
icraggs 41:b7e86fa6dbb8 41 EthernetInterface& getEth()
icraggs 41:b7e86fa6dbb8 42 {
icraggs 41:b7e86fa6dbb8 43 return eth;
icraggs 41:b7e86fa6dbb8 44 }
icraggs 41:b7e86fa6dbb8 45
icraggs 41:b7e86fa6dbb8 46 void reconnect()
icraggs 41:b7e86fa6dbb8 47 {
icraggs 41:b7e86fa6dbb8 48 eth.connect(); // nothing I've tried actually works to reconnect
icraggs 41:b7e86fa6dbb8 49 }
icraggs 41:b7e86fa6dbb8 50
icraggs 29:833386b16f3e 51 private:
icraggs 29:833386b16f3e 52
icraggs 29:833386b16f3e 53 EthernetInterface eth;
icraggs 29:833386b16f3e 54
icraggs 29:833386b16f3e 55 };
icraggs 29:833386b16f3e 56
icraggs 29:833386b16f3e 57
icraggs 29:833386b16f3e 58 #endif