[Adapt]Added support for get adapter property APIs 05/77605/1
authorAtul Rai <a.rai@samsung.com>
Thu, 30 Jun 2016 08:52:31 +0000 (17:52 +0900)
committerAtul Rai <a.rai@samsung.com>
Thu, 30 Jun 2016 09:01:26 +0000 (18:01 +0900)
This patch added support to get adapter property APIs mentioned below:
1/ _bt_get_local_address
2/ _bt_get_local_version
3/ _bt_get_local_name
4/ _bt_get_discoverable_mode

Change-Id: I21b15779b44f8ac9b715b32f4f7b6ac2eadee75c
Signed-off-by: Atul Rai <a.rai@samsung.com>
bt-oal/common/oal-event-dispatcher.c
bt-oal/include/oal-adapter-mgr.h
bt-oal/include/oal-event.h
bt-oal/include/oal-manager.h
bt-oal/oal-adapter-mgr.c
bt-service-adaptation/services/adapter/bt-service-core-adapter.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/bt-service-event-receiver.c
bt-service-adaptation/services/include/bt-service-core-adapter.h

index bc35cf4..d5247a3 100755 (executable)
@@ -34,7 +34,7 @@
 
 typedef struct {
        int event;
-       unsigned int size;
+       gsize size;
        gpointer event_data;
 } event_t;
 
index 5b414d0..b0a0ffc 100755 (executable)
@@ -65,6 +65,57 @@ oal_status_t adapter_enable(void);
  */
 oal_status_t adapter_disable(void);
 
