Skip to content

Commit 12bbe5c

Browse files
author
Martin Crossley
committed
only poll cyw43_arch() in main() if we are in polling mode
1 parent e46d277 commit 12bbe5c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pico_w/wifi/mqtt/mqtt_client.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,18 @@ int main(void) {
375375
// We are not in a callback but we can get away with calling mqtt_client_is_connected()
376376
// because it's a read-only operation
377377
while (!state.connect_done || mqtt_client_is_connected(state.mqtt_client_inst)) {
378-
// As supplied the example configures cyw43_arch for thread_safe_background operation
379-
// by linking `pico_cyw43_arch_lwip_threadsafe_background` in CMakeLists.txt, so the
380-
// following two lines are unnecessary (but do no harm). However you will need them
381-
// if you reconfigure the build to use cyw43_arch in polling mode.
378+
379+
#ifdef PICO_CYW43_ARCH_POLL
380+
// if you use cyw43_arch in lwip_poll mode then you must periodically call
381+
// cyw43_arch_poll() from your main loop (see SDK network API documentaion)
382382
cyw43_arch_poll();
383383
cyw43_arch_wait_for_work_until(make_timeout_time_ms(10000));
384+
#else
385+
// as supplied the example configures cyw43_arch for thread_safe_background
386+
// operation (see CMakeLists.txt) so there's no need to poll
387+
sleep_ms(10000);
388+
#endif
389+
384390
}
385391

386392
INFO_printf("mqtt client exiting\n");

0 commit comments

Comments
 (0)