Pi PICO W resilience.

Liste des GroupesRevenir à cs raspberry-pi 
Sujet : Pi PICO W resilience.
De : tnp (at) *nospam* invalid.invalid (The Natural Philosopher)
Groupes : comp.sys.raspberry-pi
Date : 07. Mar 2024, 16:41:00
Autres entêtes
Organisation : A little, after lunch
Message-ID : <uscjls$13fau$1@dont-email.me>
User-Agent : Mozilla Thunderbird
I am passing this along so it might be somwhere searchable if anyone has the same problem,
Basically my PICO Ws were not reconnecting to the Wifi after loss of Wifi access point.
This, however seems to work
int main()
{
int ret;
struct tcp_pcb *connection;
char buf[2048];
stdio_init_all();  
         initialise_adc();
        if (cyw43_arch_init_with_country(CYW43_COUNTRY_UK))
{
                   printf("Wi-Fi init failed");
                  return -1;
}
cyw43_arch_enable_sta_mode();
set_hostname(hostname);
sleep_ms(20);
printf("THERMOMETER FOR %s\n",hostname);
        while (TRUE)
{
// *check wifi is up and connect/reconnect as necessary*..
while((cyw43_tcpip_link_status(&cyw43_state,CYW43_ITF_STA)) != CYW43_LINK_UP)
cyw43_arch_wifi_connect_timeout_ms(ssid, password, CYW43_AUTH_WPA2_AES_PSK, 20000);
// do your stuff here...
         sleep_ms(6000);
// rinse and repeat..
}
}
The key issue is that cyw43_tcpip_link_status(&cyw43_state,CYW43_ITF_STA); will not return CYW43_LINK_UP until *everything* is sorted out including DHCP assignment of an IP address...
Fingers crossed this is now reasonably bullet proof.
--
New Socialism consists essentially in being seen to have your heart in the right place whilst your head is in the clouds and your hand is in someone else's pocket.

Date Sujet#  Auteur
7 Mar 24 o Pi PICO W resilience.1The Natural Philosopher

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal