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.
Dependents: mqtt_Autofaehrschiff MQTT_Nucleo_dht11 mqtt_Testprogramm_FritzBox mqtt_TestprogrammWorkshop ... more
PubSubClient.h
00001 #include "mbed.h" 00002 #include "ESP8266Interface.h" 00003 #include "string" 00004 00005 00006 // Library to use https://github.com/ARMmbed/mbed-mqtt 00007 #include <MQTTClientMbedOs.h> 00008 00009 00010 using namespace MQTT; 00011 00012 class PubSubClient 00013 { 00014 private: 00015 ESP8266Interface *esp; 00016 SocketAddress deviceIP; 00017 SocketAddress MQTTBroker; 00018 TCPSocket *socket; 00019 MQTTClient *client; 00020 MQTT::Message msg; 00021 MQTTPacket_connectData data; 00022 00023 //Subscriptions 00024 /* 00025 static int hs_count; 00026 static char hs[10][40]; //Topics 00027 static Callback< void(string)> cbs[10]; //Callbacks 00028 static int topicNr; 00029 */ 00030 public: 00031 void init(); 00032 PubSubClient(Callback< void()> func); 00033 PubSubClient(); 00034 bool connect(char* clientName); 00035 int publish(const char* topic, const char* buf); 00036 int publish(const char* topic, const char* buf, MQTT::QoS qos); 00037 int publish(const char* topic, const char* buf, MQTT::QoS qos, bool retain); 00038 int subscribe(const char* topicFilter, MQTT::QoS qos, MQTTClient::messageHandler mh); 00039 //int subscribe(const char* topic,Callback< void(string)> func); 00040 //static void subscribeCallback(MessageData& mymessage); 00041 //static void loop(); 00042 int yield(unsigned long timeout_ms = 1000L); 00043 int loop(unsigned long timeout_ms = 1000L); 00044 string gibPayload(MessageData& mymessage); 00045 };
Generated on Wed Jul 13 2022 10:34:42 by
1.7.2