Modify bt-oal initialize code readably
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-adapter-mgr.c
index 94148f6..ac4b48e 100644 (file)
@@ -82,30 +82,30 @@ extern void cb_raw_rssi_received(bt_bdaddr_t *bd_addr, int32_t link_type, int32_
 #endif
 
 static bt_callbacks_t callbacks = {
-       sizeof(callbacks),
-       cb_adapter_state_change,
-       cb_adapter_properties,
-       cb_device_properties,
-       cb_adapter_device_found,
-       cb_adapter_discovery_state_changed,
-       cb_device_pin_request,
-       cb_device_ssp_request,
-       cb_device_bond_state_changed,
-       cb_device_acl_state_changed,
-       NULL, /* callback_thread_event */
-       NULL, /* dut_mode_recv_callback */
-       NULL, /* le_test_mode_callback*/
-       NULL, /* energy_info_callback */
-       cb_device_authorize_request,
-       cb_device_trust_state_changed,
+       .size = sizeof(callbacks),
+       .adapter_state_changed_cb = cb_adapter_state_change,
+       .adapter_properties_cb = cb_adapter_properties,
+       .remote_device_properties_cb = cb_device_properties,
+       .device_found_cb = cb_adapter_device_found,
+       .discovery_state_changed_cb = cb_adapter_discovery_state_changed,
+       .pin_request_cb = cb_device_pin_request,
+       .ssp_request_cb = cb_device_ssp_request,
+       .bond_state_changed_cb = cb_device_bond_state_changed,
+       .acl_state_changed_cb = cb_device_acl_state_changed,
+       .thread_evt_cb = NULL,
+       .dut_mode_recv_cb = NULL,
+       .le_test_mode_cb = NULL,
+       .energy_info_cb = NULL,
+       .authorize_request_cb = cb_device_authorize_request,
+       .device_trust_state_changed_cb = cb_device_trust_state_changed,
 #ifdef TIZEN_BT_HAL
-       cb_socket_conn_authorize_request,
-       cb_ble_state_change,
-       cb_device_le_conn_state_changed,
-       cb_device_trusted_profiles_changed,
-       cb_rssi_monitor_state_changed,
-       cb_rssi_alert,
-       cb_raw_rssi_received,
+       .socket_authorize_request_cb = cb_socket_conn_authorize_request,
+       .le_state_changed_cb = cb_ble_state_change,
+       .le_conn_state_changed_cb = cb_device_le_conn_state_changed,
+       .device_trusted_profiles_changed_cb = cb_device_trusted_profiles_changed,
+       .rssi_monitor_state_changed_cb = cb_rssi_monitor_state_changed,
+       .rssi_alert_cb = cb_rssi_alert,
+       .raw_rssi_received_cb = cb_raw_rssi_received,
 #endif
 };
 
@@ -261,6 +261,27 @@ oal_status_t le_deinit(void)
 #endif
        return ret;
 }
+oal_status_t is_advertising(void)
+{
+       int ret = BT_STATUS_SUCCESS;
+       API_TRACE();
+       CHECK_OAL_INITIALIZED();
+#ifdef TIZEN_BT_HAL
+       if (OAL_STATUS_SUCCESS != hw_is_module_ready()) {
+               g_timeout_add(200, retry_enable_le, NULL);
+               return OAL_STATUS_PENDING;
+       }
+       int r = blued_api->is_advertising();
+       if (r == TRUE)
+               ret = BT_STATUS_SUCCESS;
+       else
+               ret = BT_STATUS_FAIL;
+#else
+       BT_INFO("Not Supported");
+       ret = OAL_STATUS_NOT_SUPPORT;
+#endif
+       return ret;
+}
 oal_status_t adapter_start_custom_inquiry(discovery_type_t disc_type)
 {
        int ret;
@@ -534,13 +555,11 @@ oal_status_t adapter_get_service_uuids(void)
        CHECK_OAL_INITIALIZED();
 
        API_TRACE();
-
        ret = blued_api->get_adapter_property(BT_PROPERTY_UUIDS);
        if (ret != BT_STATUS_SUCCESS) {
                BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
                return convert_to_oal_status(ret);
        }
-
        return OAL_STATUS_SUCCESS;
 }
 
@@ -695,6 +714,8 @@ static void cb_adapter_properties(bt_status_t status,
 
        BT_DBG("status: %d, count: %d", status, num_properties);
 
+       print_bt_properties(num_properties, properties);
+
        if (status != BT_STATUS_SUCCESS) {
                if (num_properties == 1) {
                        BT_ERR("Adapter Prop failed: status: [%s], count: %d, prop: %d",
@@ -732,7 +753,7 @@ static void cb_adapter_properties(bt_status_t status,
                                char * adap_name = g_strdup(local_name);
 
                                /* Application has requested this property SET/GET hence send EVENT */
-                               send_event(OAL_EVENT_ADAPTER_PROPERTY_NAME, adap_name, strlen(adap_name));
+                               send_event(OAL_EVENT_ADAPTER_PROPERTY_NAME, adap_name, strlen(adap_name)+1);
                        }
                        break;
                }
@@ -827,6 +848,25 @@ static void cb_adapter_properties(bt_status_t status,
                                        event_data, (sizeof(event_device_list_t) + num_bonded * sizeof(bt_bdaddr_t)));
                        break;
                }
+               case BT_PROPERTY_LOCAL_LE_FEATURES: {
+                       event_adapter_le_features_t *le_features;
+
+                       le_features = g_malloc(sizeof(event_adapter_le_features_t));
+
+                       le_features->max_adv_instance = ((bt_local_le_features_t *)(properties[i].val))->max_adv_instance;
+                       le_features->rpa_offloading = ((bt_local_le_features_t *)(properties[i].val))->rpa_offload_supported;
+                       le_features->max_adv_filter = ((bt_local_le_features_t *)(properties[i].val))->max_adv_filter_supported;
+                       le_features->le_2m_phy_support = ((bt_local_le_features_t *)(properties[i].val))->le_2m_phy_supported;
+                       le_features->le_coded_phy_support = ((bt_local_le_features_t *)(properties[i].val))->le_2m_phy_supported;
+
+                       BT_INFO("LE 2M PHY Support (%d)", le_features->le_2m_phy_support);
+                       BT_INFO("LE CODED PHY Support (%d)", le_features->le_coded_phy_support);
+
+                       send_event(OAL_EVENT_BLE_LOCAL_FEATURES,
+                                       le_features,
+                                       sizeof(event_adapter_le_features_t));
+                       break;
+               }
                default:
                         BT_WARN("Unhandled property: %d", properties[i].type);
                         break;