![](/media/cache/profiles/be6b2f6b6e7d72e528c6123f2cd5568e.jpg.50x50_q85.jpg)
Example for AV_MQTT
main.cpp
- Committer:
- Nim65s
- Date:
- 2013-08-08
- Revision:
- 0:ab341e0e5a21
- Child:
- 1:3bb5708ae2b9
File content as of revision 0:ab341e0e5a21:
#include "mbed.h" #include "rtos.h" #include "AV_MQTT.h" #include "EthernetInterface.h" EthernetInterface eth; DigitalOut led(LED1); DigitalIn down(p12), left(p13), center(p14), up(p15), right(p16); char BUFFER[150]; void callback(char *topic, char *message) { printf("==== New PUBLISH received ====\r\n"); printf(topic); printf("\r\n------------------------------\r\n"); printf(message); printf("\r\n------------ end -------------\r\n"); } int main() { printf("\r\n====================================================\r\n"); eth.init(); do printf("Connection...\r\n"); while (eth.connect() != 0); //niMQTT client("10.41.240.6", callback, "mbed", 1883, "MBED_MQTT_TEST", "mbed_password"); AV_MQTT client("10.41.240.6", callback, "MBED_MQTT_TEST", "mbed_password", "mbed", 1883, true); while(true) { if (down) client.pub("button", "1"); else if (left) client.pub("button", "2"); else if (center) client.pub("button", "3"); else if (up) client.pub("button", "4"); else if (right) client.pub("button", "5"); led = 0; wait(1); led = 1; wait(1); } }