NET_EVENT_NET_STATE_IND,
NET_EVENT_WIFI_SCAN_RSP,
NET_EVENT_WIFI_SCAN_IND,
+ NET_EVENT_WIFI_SCAN_STARTED,
NET_EVENT_WIFI_MAC_ID_IND, /** This is deprecated Event and maintained only for compatibility */
NET_EVENT_WIFI_POWER_RSP,
NET_EVENT_WIFI_POWER_IND,
#define SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved"
#define SIGNAL_SERVICES_CHANGED "ServicesChanged"
#define SIGNAL_SCAN_DONE "ScanDone"
+#define SIGNAL_SCAN_STARTED "ScanStarted"
#define CONNMAN_WIFI_TECHNOLOGY_PREFIX CONNMAN_PATH "/technology/wifi"
WIFI_MANAGER_RSSI_LEVEL_4 = 4, /**< level 4 */
} wifi_manager_rssi_level_e;
+/**
+ * @brief Enumeration for the wifi scanning state.
+ * @since_tizen 4.0
+ */
+typedef enum {
+ WIFI_MANAGER_SCAN_STATE_NOT_SCANNING = 0, /**< Scan is not running */
+ WIFI_MANAGER_SCAN_STATE_SCANNING = 1, /**< Scan is in progress */
+} wifi_manager_scan_state_e;
+
/**
* @}
*/
*/
typedef void(*wifi_manager_scan_finished_cb)(wifi_manager_error_e error_code, void *user_data);
+/**
+ * @brief Called when the scanning state is changed.
+ * @since_tizen 4.0
+ * @param[in] scan_state The wifi scanning status
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see wifi_manager_set_scan_state_changed_cb()
+ * @see wifi_manager_unset_scan_state_changed_cb()
+ */
+typedef void(*wifi_manager_scan_state_changed_cb)(wifi_manager_scan_state_e state, void *user_data);
+
/**
* @brief Called after wifi_manager_activate() or wifi_manager_activate_with_wifi_picker_tested() is completed.
* @since_tizen 3.0
*/
int wifi_manager_unset_background_scan_cb(wifi_manager_h wifi);
+/**
+ * @brief Registers the callback called when the scanning state is changed.
+ * @since_tizen 4.0
+ * @param[in] wifi The wifi handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 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_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_set_scan_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_scan_state_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback called when the scanning state is changed.
+ * @since_tizen 4.0
+ * @param[in] wifi The wifi handle
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ */
+int wifi_manager_unset_scan_state_changed_cb(wifi_manager_h wifi);
+
/**
* @brief Registers the callback called when the connection state is changed.
* @since_tizen 3.0
WIFI_DEVICE_STATE_CB,
WIFI_BG_SCAN_CB,
WIFI_SCAN_REQUEST_CB,
+ WIFI_SCAN_STARTED_CB,
WIFI_SPECIFIC_SCAN_CB,
WIFI_MANAGER_CONNECTION_STATE_CB,
WIFI_ACTIVATED_CB,
void *bg_scan_user_data;
wifi_manager_scan_finished_cb scan_request_cb;
void *scan_request_user_data;
+ wifi_manager_scan_state_changed_cb scan_started_cb;
+ void *scan_started_user_data;
wifi_manager_scan_finished_cb specific_scan_cb;
void *specific_scan_user_data;
wifi_manager_connection_state_changed_cb connection_state_cb;
static __thread guint gdbus_conn_subscribe_id_connman_state = 0;
static __thread guint gdbus_conn_subscribe_id_connman_error = 0;
static __thread guint gdbus_conn_subscribe_id_connman_scandone = 0;
+static __thread guint gdbus_conn_subscribe_id_connman_scanstarted = 0;
static __thread guint gdbus_conn_subscribe_id_netconfig_wifi = 0;
static __thread guint gdbus_conn_subscribe_id_netconfig = 0;
static __thread int net_dpm_wifi_state = -1;
return NET_ERR_NONE;
}
+static int __net_handle_scan_started(GVariant *param)
+{
+ net_event_info_s event_data = { 0, };
+
+ event_data.Event = NET_EVENT_WIFI_SCAN_STARTED;
+ event_data.Error = NET_ERR_NONE;
+ event_data.Datalength = 0;
+ event_data.Data = NULL;
+
+ _net_client_callback(&event_data);
+
+ return NET_ERR_NONE;
+}
+
static int __net_handle_scan_done(GVariant *param)
{
net_event_info_s event_data = { 0, };
const gchar *name, const gchar *path, const gchar *interface,
const gchar *sig, GVariant *param, gpointer user_data)
{
- if (g_strcmp0(sig, SIGNAL_SCAN_DONE) == 0)
+ if (g_strcmp0(sig, SIGNAL_SCAN_STARTED) == 0)
+ __net_handle_scan_started(param);
+ else if (g_strcmp0(sig, SIGNAL_SCAN_DONE) == 0)
__net_handle_scan_done(param);
}
gdbus_conn_subscribe_id_connman_error);
g_dbus_connection_signal_unsubscribe(connection,
gdbus_conn_subscribe_id_connman_scandone);
+ g_dbus_connection_signal_unsubscribe(connection,
+ gdbus_conn_subscribe_id_connman_scanstarted);
g_dbus_connection_signal_unsubscribe(connection,
gdbus_conn_subscribe_id_netconfig_wifi);
g_dbus_connection_signal_unsubscribe(connection,
NULL,
NULL);
+ /* Create connman service scanstarted connection */
+ gdbus_conn_subscribe_id_connman_scanstarted = g_dbus_connection_signal_subscribe(
+ connection,
+ CONNMAN_SERVICE,
+ CONNMAN_MANAGER_INTERFACE,
+ "ScanStarted",
+ CONNMAN_MANAGER_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __net_connman_manager_signal_filter,
+ NULL,
+ NULL);
+
/* Create net-config service connection */
gdbus_conn_subscribe_id_netconfig_wifi = g_dbus_connection_signal_subscribe(
connection,
gdbus_conn_subscribe_id_connman_error == 0 ||
gdbus_conn_subscribe_id_netconfig == 0 ||
gdbus_conn_subscribe_id_connman_scandone == 0 ||
+ gdbus_conn_subscribe_id_connman_scanstarted == 0 ||
gdbus_conn_subscribe_id_netconfig_wifi == 0) {
WIFI_LOG(WIFI_ERROR, "Failed register signals " //LCOV_EXCL_LINE
"connman_state(%d), connman_error(%d), netconfig(%d), "
gdbus_conn_subscribe_id_connman_error,
gdbus_conn_subscribe_id_netconfig,
gdbus_conn_subscribe_id_connman_scandone,
+ gdbus_conn_subscribe_id_connman_scanstarted,
gdbus_conn_subscribe_id_netconfig_wifi);
Error = NET_ERR_NOT_SUPPORTED; //LCOV_EXCL_LINE
}
}
}
+static void __scan_started_cb(net_event_info_s *event_cb)
+{
+ GSList *list;
+ wifi_manager_scan_state_e scan_state;
+
+ if (net_check_ref_count() != true) {
+ WIFI_LOG(WIFI_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (event_cb->Error != NET_ERR_NONE) {
+ WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error);
+ scan_state = WIFI_MANAGER_SCAN_STATE_NOT_SCANNING;
+ } else
+ scan_state = WIFI_MANAGER_SCAN_STATE_SCANNING;
+
+ if (_wifi_get_callback_count_from_handle_list(WIFI_SCAN_STARTED_CB)) {
+ for (list = wifi_manager_handle_list; list; list = list->next) {
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)list->data;
+ if (local_handle->scan_started_cb)
+ local_handle->scan_started_cb(scan_state, local_handle->scan_started_user_data);
+ }
+ }
+}
+
static void __specific_scan_cb(net_event_info_s *event_cb)
{
GSList *list;
WIFI_LOG(WIFI_INFO, "Got Wi-Fi specific scan IND\n");
__specific_scan_cb(event_cb);
break;
+ case NET_EVENT_WIFI_SCAN_STARTED:
+ WIFI_LOG(WIFI_INFO, "Got Wi-Fi scan started event\n");
+ __scan_started_cb(event_cb);
+ break;
case NET_EVENT_WIFI_POWER_RSP:
is_requested = true;
/* fall through */
if (local_handle->bg_scan_cb)
++count;
break;
+ case WIFI_SCAN_STARTED_CB:
+ if (local_handle->scan_started_cb)
+ ++count;
+ break;
case WIFI_SCAN_REQUEST_CB:
if (local_handle->scan_request_cb)
++count;
return WIFI_MANAGER_ERROR_NONE;
}
+static int __wifi_set_scan_state_changed_cb(wifi_manager_h wifi,
+ void *callback, void *user_data)
+{
+ wifi_manager_handle_s *local_handle = (wifi_manager_handle_s *)wifi;
+
+ local_handle->scan_started_cb = callback;
+ local_handle->scan_started_user_data = user_data;
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
static int __wifi_set_connection_state_changed_cb(wifi_manager_h wifi,
void *callback, void *user_data)
{
return __wifi_set_background_scan_cb(wifi, NULL, NULL);
}
+EXPORT_API int wifi_manager_set_scan_state_changed_cb(wifi_manager_h wifi,
+ wifi_manager_scan_state_changed_cb callback, void* user_data)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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_scan_state_changed_cb(wifi, callback, user_data);
+}
+
+EXPORT_API int wifi_manager_unset_scan_state_changed_cb(wifi_manager_h wifi)
+{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ 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_scan_state_changed_cb(wifi, NULL, NULL);
+}
+
EXPORT_API int wifi_manager_set_connection_state_changed_cb(wifi_manager_h wifi,
wifi_manager_connection_state_changed_cb callback, void *user_data)
{
printf(", state : Deactivated\n");
}
+static void __test_scan_started_callback(wifi_manager_scan_state_e state, void* user_data)
+{
+ printf("Scan Started, scan state : %d\n", state);
+}
+
static void __test_bg_scan_completed_callback(wifi_manager_error_e error_code, void* user_data)
{
printf("[%s] Background Scan Completed, error code : %s\n",
if (rv == WIFI_MANAGER_ERROR_NONE) {
wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
+ wifi_manager_set_scan_state_changed_cb(wifi, __test_scan_started_callback, "1");
wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");