hello allI was able to fix the pico_w mqtt lwip such that now if the broker is
not present the the pico_w will continue to to restart.
Features
commit d649e05894fc8393da066d371e329ecae80dbf45 (HEAD -> dev,
origin/dev)Author: Edward Vidal Jr <devel...@sbcglobal.net>
Date: Tue May 23 07:47:11 2023 -0600
ver 0.0.09
url = https://github.com/develone/pico_w-mqtt.git
7 FreeRTOS tasks are running on the pico_w
TEST_TASK connects to WiFi and mqtt tskIDLE_PRIORITY + 2UL
BLINK_TASK tskIDLE_PRIORITY + 3UL
WATCHDOG_TASK tskIDLE_PRIORITY + 1UL
SOCKET_TASK tcp socket to pico_w provides debug info tskIDLE_PRIORITY + 6UL
MQTT_TASK publish subscribe model tskIDLE_PRIORITY + 4UL
NTP_TASK tskIDLE_PRIORITY + 5UL
ADC_TASK tskIDLE_PRIORITY + 8UL reads onboard temperature sensor
Time is set on the pico_w using ntp
This command can not be done twice in a row ../pico-cmd pi4-50 requires
../pico-cmd-reset pi4-50 before the 2nd ../pico-cmd pi4-50
These are examples of how 4 leds are cpntrolled using the pico-cmd #2
/*These are are fix for bits[0] &bits[1] not being read correctly*/
if((bits[val]==0x746f6d65)&&(val==0)) mask = 0x3f <<
FIRST_GPIO;
if((bits[val]==0x3565)&&(val==1)) mask = 0x3e << FIRST_GPIO;
if(val>1) mask = bits[val] << FIRST_GPIO;
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'520820000a'
val 0 16515072 mask 0xFC0000
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'521820000a'
val 1 0x3565 mask 0xF80000 16252928 bits 0x3565
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'522820000a'
val 2 mask 15990784 bits 0x3d
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'523820000a'
val 3 mask 15728640 bits 0x3c
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'524820000a'
val 4 mask 15466496 bits 0x3b
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'525820000a'
val 5 mask 15204352 bits 0x3a
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'526820000a'
val 6 mask 14942208 bits 0x39
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'527820000a'
val 7 mask 14680064 bits 0x38
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'528820000a'
val 8 mask 14417920 bits 0x37
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'529820000a'
#first char 1, 2, 3, 4, 5, 6 or x all remotes
#2nd char 6, 7, 8, 9 to to be defined.
This is 6 of six remotes mosquitto_sub -t 'pico/status' -u 'testuser' -P
'password123'
Onboard temperature = 30.42 C remote3
Onboard temperature = 31.35 C remote2
Onboard temperature = 33.69 C remote5
Onboard temperature = 31.35 C remote4
Onboard temperature = 29.01 C remote6
Onboard temperature = 30.42 C remote1
Sending 10 characters provides several commands to the pico_w.
#2nd char 1 alarm pico-cmd-alarm, 2 led control pico-cmd, 3 reset
pico-cmd-reset
#2nd char 6, 7, 8, 9 to to be defined.
#3rd & 4th are alarmhour when the 2nd char is 1
#6th & 7th are alarmmin when the 2nd char is 1
#8th & 9th are arlamsec when the 2nd char is 1
#3rd & 4th are alarmhour when the 2nd char is 1
#6th & 7th are alarmmin when the 2nd char is 1
#8th & 9th are arlamsec when the 2nd char is 1
#2nd char 4 temperature
../pico-cmd-reset pi4-50 where pi4-50 broker
../pico-cmd-C pi4-50 where pi4-50 broker
#2nd char 5 temperature
../pico-cmd-reset pi4-50 where pi4-50 broker
../pico-cmd-F pi4-50 where pi4-50 broker
#2nd char 5 temperature
Onboard temperature = 86.75 F remote1
Onboard temperature = 85.91 F remote3
Onboard temperature = 87.59 F remote2
Onboard temperature = 92.65 F remote5
Onboard temperature = 89.28 F remote4
Onboard temperature = 84.22 F remote6
diff --git a/pico_w/wifi/freertos/iperf/picow_freertos_iperf.c
b/pico_w/wifi/freertos/iperf/picow_freertos_iperf.c
LWIP_PLATFORM_DIAG(("MQTT client \"%s\" connection cb: status %d\n", client_i
nfo->client_id, (int)status));
-
+ if((int)status==256) {
+ /*connecttion with broker lost*/
+ reset_remote=1;
+ watchdog_enable(10, 1);
+ while(reset_remote) {
+ }
+ }
if (status == MQTT_CONNECT_ACCEPTED) {
mosquitto -c /etc/mosquitto/mosquitto.conf
1684843828: New connection from 192.168.1.176:50238 on port 1883.
1684843828: Client remote1 already connected, closing old connection.
1684843828: New client connected from 192.168.1.176:50238 as remote1 (p2, c1,
k10, u'testuser').
1684843882: New connection from 192.168.1.177:58078 on port 1883.
1684843882: New client connected from 192.168.1.177:58078 as remote4 (p2, c1,
k10, u'testuser').
mosquitto_sub -t 'pico/status' -u 'testuser' -P 'password123'
Onboard temperature = 31.82 C remote4
Onboard temperature = 30.42 C remote1
ps -a
PID TTY TIME CMD
882 tty1 00:00:00 bash
4610 pts/3 00:00:00 minicom
6838 pts/2 00:00:00 mosquitto_sub
7129 pts/1 00:00:00 mosquitto
7709 pts/5 00:00:00 ps
kill -9 7129
MQTT client "remote1" connection cb: status 256
Starting FreeRTOS on core 0:
Connected.
mosquitto -c /etc/mosquitto/mosquitto.conf
1684844663: mosquitto version 2.0.11 starting
1684844663: Config loaded from /etc/mosquitto/mosquitto.conf.
1684844663: Opening ipv4 listen socket on port 1883.
1684844663: Opening ipv6 listen socket on port 1883.
1684844663: mosquitto version 2.0.11 running
1684844664: New connection from ::1:40396 on port 1883.
1684844664: New client connected from ::1:40396 as
auto-CE6B4277-17C7-8BC7-9614-FD1E7FF09A09 (p2, c1, k60, u'testuser').
1684844666: New connection from 192.168.1.177:51665 on port 1883.
1684844666: New client connected from 192.168.1.177:51665 as remote4 (p2, c1,
k10, u'testuser').
1684844666: New connection from 192.168.1.176:52782 on port 1883.
1684844666: New client connected from 192.168.1.176:52782 as remote1 (p2, c1,
k10, u'testuser').
../pi_tcp_tests/cli1
Socket created successfully
Connected with server successfully
Starting FreeRTOS on core 0: ver 0.0.09 remote1 Connected. iperf server
192.168.1.176 4001 mqtt_ip = 0xd401a8c0 mqtt_port = 1883 23/05/2023 12:31:36
23/05/2023 12:32:07 Alarm Fired Sunday 23 May 12:32:36 2023 23/05/2023
12:32:38
234567890123456789012301234567890123456789012345678901234567890123456789012345678901230123456789012345678901234567890123456789012345678901234567890123��L�
../pi_tcp_tests/cli2
Socket created successfully
Connected with server successfully
Starting FreeRTOS on core 0: ver 0.0.09 remote2 Connected. iperf server
192.168.1.160 4001 mqtt_ip = 0xd401a8c0 mqtt_port = 1883 23/05/2023 12:42:22
23/05/2023 12:42:53
5678901234567890123012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901230123456789012345678901234567890123456789012345678901234567890123మ�
../pi_tcp_tests/cli3
Socket created successfully
Connected with server successfully
Starting FreeRTOS on core 0: ver 0.0.09 remote3 Connected. iperf server
192.168.1.178 4001 mqtt_ip = 0xd401a8c0 mqtt_port = 1883 23/05/2023 12:54:17
23/05/2023 12:54:48
5678901234567890123012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901230123456789012345678901234567890123456789012345678901234567890123PZ��
../pi_tcp_tests/cli4
Socket created successfully
Connected with server successfully
Starting FreeRTOS on core 0: ver 0.0.09 remote4 Connected. iperf server
192.168.1.177 4001 mqtt_ip = 0xd401a8c0 mqtt_port = 1883 23/05/2023 12:47:40
4567890123456789012345678901234567890123012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901230123456789012345678901234567890123456789012345678901234567890123
'{�
../pi_tcp_tests/cli5
Socket created successfully
Connected with server successfully
Starting FreeRTOS on core 0: ver 0.0.09 remote5 Connected. iperf server
192.168.1.159 4001 mqtt_ip = 0xd401a8c0 mqtt_port = 1883 23/05/2023 12:45:15
4567890123456789012345678901234567890123012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901230123456789012345678901234567890123456789012345678901234567890123��|�
../pi_tcp_tests/cli6
Socket created successfully
Connected with server successfully
Starting FreeRTOS on core 0: ver 0.0.09 remote6 Connected. iperf server
192.168.1.175 4001 mqtt_ip = 0xd401a8c0 mqtt_port = 1883 23/05/2023 12:51:02
4567890123456789012345678901234567890123012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901230123456789012345678901234567890123456789012345678901234567890123p^��
Controlling led pin18, led pin19, led pin20, and led pin21
When is led pin18 -pin21 are on a high is being sent.
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
contents of pico-cmd
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'x27820000a'
led pin18 on led pin19 on led pin20 on led pin21 off
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
contents of pico-cmd
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'x20820000a'
led pin18 off led pin19 off led pin20 off led pin21 off
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
contents of pico-cmd
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'x21820000a'
led pin18 on led pin19 off led pin20 off led pin21 off
../pico-cmd-reset pi4-50
../pico-cmd pi4-50
contents of pico-cmd
mosquitto_pub -h $1 -p 1883 -t 'pico/cmds' -u 'testuser' -P 'password123' -m
'x29820000a'
led pin18 on led pin19 off led pin20 off led pin21 on
Edward Vidal Jr. e-mail devel...@sbcglobal.net 915-595-1613
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users