Skip to content

Commit 39cf06e

Browse files
committed
Some MQTT updates
Change /pong to /uptime Display a message if MQTT_SERVER is not defined Put picow_ in the name like the other examples Add details to the readme!
1 parent 3593551 commit 39cf06e

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ App|Description
191191
[picow_httpd](pico_w/wifi/httpd) | Runs a LWIP HTTP server test app
192192
[picow_http_client](pico_w/wifi/http_client) | Demonstrates how to make http and https requests
193193
[picow_http_client_verify](pico_w/wifi/http_client) | Demonstrates how to make a https request with server authentication
194+
[picow_mqtt_client](pico_w/wifi/mqtt) | Demonstrates how to implement an MQTT client application
194195

195196
#### FreeRTOS examples
196197

pico_w/wifi/mqtt/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (DEFINED ENV{MQTT_SERVER} AND (NOT MQTT_SERVER))
66
message("Using MQTT_SERVER from environment ('${MQTT_SERVER}')")
77
endif()
88
if (NOT MQTT_SERVER)
9+
message("Skipping MQTT example as MQTT_SERVER is not defined")
910
return()
1011
endif()
1112
# Define the name of an MQTT broker/server to enable this example
@@ -32,7 +33,7 @@ if (NOT MQTT_CERT_INC)
3233
set(MQTT_CERT_INC mqtt_client.inc)
3334
endif()
3435

35-
set(TARGET_NAME mqtt_client)
36+
set(TARGET_NAME picow_mqtt_client)
3637
add_executable(${TARGET_NAME}
3738
mqtt_client.c
3839
)

pico_w/wifi/mqtt/mqtt_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t f
206206
} else if (strcmp(basic_topic, "/ping") == 0) {
207207
char buf[11];
208208
snprintf(buf, sizeof(buf), "%u", to_ms_since_boot(get_absolute_time()) / 1000);
209-
mqtt_publish(state->mqtt_client_inst, full_topic(state, "/pong"), buf, strlen(buf), MQTT_PUBLISH_QOS, MQTT_PUBLISH_RETAIN, pub_request_cb, state);
209+
mqtt_publish(state->mqtt_client_inst, full_topic(state, "/uptime"), buf, strlen(buf), MQTT_PUBLISH_QOS, MQTT_PUBLISH_RETAIN, pub_request_cb, state);
210210
} else if (strcmp(basic_topic, "/exit") == 0) {
211211
state->stop_client = true; // stop the client when ALL subscriptions are stopped
212212
sub_unsub_topics(state, false); // unsubscribe

0 commit comments

Comments
 (0)