Skip to content

Commit e46d277

Browse files
author
Martin Crossley
committed
protect call to lwIP mqtt_client_new()
Note that start_client() may be called direct from main() - i.e. not in a callback
1 parent a23bca5 commit e46d277

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pico_w/wifi/mqtt/mqtt_client.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ static void start_client(MQTT_CLIENT_DATA_T *state) {
259259
const int port = MQTT_PORT;
260260
INFO_printf("Warning: Not using TLS\n");
261261
#endif
262-
262+
// mqtt_client_new() has LWIP_ASSERT_CORE_LOCKED(), so we should protect this call
263+
cyw43_arch_lwip_begin();
263264
state->mqtt_client_inst = mqtt_client_new();
265+
cyw43_arch_lwip_end();
264266
if (!state->mqtt_client_inst) {
265267
panic("MQTT client instance creation error");
266268
}

0 commit comments

Comments
 (0)