diff --git a/doc/mqtt_client.txt b/doc/mqtt_client.txt index 7fd93a8e..1e039815 100644 --- a/doc/mqtt_client.txt +++ b/doc/mqtt_client.txt @@ -3,11 +3,13 @@ MQTT client for lwIP Author: Erik Andersson Details of the MQTT protocol can be found at: -http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html +http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html ----------------------------------------------------------------- 1. Initial steps, reserve memory and make connection to server: +You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use MQTT! + 1.1: Provide storage Static allocation: @@ -19,34 +21,34 @@ Dynamic allocation: if(client != NULL) { example_do_connect(&client); } - + 1.2: Establish Connection with server void example_do_connect(mqtt_client_t *client) { struct mqtt_connect_client_info_t ci; err_t err; - + /* Setup an empty client info structure */ memset(&ci, 0, sizeof(ci)); - - /* Minimal amount of information required is client identifier, so set it here */ + + /* Minimal amount of information required is client identifier, so set it here */ ci.client_id = "lwip_test"; - + /* Initiate client and connect to server, if this fails immediately an error code is returned - otherwise mqtt_connection_cb will be called with connection result after attempting - to establish a connection with the server. + otherwise mqtt_connection_cb will be called with connection result after attempting + to establish a connection with the server. For now MQTT version 3.1.1 is always used */ - + err = mqtt_client_connect(client, ip_addr, MQTT_PORT, mqtt_connection_cb, 0, &ci); - + /* For now just print the result code if something goes wrong */ if(err != ERR_OK) { printf("mqtt_connect return %d\n", err); } } -Connection to server can also be probed by calling mqtt_client_is_connected(client) +Connection to server can also be probed by calling mqtt_client_is_connected(client) ----------------------------------------------------------------- 2. Implementing the connection status callback @@ -57,11 +59,11 @@ static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection err_t err; if(status == MQTT_CONNECT_ACCEPTED) { printf("mqtt_connection_cb: Successfully connected\n"); - + /* Setup callback for incoming publish requests */ mqtt_set_inpub_callback(client, mqtt_incoming_publish_cb, mqtt_incoming_data_cb, arg); - - /* Subscribe to a topic named "subtopic" with QoS level 1, call mqtt_sub_request_cb with result */ + + /* Subscribe to a topic named "subtopic" with QoS level 1, call mqtt_sub_request_cb with result */ err = mqtt_subscribe(client, "subtopic", 1, mqtt_sub_request_cb, arg); if(err != ERR_OK) { @@ -69,16 +71,16 @@ static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection } } else { printf("mqtt_connection_cb: Disconnected, reason: %d\n", status); - + /* Its more nice to be connected, so try to reconnect */ example_do_connect(client); - } + } } static void mqtt_sub_request_cb(void *arg, err_t result) { - /* Just print the result code here for simplicity, - normal behaviour would be to take some action if subscribe fails like + /* Just print the result code here for simplicity, + normal behaviour would be to take some action if subscribe fails like notifying user, retry subscribe or disconnect from server */ printf("Subscribe result: %d\n", result); } diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 5130bf32..56c92415 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -8,6 +8,8 @@ * RFC 6762 - Multicast DNS\n * RFC 6763 - DNS-Based Service Discovery\n * + * You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use MDNS! + * * @verbinclude mdns.txt * * Things left to implement: diff --git a/src/apps/sntp/sntp.c b/src/apps/sntp/sntp.c index edafc0f8..a6c4ff07 100644 --- a/src/apps/sntp/sntp.c +++ b/src/apps/sntp/sntp.c @@ -42,6 +42,8 @@ * This is simple "SNTP" client for the lwIP raw API. * It is a minimal implementation of SNTPv4 as specified in RFC 4330. * + * You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use SNTP! + * * For a list of some public NTP servers, see this link: * http://support.ntp.org/bin/view/Servers/NTPPoolServers * diff --git a/src/apps/tftp/tftp.c b/src/apps/tftp/tftp.c index c5b89ff3..c6887c8e 100644 --- a/src/apps/tftp/tftp.c +++ b/src/apps/tftp/tftp.c @@ -45,6 +45,7 @@ * @ingroup apps * * This is simple TFTP client/server for the lwIP raw API. + * You need to increase MEMP_NUM_SYS_TIMEOUT by one if you use TFTP! */ #include "lwip/apps/tftp_client.h"