CODE
int simpleWFCconnect(){ // simple WFC connect:
Wifi_AutoConnect(); // request connect
while(1) {
int i=Wifi_AssocStatus(); // check status
if(i==ASSOCSTATUS_ASSOCIATED) {
iprintf("Connected successfully! With IP %lu\n", Wifi_GetIP());
return 0;
}
if(i==ASSOCSTATUS_CANNOTCONNECT) {
iprintf("Could not connect! Press \"A\" to try again\n");
iprintf("\"B\" to cancel\n");
while (1){
scanKeys();
u16 keys = keysDown();
if (keys & KEY_A){
/* note: I am just trying this to see if it fixes the problem with the Wifi_AssocStatus function */
Wifi_DisconnectAP();
return simpleWFCconnect();
}
if (keys & KEY_B){
return -1;
}
}
}
}
}
Wifi_AutoConnect(); // request connect
while(1) {
int i=Wifi_AssocStatus(); // check status
if(i==ASSOCSTATUS_ASSOCIATED) {
iprintf("Connected successfully! With IP %lu\n", Wifi_GetIP());
return 0;
}
if(i==ASSOCSTATUS_CANNOTCONNECT) {
iprintf("Could not connect! Press \"A\" to try again\n");
iprintf("\"B\" to cancel\n");
while (1){
scanKeys();
u16 keys = keysDown();
if (keys & KEY_A){
/* note: I am just trying this to see if it fixes the problem with the Wifi_AssocStatus function */
Wifi_DisconnectAP();
return simpleWFCconnect();
}
if (keys & KEY_B){
return -1;
}
}
}
}
}
If the operation fails because it couldn't connect, I would like it to ask the user if they would like to try connecting again (i do this recursively, maybe there is a better way). The problem is, that after it fails once, I try to connect and the associated status is not updated. This sends me immediately into the second conditional. I'm not exactly sure where I am going wrong, any ideas? I also tried adding Wifi_DisconnectAP() (as can be seen in the code example) to see if this would bring things back to a normal state.
-thanks