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.
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 #include "niMQTT.h" 00004 #include "EthernetInterface.h" 00005 00006 EthernetInterface eth; 00007 00008 DigitalOut led(LED1); 00009 DigitalIn pub(p14); 00010 00011 void callback(const char *topic, const char *message) { 00012 printf("==== New PUBLISH received ====\r\n"); 00013 printf(topic); 00014 printf("\r\n------------------------------\r\n"); 00015 printf(message); 00016 printf("\r\n------------ end -------------\r\n"); 00017 } 00018 00019 int main() { 00020 printf("\r\n====================================================\r\n"); 00021 eth.init(); 00022 do printf("Connection...\r\n"); while (eth.connect() != 0); 00023 00024 niMQTT client("10.41.51.53", callback); 00025 00026 client.pub("mbed", "Hello World"); 00027 00028 client.sub("mbed", false); 00029 00030 while(true) { 00031 if (pub) client.pub("mbed", "test"); 00032 led = 0; 00033 wait(1); 00034 led = 1; 00035 wait(1); 00036 } 00037 }
Generated on Wed Jul 20 2022 11:48:47 by
1.7.2