summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhcid/dbus-test27
-rw-r--r--hcid/dbus.c79
-rw-r--r--hcid/dbus.h13
3 files changed, 73 insertions, 46 deletions
diff --git a/hcid/dbus-test b/hcid/dbus-test
index ddd3c5f37..0d20ae7d5 100755
--- a/hcid/dbus-test
+++ b/hcid/dbus-test
@@ -182,12 +182,12 @@ class Tester:
# Device.Controller methods
elif self.cmd == 'Inquiry':
- if len(self.cmd_args) != 2:
- length, maxrsp = (10, 100)
- else:
- length, maxrsp = self.cmd_args
try:
- self.ctl.Inquiry(dbus.Byte(length), dbus.Byte(maxrsp))
+ if len(self.cmd_args) != 2:
+ self.ctl.Inquiry()
+ else:
+ length, lap = self.cmd_args
+ self.ctl.Inquiry(dbus.Byte(length), dbus.UInt32(long(lap, 0)))
except dbus.DBusException, e:
print 'Sending %s failed: %s' % (self.cmd, e)
sys.exit(1)
@@ -216,13 +216,18 @@ class Tester:
self.exit_events.append('RemoteName')
elif self.cmd == 'PeriodicInquiry':
- if len(self.cmd_args) != 3:
- length, min, max = (6, 20, 60)
- else:
- length, min, max = self.cmd_args
- self.listen = True
try:
- self.ctl.PeriodicInquiry(dbus.Byte(length), dbus.UInt16(min), dbus.UInt16(max))
+ if len(self.cmd_args) < 3:
+ length, min, max = (6, 20, 60)
+ self.ctl.PeriodicInquiry(dbus.Byte(length), dbus.UInt16(min), dbus.UInt16(max))
+ elif len(self.cmd_args) == 3:
+ length, min, max = self.cmd_args
+ self.ctl.PeriodicInquiry(dbus.Byte(length), dbus.UInt16(min), dbus.UInt16(max))
+ else:
+ length, min, max, lap = self.cmd_args
+ self.ctl.PeriodicInquiry(dbus.Byte(length), dbus.UInt16(min), dbus.UInt16(max),
+ dbus.UInt32(long(lap, 0)))
+ self.listen = True
except dbus.DBusException, e:
print 'Sending %s failed: %s' % (self.cmd, e)
sys.exit(1)
diff --git a/hcid/dbus.c b/hcid/dbus.c
index cbc18ef2d..c450a66fc 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -356,9 +356,11 @@ static DBusMessage* handle_auth_req(DBusMessage *msg, void *data);
static const struct service_data device_hci_services[] = {
{ HCI_PERIODIC_INQ, handle_periodic_inq_req, HCI_PERIODIC_INQ_SIGNATURE },
+ { HCI_PERIODIC_INQ, handle_periodic_inq_req, HCI_PERIODIC_INQ_EXT_SIGNATURE },
{ HCI_CANCEL_PERIODIC_INQ, handle_cancel_periodic_inq_req, HCI_CANCEL_PERIODIC_INQ_SIGNATURE },
{ HCI_ROLE_SWITCH, handle_role_switch_req, HCI_ROLE_SWITCH_SIGNATURE },
{ HCI_INQ, handle_inq_req, HCI_INQ_SIGNATURE },
+ { HCI_INQ, handle_inq_req, HCI_INQ_EXT_SIGNATURE },
{ HCI_CANCEL_INQ, handle_cancel_inq_req, HCI_CANCEL_INQ_SIGNATURE },
{ HCI_REMOTE_NAME, handle_remote_name_req, HCI_REMOTE_NAME_SIGNATURE },
{ HCI_CONNECTIONS, handle_display_conn_req, HCI_CONNECTIONS_SIGNATURE },
@@ -1312,9 +1314,10 @@ static DBusMessage* handle_periodic_inq_req(DBusMessage *msg, void *data)
periodic_inquiry_cp inq_param;
DBusMessage *reply = NULL;
struct hci_dbus_data *dbus_data = data;
- uint8_t length;
+ uint8_t length, num_rsp = 0;
uint16_t max_period;
uint16_t min_period;
+ uint32_t lap = 0x9e8b33;
int dd = -1;
dd = hci_open_dev(dbus_data->dev_id);
@@ -1324,42 +1327,50 @@ static DBusMessage* handle_periodic_inq_req(DBusMessage *msg, void *data)
goto failed;
}
- dbus_message_get_args(msg, NULL,
- DBUS_TYPE_BYTE, &length,
- DBUS_TYPE_UINT16, &min_period,
- DBUS_TYPE_UINT16, &max_period,
- DBUS_TYPE_INVALID);
-
- syslog(LOG_DEBUG, "%02X %04X %04X", length, min_period, max_period);
-
- if (length >= min_period || min_period >= max_period) {
+ if (dbus_message_has_signature(msg, HCI_PERIODIC_INQ_EXT_SIGNATURE))
+ dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_BYTE, &length,
+ DBUS_TYPE_UINT16, &min_period,
+ DBUS_TYPE_UINT16, &max_period,
+ DBUS_TYPE_UINT32, &lap,
+ DBUS_TYPE_INVALID);
+ else
+ dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_BYTE, &length,
+ DBUS_TYPE_UINT16, &min_period,
+ DBUS_TYPE_UINT16, &max_period,
+ DBUS_TYPE_INVALID);
+
+ /* Check for valid parameters */
+ if (length >= min_period || min_period >= max_period
+ || length < 0x01 || length > 0x30
+ || lap < 0x9e8b00 || lap > 0x9e8b3f) {
reply = bluez_new_failure_msg(msg, BLUEZ_EDBUS_WRONG_PARAM);
goto failed;
}
- inq_param.num_rsp = 100;
+ inq_param.num_rsp = num_rsp;
inq_param.length = length;
inq_param.max_period = htobs(max_period);
inq_param.min_period = htobs(min_period);
- /* General/Unlimited Inquiry Access Code (GIAC) */
- inq_param.lap[0] = 0x33;
- inq_param.lap[1] = 0x8b;
- inq_param.lap[2] = 0x9e;
+ inq_param.lap[0] = lap & 0xff;
+ inq_param.lap[1] = (lap >> 8) & 0xff;
+ inq_param.lap[2] = (lap >> 16) & 0xff;
- inq_mode.mode = 1; //INQUIRY_WITH_RSSI;
+ inq_mode.mode = 1; // INQUIRY_WITH_RSSI
if (hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_INQUIRY_MODE,
WRITE_INQUIRY_MODE_CP_SIZE, &inq_mode) < 0) {
- syslog(LOG_ERR, "Can't set inquiry mode:%s.", strerror(errno));
+ syslog(LOG_ERR, "Can't set inquiry mode: %s", strerror(errno));
reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET + errno);
goto failed;
}
if (hci_send_cmd(dd, OGF_LINK_CTL, OCF_PERIODIC_INQUIRY,
PERIODIC_INQUIRY_CP_SIZE, &inq_param) < 0) {
- syslog(LOG_ERR, "Can't send HCI commands:%s.", strerror(errno));
+ syslog(LOG_ERR, "Can't send HCI commands: %s", strerror(errno));
reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET + errno);
goto failed;
}
@@ -1387,7 +1398,7 @@ static DBusMessage* handle_cancel_periodic_inq_req(DBusMessage *msg, void *data)
}
if (hci_send_cmd(dd, OGF_LINK_CTL, OCF_EXIT_PERIODIC_INQUIRY, 0 , NULL) < 0) {
- syslog(LOG_ERR, "Send hci command failed.");
+ syslog(LOG_ERR, "Send HCI command failed");
reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET + errno);
goto failed;
}
@@ -1409,16 +1420,20 @@ static DBusMessage* handle_inq_req(DBusMessage *msg, void *data)
struct hci_request rq;
struct hci_dbus_data *dbus_data = data;
int dd = -1;
- uint8_t length, num_rsp;
-
- dbus_message_get_args(msg, NULL,
- DBUS_TYPE_BYTE, &length,
- DBUS_TYPE_BYTE, &num_rsp,
- DBUS_TYPE_INVALID);
-
- if (length < 0x01 || length > 0x30) {
- reply = bluez_new_failure_msg(msg, BLUEZ_EDBUS_WRONG_PARAM);
- goto failed;
+ uint8_t length = 8, num_rsp = 0;
+ uint32_t lap = 0x9e8b33;
+
+ if (dbus_message_has_signature(msg, HCI_INQ_EXT_SIGNATURE)) {
+ dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_BYTE, &length,
+ DBUS_TYPE_UINT32, &lap,
+ DBUS_TYPE_INVALID);
+
+ if (length < 0x01 || length > 0x30
+ || lap < 0x9e8b00 || lap > 0x9e8b3f) {
+ reply = bluez_new_failure_msg(msg, BLUEZ_EDBUS_WRONG_PARAM);
+ goto failed;
+ }
}
dd = hci_open_dev(dbus_data->dev_id);
@@ -1429,9 +1444,9 @@ static DBusMessage* handle_inq_req(DBusMessage *msg, void *data)
}
memset(&cp, 0, sizeof(cp));
- cp.lap[0] = 0x33;
- cp.lap[1] = 0x8b;
- cp.lap[2] = 0x9e;
+ cp.lap[0] = lap & 0xff;
+ cp.lap[1] = (lap >> 8) & 0xff;
+ cp.lap[2] = (lap >> 16) & 0xff;
cp.length = length;
cp.num_rsp = num_rsp;
diff --git a/hcid/dbus.h b/hcid/dbus.h
index aee5b416c..557a66866 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -164,16 +164,23 @@
#define DEV_GET_PROPERTY_SIGNATURE DBUS_TYPE_STRING_AS_STRING \
__END_SIG__
-
#define HCI_PERIODIC_INQ_SIGNATURE DBUS_TYPE_BYTE_AS_STRING \
DBUS_TYPE_UINT16_AS_STRING \
DBUS_TYPE_UINT16_AS_STRING \
__END_SIG__
+#define HCI_PERIODIC_INQ_EXT_SIGNATURE DBUS_TYPE_BYTE_AS_STRING \
+ DBUS_TYPE_UINT16_AS_STRING \
+ DBUS_TYPE_UINT16_AS_STRING \
+ DBUS_TYPE_UINT32_AS_STRING \
+ __END_SIG__
+
#define HCI_CANCEL_PERIODIC_INQ_SIGNATURE __END_SIG__
-#define HCI_INQ_SIGNATURE DBUS_TYPE_BYTE_AS_STRING \
- DBUS_TYPE_BYTE_AS_STRING \
+#define HCI_INQ_SIGNATURE __END_SIG__
+
+#define HCI_INQ_EXT_SIGNATURE DBUS_TYPE_BYTE_AS_STRING \
+ DBUS_TYPE_UINT32_AS_STRING \
__END_SIG__
#define HCI_CANCEL_INQ_SIGNATURE __END_SIG__