Guilhem Saurel
/
niMQTT_example
An exemple for the lib niMQTT
Revision 0:db40c618e10c, committed 2013-08-07
- Comitter:
- Nim65s
- Date:
- Wed Aug 07 13:42:24 2013 +0000
- Child:
- 1:4fcb7135d040
- Commit message:
- First commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Wed Aug 07 13:42:24 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Nim65s/code/EthernetInterface/#5a856f78b671
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 07 13:42:24 2013 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "rtos.h" +#include "niMQTT.h" +#include "EthernetInterface.h" + +EthernetInterface eth; + +DigitalOut led(LED1); +DigitalIn pub(p14); + +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.51.53", callback); + + client.pub("mbed", "Hello World"); + + client.sub("mbed", false); + + while(true) { + if (pub) client.pub("mbed", "test"); + led = 0; + wait(1); + led = 1; + wait(1); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Wed Aug 07 13:42:24 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#58b30ac3f00e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 07 13:42:24 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/niMQTT.lib Wed Aug 07 13:42:24 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Nim65s/code/niMQTT/#4faa96fa4350