WIFI_API int wifi_get_status(wifi_status_t *status);
I'm writing my own "wrapper" for it as:
1 2 3 4 5 6 7 8 9 10
int getWifiStatus();
int getWifiStatus() {
wifi_status_t *status = 0;
int result = 0
result = wifi_get_status(*status);
if (result == 0) {
// i'd like to switch case on the various WIFI_STATUS_* states
}
}
but i'm stuck on how to do a switch - if it's even possible, and how to handle/deal with the *status pointer (i admit, pointers still confuse the crap out of me!).
When you want to get the value the pointer is pointing to, you need to dereference.
wifi_get_status actually expects a pointer, so the dereferencing in line 6 is wrong.
This would be correct:
1 2 3 4 5 6 7 8 9
int getWifiStatus() {
wifi_status_t status;
int result = wifi_get_status(&status);
if (result == 0) {
switch(status) {
...
}
}
}
wifi_status_t status = 0;
Int result =0;
result = wifi_get_status( &status);
//status now holds the wifi status.
// now check state
If(result == 0)
{
switch(status)
{
case WIFI_STATUS_RADIO_OFF:
//handle off status
break;
case WIFI_STATUS_RADIO_ON:
// handle on status
break;
case WIFI_STATUS_BUSY:
// handle busy state
break;
default:
//error
break;
}