Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MQTT
Dependents: IBMIoTClientLibrarySamplefinal IBMWIoTPSecureClientSample IBMIoTClientLibrarySample
Diff: DeviceClient.h
- Revision:
- 0:f86732d81998
- Child:
- 1:31c93319bbd8
- Child:
- 2:199ddea804cd
diff -r 000000000000 -r f86732d81998 DeviceClient.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DeviceClient.h Fri Nov 06 07:09:14 2015 +0000
@@ -0,0 +1,54 @@
+#ifndef DeviceClient_H
+#define DeviceClient_H
+
+#include "MQTTEthernet.h"
+#include "MQTTClient.h"
+#include "Command.h"
+
+// Update this to the next number *before* a commit
+#define __APP_SW_REVISION__ "0.0.1"
+
+// Configuration values needed to connect to IBM IoT Cloud
+#define QUICKSTART "quickstart"
+
+#define MQTT_PORT 1883
+#define MQTT_TLS_PORT 8883
+#define IBM_IOT_PORT MQTT_PORT
+
+#define IBM_IOT_MESSAGING ".messaging.internetofthings.ibmcloud.com"
+#define CONNECT_TIMEOUT 1000 * 60
+#define MQTT_MAX_PACKET_SIZE 250
+
+typedef void (*CommandHandler)(IoTF::Command &cmd);
+
+namespace IoTF {
+
+ class DeviceClient
+ {
+ private:
+ char *org;
+ char *deviceType;
+ char *deviceId;
+ char *authMethod;
+ char *authToken;
+ MQTTEthernet ipstack;
+ MQTT::Client<MQTTEthernet, Countdown, MQTT_MAX_PACKET_SIZE> mqttClient;
+
+ bool tryConnect(char *hostname, MQTTPacket_connectData &data);
+ int getConnTimeout(int attemptNumber);
+ void logData(EthernetInterface& eth, char *hostname, char *clientId);
+ int subscribeToCommands();
+
+ public:
+ DeviceClient();
+ DeviceClient(char *org, char *deviceType, char *deviceId);
+ DeviceClient(char *org, char *deviceType, char *deviceId, char *authMethod, char *authToken);
+ bool publishEvent(char *eventName, char *data, MQTT::QoS qos = MQTT::QOS0);
+ void setCommandCallback(CommandHandler callbackFunc);
+ char* getMac(char* buf, int buflen);
+ void yield(int ms);
+ bool connect();
+ bool disconnect();
+ };
+}
+#endif
\ No newline at end of file