static gboolean deinit_is_running = FALSE;
static gboolean check_nfc_disable = FALSE;
+static pthread_mutex_t reset_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t reset_cond = PTHREAD_COND_INITIALIZER;
+
static void controller_async_queue_free_func(gpointer user_data)
{
ControllerFuncData *func_data = (ControllerFuncData *) user_data;
abort();
}
+ pthread_cond_signal(&reset_cond);
DEBUG_SERVER_MSG("net_nfc_server_llcp_set_config success");
}
/* LCOV_EXCL_STOP */
}
#endif
+static void controller_deinit_without_quit_thread_func(gpointer user_data)
+{
+ net_nfc_server_free_target_info();
+
+ if (net_nfc_controller_deinit() == false) {
+ DEBUG_ERR_MSG("net_nfc_controller_deinit failed");
+ return;
+ }
+
+ DEBUG_SERVER_MSG("net_nfc_controller_deinit success");
+}
+
/* LCOV_EXCL_START */
static void restart_polling_loop_thread_func(gpointer user_data)
{
}
}
#endif
+void net_nfc_server_controller_deinit_without_quit()
+{
+ if (controller_async_queue == NULL) {
+ DEBUG_ERR_MSG("controller_async_queue is not initialized"); //LCOV_EXCL_LINE
+
+ return;
+ }
+
+ _push_to_queue(0, false, controller_deinit_without_quit_thread_func, NULL);
+}
+
+void net_nfc_server_controller_reset(void)
+{
+ DEBUG_ERR_MSG("[%s] START", __func__);
+
+ struct timeval now;
+ struct timespec ts;
+
+ gettimeofday(&now, NULL);
+ ts.tv_sec = now.tv_sec + 5;
+ ts.tv_nsec = now.tv_usec * 1000;
+
+ pthread_mutex_lock(&reset_mutex);
+ net_nfc_server_controller_deinit_without_quit();
+ net_nfc_server_controller_init();
+ pthread_cond_timedwait(&reset_cond, &reset_mutex, &ts);
+ pthread_mutex_unlock(&reset_mutex);
+
+ DEBUG_ERR_MSG("[%s] END", __func__);
+}
gboolean net_nfc_server_controller_is_blocked()
{
SECURE_MSG("handle [%p]", handle);
} else {
- DEBUG_ERR_MSG("net_nfc_controller_secure_element_open failed [%d]", result);
+ DEBUG_ERR_MSG("First net_nfc_controller_secure_element_open failed [%d]", result);
+
+ /* Restore state */
+ if (result == NET_NFC_OPERATION_FAIL) {
+ net_nfc_server_controller_reset();
+
+ if (net_nfc_controller_secure_element_open(NET_NFC_SE_TYPE_ESE, &handle, &result) == true) {
+ net_nfc_server_se_set_current_ese_handle(handle);
+
+ SECURE_MSG("handle [%p]", handle);
+ } else {
+ DEBUG_ERR_MSG("Second net_nfc_controller_secure_element_open failed [%d]", result);
+ }
+ }
}
}