INTL 3:770/1 3:770/3   
   REPLYADDR tnp@invalid.invalid   
   REPLYTO 3:770/3.0 UUCP   
   MSGID: e3b145d9   
   PID: SoupGate-Win32 v1.05   
   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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)   
   SEEN-BY: 10/0 1 15/0 90/1 103/705 105/81 106/201 128/260 129/305 135/225   
   SEEN-BY: 153/757 7715 218/0 1 601 700 840 870 930 220/70 221/1 6 226/17   
   SEEN-BY: 226/30 100 227/114 229/110 111 112 113 200 206 307 317 400   
   SEEN-BY: 229/426 428 470 550 616 664 700 240/1120 266/512 267/800   
   SEEN-BY: 282/1038 291/111 292/854 301/1 113 812 310/31 320/219 322/757   
   SEEN-BY: 335/364 341/66 342/200 396/45 460/58 633/280 712/848 770/1   
   SEEN-BY: 770/3 100 330 340 772/210 220 230 5020/400 1042 5058/104   
   SEEN-BY: 5075/35   
   PATH: 770/3 1 218/840 221/6 301/1 218/700 229/426   
      
|