*/
typedef void(*wifi_manager_rssi_level_changed_cb)(wifi_manager_rssi_level_e rssi_level, void *user_data);
+/**
+ * @brief Called when the Wi-Fi Module state is changed.
+ * @since_tizen 4.0
+ * @param[in] wifi_module_state The Wi-Fi Module state
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_set_module_state_changed_cb()
+ * @see wifi_manager_unset_module_state_changed_cb()
+ */
+typedef void(*wifi_manager_module_state_changed_cb)(wifi_manager_module_state_e wifi_module_state,
+ void *user_data);
+
/**
* @}
*/
*/
int wifi_manager_unset_rssi_level_changed_cb(wifi_manager_h wifi);
+/**
+ * @brief Registers a callback called when the Wi-Fi Module state is changed.
+ * @since_tizen 4.0
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_module_state_changed_cb()
+ * @see wifi_manager_unset_module_state_changed_cb()
+*/
+int wifi_manager_set_module_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_module_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when the Wi-Fi Module state is changed.
+ * @since_tizen 4.0
+ * @param[in] wifi The Wi-Fi handle
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @see wifi_manager_module_state_changed_cb()
+ * @see wifi_manager_set_module_state_changed_cb()
+ */
+int wifi_manager_unset_module_state_changed_cb(wifi_manager_h wifi);
+
/**
* @brief Gets the Wi-Fi Module state.
* @since_tizen 4.0
void *connected_user_data;
wifi_manager_disconnected_cb disconnected_cb;
void *disconnected_user_data;
-
wifi_manager_rssi_level_changed_cb rssi_level_changed_cb;
void *rssi_level_changed_user_data;
wifi_manager_tdls_state_changed_cb tdls_state_changed_cb;
void *tdls_state_changed_user_data;
wifi_manager_tdls_discovered_cb tdls_discovered_cb;
void *tdls_discovered_user_data;
+ wifi_manager_module_state_changed_cb module_state_changed_cb;
+ void *module_state_changed_user_data;
+
} wifi_manager_handle_s;
int _wifi_get_autoscan(bool *autoscan);
int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode);
int _wifi_get_module_state(wifi_manager_module_state_e *state);
+void _wifi_module_state_changed_cb(keynode_t *node, void *user_data);
return WIFI_MANAGER_ERROR_NONE;
}
+void _wifi_module_state_changed_cb(keynode_t *node, void *user_data)
+{
+ GSList *list;
+ wifi_manager_handle_s *handle;
+ int wifi_device_status = 0;
+
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ handle = (wifi_manager_handle_s *)list->data;
+
+ if (__wifi_check_handle_validity((wifi_manager_h)handle) != true)
+ return;
+
+ if (vconf_get_int(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT, &wifi_device_status) < 0) {
+ WIFI_LOG(WIFI_ERROR, "Unable to read status from vconf key\n");
+ return;
+ }
+
+ WIFI_LOG(WIFI_ERROR, "Wi-Fi Module State [%d]\n", wifi_device_status);
+
+ if (handle->module_state_changed_cb)
+ handle->module_state_changed_cb(wifi_device_status,
+ handle->module_state_changed_user_data);
+ }
+}
+
//LCOV_EXCL_STOP
{
return _wifi_get_count_from_handle_list();
}
+
+static int __wifi_set_module_state_changed_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ static __thread gint refcount = 0;
+ wifi_manager_handle_s *local_handle;
+
+ local_handle = (wifi_manager_handle_s *)wifi;
+
+ if (callback) {
+ if (refcount == 0)
+ vconf_notify_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
+ _wifi_module_state_changed_cb, NULL);
+
+ refcount++;
+ WIFI_LOG(WIFI_INFO, "Successfully registered(%d)", refcount);
+ } else {
+ if (refcount > 0 && local_handle->module_state_changed_cb) {
+ if (--refcount == 0) {
+ if (vconf_ignore_key_changed(VCONFKEY_WIFI_DEVICE_STATUS_UEVENT,
+ _wifi_module_state_changed_cb) < 0) {
+ WIFI_LOG(WIFI_ERROR, "Error to de-register vconf callback(%d)", refcount);
+ } else {
+ WIFI_LOG(WIFI_INFO, "Successfully de-registered(%d)", refcount);
+ }
+ }
+ }
+ }
+
+ local_handle->module_state_changed_cb = callback;
+ local_handle->module_state_changed_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
//LCOV_EXCL_STOP
EXPORT_API int wifi_manager_initialize(wifi_manager_h *wifi)
}
//LCOV_EXCL_STOP
+EXPORT_API int wifi_manager_set_module_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_module_state_changed_cb callback, void* user_data)
+{
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV)
+ return WIFI_MANAGER_ERROR_NOT_SUPPORTED;
+
+ if (callback == NULL || !(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_module_state_changed_cb(wifi, callback, user_data);
+
+}
+
+EXPORT_API int wifi_manager_unset_module_state_changed_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV)
+ return WIFI_MANAGER_ERROR_NOT_SUPPORTED;
+
+ if (!(__wifi_check_handle_validity(wifi))) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ return __wifi_set_module_state_changed_cb(wifi, NULL, NULL);
+}
+
EXPORT_API int wifi_manager_get_module_state(wifi_manager_h wifi,
wifi_manager_module_state_e *state)
{
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV)
+ return WIFI_MANAGER_ERROR_NOT_SUPPORTED;
+
if (state == NULL || !(__wifi_check_handle_validity(wifi))) {
WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
printf(", Discovery is finished");
}
+static void __test_get_wifi_module_state_callback(wifi_manager_module_state_e state, void *user_data)
+{
+ printf("Wi-Fi Module State Changed callback : %d", state);
+
+ if (state == WIFI_MANAGER_MODULE_STATE_ATTACHED)
+ printf(", Wi-Fi Module Attached\n");
+ else
+ printf(", Wi-Fi Module Detached\n");
+}
+
static void __test_tdls_state_callback(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
{
printf("[%s] TDLS state changed callback", (char *)user_data);
wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
wifi_manager_tdls_set_state_changed_cb(wifi, __test_tdls_state_callback, "1");
wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "1");
+ wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "1");
+
} else {
printf("[1] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
return -1;
wifi_manager_set_rssi_level_changed_cb(wifi2, __test_rssi_level_callback, "2");
wifi_manager_tdls_set_state_changed_cb(wifi2, __test_tdls_state_callback, "2");
wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "2");
+ wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "2");
} else {
printf("[2] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
return -1;