Page 1 of 1

return WL_CONNECT from function

Posted: Sun Nov 10, 2019 11:16 pm
by azz-zza
Hello,
the question is due to my limited knowledge of C.

What is the function type should i specify if i want to check that the esp is connected after calling the function:

Code: Select all

#include <WiFi.h>

<skip>

wl_status_t WIFI_Net_Connect() {

  return WL_CONNECTED;
}



The complier is upset :

Code: Select all

In file included from src/main.cpp:10:0:
include/wireless.h:4:1: error: 'wl_status_t' does not name a type
 wl_status_t WIFI_Net_Connect() ;
 ^
Wifitype.h :

Code: Select all


typedef enum {
    WL_NO_SHIELD        = 255,   // for compatibility with WiFi Shield library
    WL_IDLE_STATUS      = 0,
    WL_NO_SSID_AVAIL    = 1,
    WL_SCAN_COMPLETED   = 2,
    WL_CONNECTED        = 3,
    WL_CONNECT_FAILED   = 4,
    WL_CONNECTION_LOST  = 5,
    WL_DISCONNECTED     = 6
} wl_status_t;

I understand that switching the return type to "int" will work, but kind of not obviuos for support.

At the same time in WiFiSta.h:

Code: Select all

class WiFiSTAClass {
<skip>
    static wl_status_t status();
    static void _setStatus(wl_status_t status);
}
And stackoverflow seemed to "allow" what im trying to do (https://stackoverflow.com/questions/742 ... ction-in-c):
TLDR:

Code: Select all

enum Foo { BAR, BAZ };

enum Foo testFunc(void)
{
    return BAR;
}

Or, with a typedef:

typedef enum Foo { BAR, BAZ } Foo;

Foo testFunc(void)
{
    return BAR;
}
So what am i missing ?


thank you .