+/**
+ * @brief Get local BT chip address
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ * @see OAL_EVENT_ADAPTER_PROPERTY_ADDRESS
+ */
+oal_status_t adapter_get_address(void);
+
+/**
+ * @brief Get local BT version
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ * @see OAL_EVENT_ADAPTER_PROPERTY_VERSION
+ */
+oal_status_t adapter_get_version(void);
+
+/**
+ * @brief Get local BT chip name
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ * @see OAL_EVENT_ADAPTER_PROPERTY_NAME
+ */
+oal_status_t adapter_get_name(void);
+
+/**
+ * @brief Sets output variable to TRUE if adapter is discoverable & connectable.
+ */
+oal_status_t adapter_is_discoverable(int *p_discoverable);
+
+/**
+ * @brief Sets output variable to TRUE if adapter is either discoverable or connectable.
+ */
+oal_status_t adapter_is_connectable(int *p_connectable);
+
+/**
+ * @brief Sets output variable to value of current discoverable timeout.
+ */
+oal_status_t adapter_get_discoverable_timeout(int *p_timeout);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 56fa8b9..d84accc 100755 (executable)
@@ -37,6 +37,7 @@ extern "C" {
        EVENT(OAL_EVENT_ADAPTER_HARDWARE_ERROR) \
        EVENT(OAL_EVENT_ADAPTER_PROPERTY_ADDRESS)                       /* bt_address_t */      \
        EVENT(OAL_EVENT_ADAPTER_PROPERTY_NAME)                          /* char string */\
+       EVENT(OAL_EVENT_ADAPTER_PROPERTY_VERSION)                       /* char string */\
        EVENT(OAL_EVENT_ADAPTER_PROPERTY_SERVICES)                      /* event_adapter_services_t */\
        EVENT(OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE)   \
        EVENT(OAL_EVENT_ADAPTER_MODE_CONNECTABLE)       \
index 0460cac..08bbcb2 100755 (executable)
@@ -28,6 +28,8 @@
 extern "C" {
 #endif
 
+#define BT_VERSION_STR_LEN_MAX       30 /**< This specifies maximum adapter version string length */
+
 #define BT_DEVICE_NAME_LENGTH_MAX       248 /**< This specifies maximum device name length */
 
 #define BT_ADDRESS_BYTES_NUM            6 /**< This specifies bluetooth device address length */
index 0099338..33bd6d2 100755 (executable)
 
 static const bt_interface_t * blued_api;
 
+static bt_address_t local_address;
+static char local_name[BT_DEVICE_NAME_LENGTH_MAX + 1] = {'O', 'A', 'L', 0};
+static char local_version[BT_VERSION_STR_LEN_MAX + 1];
+static bt_scan_mode_t scan_mode = BT_SCAN_MODE_NONE;
+static int discoverable_timeout = 0;
+
 /* Forward declarations */
 const char * status2string(bt_status_t status);
 oal_status_t convert_to_oal_status(bt_status_t status);
@@ -46,11 +52,13 @@ oal_status_t oal_mgr_init_internal(void);
 
 /* Callback registered with Stack */
 static void cb_adapter_state_change(bt_state_t status);
+static void cb_adapter_properties (bt_status_t status,
+               int num_properties, bt_property_t *properties);
 
 static bt_callbacks_t callbacks = {
        sizeof(callbacks),
        cb_adapter_state_change,
-       NULL, /* adapter_properties_callback */
+       cb_adapter_properties,
        NULL, /* remote_device_properties_callback */
        NULL, /* device_found_callback */
        NULL, /* discovery_state_changed_callback */
@@ -145,3 +153,233 @@ static gboolean retry_enable_adapter(gpointer data)
        adapter_enable();
        return FALSE;
 }
+
+oal_status_t adapter_get_address(void)
+{
+       int ret;
+
+       CHECK_OAL_INITIALIZED();
+
+       API_TRACE();
+
+       ret = blued_api->get_adapter_property(BT_PROPERTY_BDADDR);
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_get_version(void)
+{
+       int ret;
+
+       CHECK_OAL_INITIALIZED();
+
+       API_TRACE();
+
+       ret = blued_api->get_adapter_property(BT_PROPERTY_VERSION);
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_get_name(void)
+{
+       int ret;
+
+       CHECK_OAL_INITIALIZED();
+
+       API_TRACE();
+
+       ret = blued_api->get_adapter_property(BT_PROPERTY_BDNAME);
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_is_discoverable(int *p_discoverable)
+{
+       OAL_CHECK_PARAMETER(p_discoverable, return);
+
+       *p_discoverable = (scan_mode == BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
+
+       API_TRACE("%d", *p_discoverable);
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_is_connectable(int *p_connectable)
+{
+       OAL_CHECK_PARAMETER(p_connectable, return);
+
+       *p_connectable = (scan_mode == BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE)
+               ||(scan_mode == BT_SCAN_MODE_CONNECTABLE);
+
+       API_TRACE("%d", *p_connectable);
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_get_discoverable_timeout(int *p_timeout)
+{
+       API_TRACE("%d", discoverable_timeout);
+
+       *p_timeout = discoverable_timeout;
+
+       return OAL_STATUS_SUCCESS;
+}
+
+static void cb_adapter_properties (bt_status_t status,
+                                               int num_properties,
+                                               bt_property_t *properties)
+{
+       int i;
+
+       BT_DBG("status: %d, count: %d", status, num_properties);
+
+       if (status != BT_STATUS_SUCCESS) {
+               if (num_properties == 1) {
+                       BT_ERR("Adapter Prop failed: status: [%s], count: %d, prop: %d",
+                               status2string(status), num_properties, properties[num_properties-1].type);
+               } else {
+                       BT_ERR("Adapter Prop failed: status: [%s], count: %d", status2string(status), num_properties);
+               }
+               return;
+       }
+
+       for (i = 0; i < num_properties; i++) {
+               BT_DBG("prop type %d, len %d", properties[i].type, properties[i].len);
+               switch (properties[i].type) {
+               case BT_PROPERTY_VERSION: {
+                       g_strlcpy(local_version, properties[i].val, BT_VERSION_STR_LEN_MAX);
+                       local_version[properties[i].len] = '\0';
+
+                       BT_DBG("Version: %s", local_version);
+                       /* Send event to application */
+                       if (num_properties == 1) {
+                               char *adapter_ver = g_strdup(local_version);
+
+                               /* Application has requested this property SET/GET hence send EVENT */
+                               send_event(OAL_EVENT_ADAPTER_PROPERTY_VERSION, adapter_ver, strlen(adapter_ver));
+                       }
+                       break;
+               }
+               case BT_PROPERTY_BDNAME: {
+                       g_strlcpy(local_name, properties[i].val, BT_DEVICE_NAME_LENGTH_MAX);
+                       local_name[properties[i].len] = '\0';
+
+                       BT_DBG("Name: %s", local_name);
+                       /* Send event to application */
+                       if (num_properties == 1) {
+                               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));
+                       }
+                       break;
+               }
+               case BT_PROPERTY_BDADDR: {
+                       bt_bdaddr_t * addr;
+
+                       addr =  properties[i].val;
+                       memcpy(local_address.addr, addr->address, 6);
+                       if (num_properties == 1) {
+                               /* Application has requested this property SET/GET hence send EVENT */
+                               send_event(OAL_EVENT_ADAPTER_PROPERTY_ADDRESS,
+                                               g_memdup(&local_address, sizeof(local_address)),
+                                               sizeof(local_address));
+                       }
+                       break;
+               }
+               case BT_PROPERTY_UUIDS: {
+                       int num_uuid;
+
+                       num_uuid = properties[i].len/sizeof(bt_uuid_t);
+
+                       BT_DBG("num_uuid: %d", num_uuid);
+
+                       /* Send event to application */
+                       if (num_properties == 1) {
+                               event_adapter_services_t *uuids_event;
+
+                               uuids_event = g_malloc(sizeof(event_adapter_services_t) + properties[i].len);
+                               memcpy(uuids_event->service_list, properties[i].val, properties[i].len);
+                               uuids_event->num = num_uuid;
+
+                               /* Application has requested this property SET/GET hence send EVENT */
+                               send_event(OAL_EVENT_ADAPTER_PROPERTY_SERVICES,
+                                               uuids_event, (num_uuid * sizeof(bt_uuid_t)));
+                       }
+                       break;
+               }
+               case BT_PROPERTY_ADAPTER_SCAN_MODE: {
+                       bt_scan_mode_t cur_mode = *((bt_scan_mode_t *)properties[i].val);
+
+                       BT_INFO("Scan mode (%d)", cur_mode);
+
+                       scan_mode = cur_mode;
+
+                       /* Send event to application */
+                       if (num_properties == 1) {
+                               oal_event_t event = OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE;
+
+                               if (BT_SCAN_MODE_CONNECTABLE == cur_mode)
+                                       event = OAL_EVENT_ADAPTER_MODE_CONNECTABLE;
+                               else if (BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE == cur_mode)
+                                       event = OAL_EVENT_ADAPTER_MODE_DISCOVERABLE;
+
+                               /* Application has requested this property SET/GET hence send EVENT */
+                               send_event(event, NULL, 0);
+                       }
+                       break;
+               }
+               case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT: {
+                       int timeout;
+
+                       timeout = *((uint32_t*)properties[i].val);
+
+                       BT_INFO("Discoverability timeout: %d", timeout);
+                       discoverable_timeout = timeout;
+
+                       send_event(OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT,
+                                       g_memdup(properties[i].val, sizeof(uint32_t)),
+                                       sizeof(uint32_t));
+                       break;
+               }
+               case BT_PROPERTY_ADAPTER_BONDED_DEVICES: {
+                       int j;
+                       int num_bonded;
+                       bt_bdaddr_t *bonded_addr_list;
+                       event_device_list_t *event_data;
+
+                       num_bonded = properties[i].len/sizeof(bt_bdaddr_t);
+                       BT_DBG("num_bonded %d", num_bonded);
+
+                       if (num_properties > 1) /* No explicit req for this prop, ignore */
+                               break;
+
+                       bonded_addr_list = properties[i].val;
+                       event_data = g_malloc(sizeof(event_device_list_t) + num_bonded*sizeof(bt_address_t));
+                       event_data->num = num_bonded;
+
+                       for (j = 0; j < num_bonded; j++)
+                               memcpy(event_data->devices[j].addr, bonded_addr_list[j].address, 6);
+
+                       send_event(OAL_EVENT_ADAPTER_BONDED_DEVICE_LIST,
+                                       event_data, (num_bonded * sizeof(bt_bdaddr_t)));
+                       break;
+               }
+               default:
+                       BT_WARN("Unhandled property: %d", properties[i].type);
+                       break;
+               }
+       }
+}
index 2683594..d2efaca 100644 (file)
@@ -104,25 +104,170 @@ int _bt_disable_adapter(void)
        return __bt_adapter_state_handle_request(FALSE);
 }
 
+int _bt_get_local_address(void)
+{
+       int result;
+
+       BT_DBG("+");
+
+       result =  adapter_get_address();
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("adapter_get_address failed: %d", result);
+               result = BLUETOOTH_ERROR_INTERNAL;
+       } else
+               result = BLUETOOTH_ERROR_NONE;
+
+       BT_DBG("-");
+       return result;
+}
+
+int _bt_get_local_version(void)
+{
+       int result;
+       BT_DBG("+");
+
+       result =  adapter_get_version();
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("adapter_get_address failed: %d", result);
+               result = BLUETOOTH_ERROR_INTERNAL;
+       } else
+               result = BLUETOOTH_ERROR_NONE;
+
+       BT_DBG("-");
+       return result;
+}
+
+int _bt_get_local_name(void)
+{
+       int result;
+
+       BT_DBG("+");
+
+       result =  adapter_get_name();
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("adapter_get_name failed: %d", result);
+               result = BLUETOOTH_ERROR_INTERNAL;
+       } else
+               result = BLUETOOTH_ERROR_NONE;
+
+       BT_DBG("-");
+       return result;
+}
+
+int _bt_get_discoverable_mode(int *mode)
+{
+       int scan_mode = 0;
+       int timeout = 0;
+
+       BT_DBG("+");
+
+       retv_if(NULL == mode, BLUETOOTH_ERROR_INVALID_PARAM);
+
+       adapter_is_discoverable(&scan_mode);
+       if (TRUE == scan_mode) {
+               adapter_get_discoverable_timeout(&timeout);
+               if (timeout > 0)
+                       *mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
+               else
+                       *mode = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
+       } else {
+               adapter_is_connectable(&scan_mode);
+               if(scan_mode == TRUE)
+                       *mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+               else {
+                       /*
+                        * TODO: NON CONNECTABLE is not defined in bluetooth_discoverable_mode_t.
+                        * After adding BLUETOOTH_DISCOVERABLE_MODE_NON_CONNECTABLE, set mode as
+                        * BLUETOOTH_DISCOVERABLE_MODE_NON_CONNECTABLE. Until then return error.
+                        */
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+       }
+
+       BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
 static void __bt_adapter_event_handler(int event_type, gpointer event_data)
 {
-        BT_DBG("");
+        BT_DBG("+");
 
-        switch(event_type) {
-        case OAL_EVENT_OAL_INITIALISED_SUCCESS:
-        case OAL_EVENT_OAL_INITIALISED_FAILED:
-                __bt_handle_oal_initialisation(event_type);
-                break;
+       switch(event_type) {
+       case OAL_EVENT_OAL_INITIALISED_SUCCESS:
+       case OAL_EVENT_OAL_INITIALISED_FAILED:
+               __bt_handle_oal_initialisation(event_type);
+               break;
        case OAL_EVENT_ADAPTER_ENABLED:
-                __bt_adapter_state_change_callback(BT_ACTIVATED);
-                break;
-        case OAL_EVENT_ADAPTER_DISABLED:
-                __bt_adapter_state_change_callback(BT_DEACTIVATED);
-                break;
+               __bt_adapter_state_change_callback(BT_ACTIVATED);
+               break;
+       case OAL_EVENT_ADAPTER_DISABLED:
+               __bt_adapter_state_change_callback(BT_DEACTIVATED);
+               break;
+       case OAL_EVENT_ADAPTER_PROPERTY_ADDRESS: {
+               bt_address_t *bd_addr = event_data;
+               bluetooth_device_address_t local_address;
+
+               /* Copy data */
+               memcpy(local_address.addr, bd_addr->addr, BT_ADDRESS_LENGTH_MAX);
+               BT_DBG("Adapter address: [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]",
+                               local_address.addr[0], local_address.addr[1], local_address.addr[2],
+                               local_address.addr[3], local_address.addr[4], local_address.addr[5]);
+
+               __bt_adapter_handle_pending_requests(BT_GET_LOCAL_ADDRESS,
+                               (void *) &local_address, sizeof(bluetooth_device_address_t));
+               break;
+       }
+       case OAL_EVENT_ADAPTER_PROPERTY_NAME: {
+               char *name = event_data;
+               bluetooth_device_name_t local_name;
+
+               memset(&local_name, 0x00, sizeof(bluetooth_device_name_t));
+               /* Copy data */
+               g_strlcpy(local_name.name,
+                               (const gchar *)name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+               BT_DBG("Adapter Name: %s", local_name.name);
+
+               __bt_adapter_handle_pending_requests(BT_GET_LOCAL_NAME,
+                               (void *) &local_name, sizeof(bluetooth_device_name_t));
+               break;
+       }
+       case OAL_EVENT_ADAPTER_PROPERTY_VERSION: {
+               char *ver = event_data;
+               bluetooth_version_t local_version;
+
+               memset(&local_version, 0x00, sizeof(bluetooth_version_t));
+               g_strlcpy(local_version.version,
+                               (const gchar *)ver, BLUETOOTH_VERSION_LENGTH_MAX);
+               BT_DBG("BT Version: %s", local_version.version);
+
+               __bt_adapter_handle_pending_requests(BT_GET_LOCAL_VERSION,
+                               (void *) &local_version, sizeof(bluetooth_version_t));
+               break;
+       }
+       case OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE: {
+               BT_INFO("Adapter discoverable mode: BLUETOOTH_DISCOVERABLE_MODE_NON_CONNECTABLE");
+               break;
+       }
+       case OAL_EVENT_ADAPTER_MODE_CONNECTABLE: {
+               BT_INFO("Adapter discoverable mode: BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE");
+               break;
+       }
+       case OAL_EVENT_ADAPTER_MODE_DISCOVERABLE: {
+               BT_INFO("Adapter discoverable mode: BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE");
+               break;
+       }
+       case OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT: {
+               int *timeout = event_data;
+
+               BT_INFO("Discoverable timeout: [%d]", *timeout);
+               break;
+       }
        default:
                BT_ERR("Unhandled event..");
                break;
        }
+
+       BT_DBG("-");
 }
 
 /* OAL post initialization handler */
@@ -170,15 +315,19 @@ static void __bt_adapter_handle_pending_requests(int service_function, void *use
                out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
 
                switch(service_function) {
-                       case BT_ENABLE_ADAPTER:
-                       case BT_DISABLE_ADAPTER:
-                       {
-                               gboolean done = TRUE;
-                               g_array_append_vals(out_param, &done, sizeof(gboolean));
-                               break;
-                       }
-                       default:
-                               BT_ERR("Unknown service function[%d]", service_function);
+               case BT_ENABLE_ADAPTER:
+               case BT_DISABLE_ADAPTER: {
+                       gboolean done = TRUE;
+                       g_array_append_vals(out_param, &done, sizeof(gboolean));
+                       break;
+               }
+               case BT_GET_LOCAL_NAME:
+               case BT_GET_LOCAL_ADDRESS:
+               case BT_GET_LOCAL_VERSION:
+                       g_array_append_vals(out_param, user_data, size);
+                       break;
+               default:
+                       BT_ERR("Unknown service function[%d]", service_function);
                }
 
                _bt_service_method_return(req_info->context, out_param, req_info->result);
index 2eb0050..ea19c68 100644 (file)
@@ -275,12 +275,20 @@ static void __bt_service_method(GDBusConnection *connection,
                        /* Return result */
                        if (service_type == BT_CHECK_PRIVILEGE ||
                                        service_function != BT_OPP_PUSH_FILES) {
-                               out_var = g_variant_new_from_data((const GVariantType *)"ay",
-                                               out_param1->data, out_param1->len,
-                                               TRUE, NULL, NULL);
-
-                               GVariant *temp = g_variant_new("(iv)", result, out_var);
-                               g_dbus_method_invocation_return_value(invocation, temp);
+                               if (!__bt_is_sync_function(service_function)) {
+                                       out_var = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       out_param1->data, out_param1->len,
+                                                       TRUE, NULL, NULL);
+
+                                       GVariant *temp = g_variant_new("(iv)", result, out_var);
+                                       g_dbus_method_invocation_return_value(invocation, temp);
+                               } else {
+                                       /*
+                                        * API expects return value from Bluetooth stack, so just save
+                                        * the invocation and invoke it when we get response from stack.
+                                        */
+                                       BT_INFO("Invocation context will be saved in service_function");
+                               }
 
                                g_array_free(out_param1, TRUE);
                                out_param1 = NULL;
@@ -357,20 +365,59 @@ int __bt_bluez_request(int function_name,
                break;
        }
        case BT_DISABLE_ADAPTER: {
-                result = _bt_disable_adapter();
-                /* Save invocation */
-                if (result == BLUETOOTH_ERROR_NONE) {
-                        BT_DBG("_bt_disable_adapter scheduled successfully! save invocation context");
-                        sender = (char*)g_dbus_method_invocation_get_sender(context);
-                        _bt_save_invocation_context(context, result, sender,
-                                        function_name, NULL);
-                }
-                break;
-        }
+               result = _bt_disable_adapter();
+               /* Save invocation */
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       BT_DBG("_bt_disable_adapter scheduled successfully! save invocation context");
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, NULL);
+               }
+               break;
+       }
+       case BT_GET_LOCAL_ADDRESS: {
+               result = _bt_get_local_address();
+
+               /* Save invocation */
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, NULL);
+               }
+               break;
+       }
+       case BT_GET_LOCAL_VERSION: {
+               result = _bt_get_local_version();
+
+               /* Save invocation */
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, NULL);
+               }
+               break;
+       }
+       case BT_GET_LOCAL_NAME: {
+               result = _bt_get_local_name();
+
+               /* Save invocation */
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, NULL);
+               }
+               break;
+       }
+       case BT_GET_DISCOVERABLE_MODE: {
+               int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+               result = _bt_get_discoverable_mode(&discoverable_mode);
+               g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
+               break;
+       }
        default:
