🌐 English

    WiFi Wireless Network API#

    Oasis provides APIs for using wireless networks.

    When controlling wireless network interfaces with hostapd or wpa_supplicant commands, it is recommended to proceed in a separate process and receive the response through IPC or similar methods. Refer to the Pipe IPC example.

    Header File#

    OasisNet.h

    Functions#

    ssize_t generateWifiPsk ( const char * passphrase , const char * ssid , char * pskstr , size_t size )
    OasisNet.h
    Generates a WiFi PSK.
    Parameters
    passphrase  Phrases such as the WiFi AP connection password entered by the user.
    ssid  The SSID of the WiFi AP.
    pskstr  OUT Returns the generated PSK.
    size  The PSK buffer size. Measured in bytes.
    Return Value
    Returns the generated PSK key length. Measured in bytes.
    int32_t wifiScanNetworks ( std::list<WifiAccessPointInfo> & list , int32_t timeout = 15000000 , bool * cancel_ptr = nullptr )
    OasisNet.h
    Scans for WiFi APs in the local network to obtain a list.
    Parameters
    list  OUT Returns the scanned WiFi AP list. Refer to the structure section below for WifiAccessPointInfo.
    timeout  The waiting time until scanning is completed. Measured in microseconds. The default is 15 seconds.
    cancel_ptr  A bool type pointer for cancellation during scanning. If the user sets the value of this pointer to true, scanning stops.
    Return Value
    Returns the AP list size on success. Returns -1 on failure.

    Below is an example of scanning for WiFi APs for a maximum of 20 seconds.

    bool cancel_scanning_ = false;
    std::list<WifiAccessPointInfo> list;
    wifiScanNetworks(list, 20000000, &cancel_scanning_);
    TRACE0("scan done #%d, canceled?%d\n", list.size(), cancel_scanning_);
    
    int32_t wifiGetConnectedNetworkSSID ( const char * ifname , std::string & essid )
    OasisNet.h
    Obtains the current AP SSID connected to the wireless network interface.
    Parameters
    ifname  The wireless network interface name such as wlan0.
    essid  OUT Returns the SSID of the connected AP. Returns -1 if not connected.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t wifiGetMode ( const char * ifname , std::string & mode )
    OasisNet.h
    Obtains the current mode of the wireless network interface.
    Parameters
    ifname  The wireless network interface name such as wlan0.
    mode  OUT Returns ap if it is AP mode, and returns sta if it is STA mode.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t wifiGetSignalStrength ( const char * ifname , int32_t * strength )
    OasisNet.h
    Obtains the signal strength of the wireless network interface.
    Parameters
    ifname  The wireless network interface name such as wlan0.
    strength  OUT Returns the signal strength (dBm).
    Return Value
    • 0: Success
    • -1: Failure

    Below is the relationship table of levels (0-4) according to signal strength values.

    Strength(dBm) Level Status
    -30 or higher 4 Excellent
    -51 ~ -31 3 Good
    -76 ~ -52 2 Fair
    -80 ~ -77 1 Weak
    -90 ~ -81 0 Very Weak (Unusable)

    Structures#

    OasisNet.h
    Member Type & Name
    Description
    std::string essid
    The SSID of the AP.
    bool is_public
    Public status. If true, no connection password is required.