kh7ioiuyg56yjiuy

Dependencies:   FP MQTTPacket

Fork of MQTT by Irayya Mathad

Committer:
bangbh
Date:
Mon Jun 29 02:07:13 2015 +0000
Revision:
46:88f62eb29442
Parent:
45:b7cebc104c6c
Child:
47:d3feba7f242a
You have to use your ethernet information.

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 46:88f62eb29442 10 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x00, 0x00}; // your mac address
bangbh 46:88f62eb29442 11 const char * ip_addr = "???.???.???.???"; // your ip
bangbh 46:88f62eb29442 12 const char * gw_addr = "???.???.???.???"; // your gateway
bangbh 46:88f62eb29442 13 const char * snmask = "???.???.???.???"; // your subnetmask
bangbh 45:b7cebc104c6c 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 {
bangbh 45:b7cebc104c6c 20 wait(1);
bangbh 45:b7cebc104c6c 21 this->createSocket();
bangbh 46:88f62eb29442 22 eth.init(mac_addr,ip_addr,snmask,gw_addr); // Do not use DHCP! If you use DHCP use "eth.init(mac_addr);".
icraggs 29:833386b16f3e 23 eth.connect();
icraggs 29:833386b16f3e 24 }
icraggs 29:833386b16f3e 25
icraggs 41:b7e86fa6dbb8 26 EthernetInterface& getEth()
icraggs 41:b7e86fa6dbb8 27 {
icraggs 41:b7e86fa6dbb8 28 return eth;
icraggs 41:b7e86fa6dbb8 29 }
icraggs 41:b7e86fa6dbb8 30
icraggs 41:b7e86fa6dbb8 31 void reconnect()
icraggs 41:b7e86fa6dbb8 32 {
icraggs 41:b7e86fa6dbb8 33 eth.connect(); // nothing I've tried actually works to reconnect
icraggs 41:b7e86fa6dbb8 34 }
icraggs 41:b7e86fa6dbb8 35
icraggs 29:833386b16f3e 36 private:
icraggs 29:833386b16f3e 37
icraggs 29:833386b16f3e 38 EthernetInterface eth;
icraggs 29:833386b16f3e 39
icraggs 29:833386b16f3e 40 };
icraggs 29:833386b16f3e 41
icraggs 29:833386b16f3e 42
icraggs 29:833386b16f3e 43 #endif