-        BT_INFO("UnSupported function [%d]", function_name);
-        result = BLUETOOTH_ERROR_NOT_SUPPORT;
-        break;
+               BT_INFO("UnSupported function [%d]", function_name);
+               result = BLUETOOTH_ERROR_NOT_SUPPORT;
+               break;
        }
 
        return result;
index 89cc08a..131b842 100644 (file)
@@ -64,11 +64,19 @@ void _bt_service_oal_event_receiver(int event_type, gpointer event_data, gsize l
 {
        BT_INFO("event_type: [%d], data size: [%d]", event_type, len);
 
-       switch(event_type) {
+       switch (event_type) {
        case OAL_EVENT_OAL_INITIALISED_SUCCESS:
        case OAL_EVENT_OAL_INITIALISED_FAILED:
        case OAL_EVENT_ADAPTER_ENABLED:
-        case OAL_EVENT_ADAPTER_DISABLED:
+       case OAL_EVENT_ADAPTER_DISABLED:
+       case OAL_EVENT_ADAPTER_PROPERTY_ADDRESS:
+       case OAL_EVENT_ADAPTER_PROPERTY_NAME:
+       case OAL_EVENT_ADAPTER_PROPERTY_VERSION:
+       case OAL_EVENT_ADAPTER_PROPERTY_SERVICES:
+       case OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE:
+       case OAL_EVENT_ADAPTER_MODE_CONNECTABLE:
+       case OAL_EVENT_ADAPTER_MODE_DISCOVERABLE:
+       case OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT:
                if (adapter_cb)
                        adapter_cb(event_type, event_data);
                break;
index de648c1..06c35b9 100755 (executable)
@@ -47,6 +47,14 @@ int _bt_disable_adapter(void);
 
 int _bt_stack_init(void);
 
+int _bt_get_local_address(void);
+
+int _bt_get_local_version(void);
+
+int _bt_get_local_name(void);
+
+int _bt_get_discoverable_mode(int *mode);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */