![](/media/cache/profiles/be6b2f6b6e7d72e528c6123f2cd5568e.jpg.50x50_q85.jpg)
Example for AV_MQTT
main.cpp
- Committer:
- Nim65s
- Date:
- 2013-08-08
- Revision:
- 1:3bb5708ae2b9
- Parent:
- 0:ab341e0e5a21
- Child:
- 2:b9b08c7d6e12
File content as of revision 1:3bb5708ae2b9:
#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); 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); AV_MQTT client("10.41.240.6", callback, "MBED_MQTT_TEST", "mbed_password"); 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); } }