-void CALEMainLoopThread(void *param)
-{
- OIC_LOG(DEBUG, TAG, "IN");
-
- int ret = bt_initialize();
- if (BT_ERROR_NONE != ret)
- {
- OIC_LOG(ERROR, TAG, "bt_initialize failed");
- return;
- }
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0);
- if (BT_ERROR_NONE != ret)
- {
- OIC_LOG(ERROR, TAG, "bt_adapter_set_visibility failed");
- return;
- }
-
- ret = bt_adapter_set_state_changed_cb(CALEAdapterStateChangedCb, NULL);
- if (BT_ERROR_NONE != ret)
- {
- OIC_LOG(DEBUG, TAG, "bt_adapter_set_state_changed_cb failed");
- return;
- }
-
- ret = bt_gatt_set_connection_state_changed_cb(CALENWConnectionStateChangedCb, NULL);
- if (BT_ERROR_NONE != ret)
- {
- OIC_LOG_V(ERROR, TAG,
- "bt_gatt_set_connection_state_changed_cb has failed");
- return;
- }
-
- g_mainloop = g_main_loop_new(g_main_context_default(), FALSE);
-
- ca_mutex_lock(g_btinitializeMutex);
- g_isBTStackInitialised = true;
- ca_mutex_unlock(g_btinitializeMutex);
- ca_cond_signal(g_initializeCond);
-
- // Run gmainloop to handle the events from bt stack
- g_main_loop_run(g_mainloop);
- OIC_LOG(DEBUG, TAG, "OUT");
-}
-