Get the ESSID of the currently connected WiFi access point

This is a one-shot snippet to get the name of the currently connected WiFi access point. PRIVILEGE NEEDED: http://tizen.org/privilege/network.get
//    PRIVILEGE needed to be set in tizen-manifest.xml:
//    http://tizen.org/privilege/network.get

#include <wifi.h>

void get_AP_essid()
{
    wifi_ap_h access_point = NULL;
    char *essid = NULL;
    if (wifi_initialize() == WIFI_ERROR_NONE
        && wifi_get_connected_ap(&access_point) == WIFI_ERROR_NONE
        && wifi_ap_get_essid(access_point, &essid) == WIFI_ERROR_NONE)
    {
        LOGI("Current connected WiFi Access Point essid: %s", essid);
        if (wifi_deinitialize() != WIFI_ERROR_NONE)
        {
            LOGI("Error when deinitializing WiFi!");
        }
    }
    else
    {
        LOGE("Error when trying to retrieve WiFi AP data!");
    }
}

Responses

0 Replies