언어 설정

Menu
Sites
Language
[Tizen 2.3.2] [WiFi] How to connect to hidden AP

Does anybody know how to connect to hidden network using Native API on Gear S3 or Gear Fit2?

 

    int ret = WIFI_ERROR_NONE;
    ret = wifi_ap_hidden_create("blahblah", &ap);
    if (ret != WIFI_ERROR_NONE) {
        ERR("wifi_ap_create failed %d", ret);
    }

    ret = wifi_ap_set_security_type(ap, WIFI_SECURITY_TYPE_WPA2_PSK);
    if (ret != WIFI_ERROR_NONE) {
        ERR("wifi_ap_set_security_type failed %s", get_error_message(ret));
    }


    bool required = false;
    ret = wifi_ap_is_passphrase_required(ap, &required);
    if (ret != WIFI_ERROR_NONE) {
        ERR("wifi_ap_is_passphrase_required failed %s", get_error_message(ret));
    }

    ret = wifi_ap_set_passphrase(ap, "passwdpasswd");
    if (ret != WIFI_ERROR_NONE) {
        ERR("wifi_ap_set_passphrase failed %s", get_error_message(ret));
    }


    ret = wifi_initialize();
    if (ret != WIFI_ERROR_NONE) {
        ERR("wifi_initialize failed %s", get_error_message(ret));
    }

    bool activated = false;
    ret = wifi_is_activated(&activated);
    if (ret != WIFI_ERROR_NONE) {
        ERR("wifi_is_activated failed %s", get_error_message(ret));
    }
    if (!activated) {
        DBG("WiFi not activated");
        ret = wifi_activate(wifiActivatedCb, &ap);
        if (ret != WIFI_ERROR_NONE) {
            ERR("wifi_activate failed %s", get_error_message(ret));
        }
    } else {
        DBG("WiFi activated");
        ret = wifi_connect(ap, wifiConnectedCb, NULL);
        if (ret != WIFI_ERROR_NONE) {
            ERR("wifi_connect failed %s", get_error_message(ret));
        }
    }


 

Unfortunately

wifi_connect

failed with message "opertion failed" error.

As almost always the error codes are totaly uselese in such cases.

Thanks in advance for help :P !!

Responses

5 댓글
Yasin Ali

Hi,


Check if you added these privileges in manifest.

<privileges>
   <privilege>http://tizen.org/privilege/network.get</privilege>
   <privilege>http://tizen.org/privilege/network.set</privilege>
   <privilege>http://tizen.org/privilege/network.profile</privilege>
</privileges>

The Wi-Fi feature is not thread-safe and depends on the ecore main loop.
Implement Wi-Fi within the ecore main loop, and do not use it in a thread.

See link: https://developer.tizen.org/development/guides/native-application/connectivity-and-wireless/wi-fi
Section: Connecting to a Specific Access Point
function wifi_manager_connect

Hope it will help you.
If you find my post is helpful for you, please mark it as answer to promote this post to others.

dev madrad

Hi Yasin,

The privileges are set properly - it is not th cause.

I read all you sent previously as it's a copy of tutorial.

 

Does any condition must be met to connect to hidden wifi? e.g. WiFi activated but not connected?

Yasin Ali

I think device distance may matter. Try keeping minimal distance.

dev madrad

This obvious that the watch must be in AP range. The distance is 1m.

Do I need to specify certificates for the connection?

Yasin Ali

Cert and accurate date time on the device sometimes solve problem.

You may try also.