OSDN Git Service

Adding start_inquiry method to handle inquiry start event.
authorAlok Barsode <alok.barsode@azingo.com>
Mon, 22 Jun 2009 14:57:36 +0000 (20:27 +0530)
committerJohan Hedberg <johan.hedberg@nokia.com>
Tue, 30 Jun 2009 15:25:35 +0000 (18:25 +0300)
src/dbus-hci.c
src/dbus-hci.h
src/security.c

index 710958a..b712afa 100644 (file)
@@ -434,38 +434,6 @@ void hcid_dbus_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
        device_simple_pairing_complete(device, status);
 }
 
-void hcid_dbus_inquiry_start(bdaddr_t *local)
-{
-       struct btd_adapter *adapter;
-       int state;
-
-       adapter = manager_find_adapter(local);
-       if (!adapter) {
-               error("Unable to find matching adapter");
-               return;
-       }
-
-       state = adapter_get_state(adapter);
-       state |= STD_INQUIRY;
-       adapter_set_state(adapter, state);
-       /*
-        * Cancel pending remote name request and clean the device list
-        * when inquiry is supported in periodic inquiry idle state.
-        */
-       if (adapter_get_state(adapter) & PERIODIC_INQUIRY) {
-               pending_remote_name_cancel(adapter);
-
-               clear_found_devices_list(adapter);
-       }
-
-       /* Disable name resolution for non D-Bus clients */
-       if (!adapter_has_discov_sessions(adapter)) {
-               state = adapter_get_state(adapter);
-               state &= ~RESOLVE_NAME;
-               adapter_set_state(adapter, state);
-       }
-}
-
 static int found_device_req_name(struct btd_adapter *adapter)
 {
        struct hci_request rq;
@@ -577,26 +545,6 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
        adapter_set_state(adapter, state);
 }
 
-void hcid_dbus_periodic_inquiry_start(bdaddr_t *local, uint8_t status)
-{
-       struct btd_adapter *adapter;
-       int state;
-
-       /* Don't send the signal if the cmd failed */
-       if (status)
-               return;
-
-       adapter = manager_find_adapter(local);
-       if (!adapter) {
-               error("No matching adapter found");
-               return;
-       }
-
-       state = adapter_get_state(adapter);
-       state |= PERIODIC_INQUIRY;
-       adapter_set_state(adapter, state);
-}
-
 void hcid_dbus_periodic_inquiry_exit(bdaddr_t *local, uint8_t status)
 {
        struct btd_adapter *adapter;
index d46ccf8..0c809f6 100644 (file)
  */
 
 int hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci);
-
-void hcid_dbus_inquiry_start(bdaddr_t *local);
 void hcid_dbus_inquiry_complete(bdaddr_t *local);
-void hcid_dbus_periodic_inquiry_start(bdaddr_t *local, uint8_t status);
 void hcid_dbus_periodic_inquiry_exit(bdaddr_t *local, uint8_t status);
 void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, int8_t rssi, uint8_t *data);
 void hcid_dbus_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class);
index 176a8e3..ccbaebf 100644 (file)
@@ -53,6 +53,7 @@
 #include "adapter.h"
 #include "dbus-hci.h"
 #include "storage.h"
+#include "manager.h"
 
 typedef enum {
        REQ_PENDING,
@@ -551,16 +552,59 @@ reject:
        hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, dba);
 }
 
+static void start_inquiry(bdaddr_t *local, uint8_t status, gboolean periodic)
+{
+       struct btd_adapter *adapter;
+       int state;
+
+       /* Don't send the signal if the cmd failed */
+       if (status) {
+               error("Inquiry Failed with status 0x%02x", status);
+               return;
+       }
+
+       adapter = manager_find_adapter(local);
+       if (!adapter) {
+               error("Unable to find matching adapter");
+               return;
+       }
+
+       state = adapter_get_state(adapter);
+
+       if (periodic) {
+               state |= PERIODIC_INQUIRY;
+               adapter_set_state(adapter, state);
+               return;
+       }
+
+       state |= STD_INQUIRY;
+       adapter_set_state(adapter, state);
+
+       /*
+        * Cancel pending remote name request and clean the device list
+        * when inquiry is supported in periodic inquiry idle state.
+        */
+       if (adapter_get_state(adapter) & PERIODIC_INQUIRY) {
+               pending_remote_name_cancel(adapter);
+
+               clear_found_devices_list(adapter);
+       }
+
+       /* Disable name resolution for non D-Bus clients */
+       if (!adapter_has_discov_sessions(adapter)) {
+               state = adapter_get_state(adapter);
+               state &= ~RESOLVE_NAME;
+               adapter_set_state(adapter, state);
+       }
+}
+
 static inline void cmd_status(int dev, bdaddr_t *sba, void *ptr)
 {
        evt_cmd_status *evt = ptr;
        uint16_t opcode = btohs(evt->opcode);
 
-       if (evt->status)
-               return;
-
        if (opcode == cmd_opcode_pack(OGF_LINK_CTL, OCF_INQUIRY))
-               hcid_dbus_inquiry_start(sba);
+               start_inquiry(sba, evt->status, FALSE);
 }
 
 static inline void cmd_complete(int dev, bdaddr_t *sba, void *ptr)
@@ -572,7 +616,7 @@ static inline void cmd_complete(int dev, bdaddr_t *sba, void *ptr)
        switch (opcode) {
        case cmd_opcode_pack(OGF_LINK_CTL, OCF_PERIODIC_INQUIRY):
                status = *((uint8_t *) ptr + EVT_CMD_COMPLETE_SIZE);
-               hcid_dbus_periodic_inquiry_start(sba, status);
+               start_inquiry(sba, status, TRUE);
                break;
        case cmd_opcode_pack(OGF_LINK_CTL, OCF_EXIT_PERIODIC_INQUIRY):
                status = *((uint8_t *) ptr + EVT_CMD_COMPLETE_SIZE);