Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions espduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ BOOL ESP::mqttConnect(const char* host, U16 port)
INFO("TCP: Connected");
connState = MQTT_CONNECT_SEND;
}

BOOL ESP::publish(char* topic, char* data, int data_length, int qos, int retain)
{
if(connState != MQTT_DATA)
return false;
INFO("MQTT: sending publish...\r\n");
mqtt_state.outbound_message = mqtt_msg_publish(&mqtt_state.mqtt_connection,
topic, data, data_length,
qos, retain,
&mqtt_state.pending_msg_id);
}

BOOL ESP::subscribe(char* topic)
{
INFO("MQTT: subscribe, topic");
Expand Down
1 change: 1 addition & 0 deletions espduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ESP
BOOL initMqttClient(const char *clientId, const char *user, const char *pass, U32 keepalive);
BOOL wifiConnect(const char* ssid, const char* pass);
BOOL mqttConnect(const char* host, U16 port);
BOOL publish(char* topic, char* data, int data_length, int qos, int retain);
BOOL subscribe(char* topic);
void process();
void enable();
Expand Down