
Contains example code to connect the mbed LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service via ethernet.
Dependencies: C12832 MQTT LM75B MMA7660
Dependents: MFT_IoT_demo_USB400 IBM_RFID
MQTT/MQTTSocket.h
- Committer:
- samdanbury
- Date:
- 2014-08-20
- Revision:
- 6:37b6d0d56190
- Child:
- 8:80d49dd91542
File content as of revision 6:37b6d0d56190:
#if !defined(MQTTSOCKET_H) #define MQTTSOCKET_H #include "MQTT_mbed.h" #include "TCPSocketConnection.h" class MQTTSocket { public: int connect(char* hostname, int port, int timeout=1000) { mysock.set_blocking(false, timeout); // 1 second Timeout return mysock.connect(hostname, port); } int read(unsigned char* buffer, int len, int timeout) { mysock.set_blocking(false, timeout); return mysock.receive((char*)buffer, len); } int write(unsigned char* buffer, int len, int timeout) { mysock.set_blocking(false, timeout); return mysock.send((char*)buffer, len); } int disconnect() { return mysock.close(); } private: TCPSocketConnection mysock; }; #endif