* limitations under the License.
*/
+#include <shared_vars.h>
#include <context_mgr.h>
#include "device_status_types.h"
#include "wifi.h"
-GENERATE_PROVIDER_COMMON_IMPL(device_status_wifi);
+ctx::device_status_wifi *ctx::device_status_wifi::__instance = NULL;
ctx::device_status_wifi::device_status_wifi()
: last_state(_UNKNOWN)
, is_initialized(false)
, is_activated(false)
{
+ IF_FAIL_VOID_TAG(start_monitor(), _W, "WiFi monitor initialization failed");
+
+ if (!get_current_state()) {
+ stop_monitor();
+ _W("Getting current WiFi status failed");
+ }
}
ctx::device_status_wifi::~device_status_wifi()
{
}
+ctx::context_provider_iface *ctx::device_status_wifi::create(void *data)
+{
+ CREATE_INSTANCE(device_status_wifi);
+}
+
+void ctx::device_status_wifi::destroy(void *data)
+{
+ __instance->stop_monitor();
+ DESTROY_INSTANCE();
+}
+
+void ctx::device_status_wifi::destroy_self()
+{
+ /* WiFi status will be monitored continuously, even if no client is subscribing it */
+}
+
bool ctx::device_status_wifi::is_supported()
{
return get_system_info_bool("tizen.org/feature/network.wifi");
get_bssid();
} else {
last_state = _UNCONNECTED;
+ clear_bssid();
}
} else {
last_state = _DISABLED;
+ clear_bssid();
}
if (!is_initialized)
if (bssid.empty())
_W("Failed to get BSSID");
+ ctx::shared::wifi_bssid = bssid;
+ _D("BSSID: %s", bssid.c_str());
+
return !bssid.empty();
}
+void ctx::device_status_wifi::clear_bssid()
+{
+ bssid.clear();
+ ctx::shared::wifi_bssid.clear();
+ _D("No WiFi connection");
+}
+
bool ctx::device_status_wifi::get_response_packet(ctx::json &data)
{
switch (last_state) {
int ctx::device_status_wifi::subscribe()
{
+#if 0
IF_FAIL_RETURN(start_monitor(), ERR_OPERATION_FAILED);
if (!get_current_state()) {
stop_monitor();
return ERR_OPERATION_FAILED;
}
+#endif
return ERR_NONE;
}
int ctx::device_status_wifi::unsubscribe()
{
+#if 0
stop_monitor();
+#endif
return ERR_NONE;
}
}
if (last_state != prev_state) {
- if (last_state == _CONNECTED)
+ if (last_state == _CONNECTED) {
get_bssid();
+ } else {
+ clear_bssid();
+ }
ctx::json data;
- if (get_response_packet(data))
+ if (being_subscribed && get_response_packet(data))
context_manager::publish(DEVICE_ST_SUBJ_WIFI, NULL, ERR_NONE, data);
}
}