summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hidd/hidd.h2
-rw-r--r--hidd/main.c16
-rw-r--r--hidd/sdp.c24
3 files changed, 23 insertions, 19 deletions
diff --git a/hidd/hidd.h b/hidd/hidd.h
index cd0c102c..451bea4e 100644
--- a/hidd/hidd.h
+++ b/hidd/hidd.h
@@ -29,4 +29,4 @@
#define L2CAP_PSM_HIDP_CTRL 0x11
#define L2CAP_PSM_HIDP_INTR 0x13
-int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *req);
+int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, uint8_t *subclass, struct hidp_connadd_req *req);
diff --git a/hidd/main.c b/hidd/main.c
index 7270a235..e4202643 100644
--- a/hidd/main.c
+++ b/hidd/main.c
@@ -156,6 +156,7 @@ static int create_device(int ctl, int csk, int isk, int timeout)
struct hidp_connadd_req req;
struct sockaddr_l2 addr;
socklen_t addrlen;
+ uint8_t subclass;
bdaddr_t src, dst;
char bda[18];
int err;
@@ -182,15 +183,19 @@ static int create_device(int ctl, int csk, int isk, int timeout)
req.flags = 0;
req.idle_to = timeout * 60;
- err = get_hid_device_info(&src, &dst, &req);
+ err = get_hid_device_info(&src, &dst, &subclass, &req);
if (err < 0)
- return err;
+ goto error;
ba2str(&dst, bda);
syslog(LOG_INFO, "New HID device %s (%s)", bda, req.name);
+ if (subclass == 0x40) {
+ }
+
err = ioctl(ctl, HIDPCONNADD, &req);
+error:
if (req.rd_data)
free(req.rd_data);
@@ -228,8 +233,9 @@ static void run_server(int ctl, int csk, int isk, int timeout)
syslog(LOG_ERR, "HID create error %d (%s)",
errno, strerror(errno));
- close(ncsk);
close(nisk);
+ sleep(1);
+ close(ncsk);
}
}
}
@@ -319,7 +325,7 @@ static void do_search(int ctl, bdaddr_t *bdaddr, int timeout)
length = 8; /* ~10 seconds */
num_rsp = 0;
- flags = 0;
+ flags = IREQ_CACHE_FLUSH;
printf("Searching ...\n");
@@ -327,7 +333,7 @@ static void do_search(int ctl, bdaddr_t *bdaddr, int timeout)
for (i = 0; i < num_rsp; i++) {
memcpy(class, (info+i)->dev_class, 3);
- if (class[1] == 0x25 && class[2] == 0x00) {
+ if (class[1] == 0x25 && (class[2] == 0x00 || class[2] == 0x01)) {
bacpy(&dst, &(info+i)->bdaddr);
ba2str(&dst, addr);
diff --git a/hidd/sdp.c b/hidd/sdp.c
index 4db9a4c8..467129b2 100644
--- a/hidd/sdp.c
+++ b/hidd/sdp.c
@@ -49,7 +49,7 @@
#include "hidd.h"
-int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *req)
+int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, uint8_t *subclass, struct hidp_connadd_req *req)
{
uint32_t range = 0x0000ffff;
sdp_session_t *s;
@@ -90,16 +90,13 @@ int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *r
rec = (sdp_record_t *) pnp_rsp->data;
pdlist = sdp_data_get(rec, 0x0201);
- if (pdlist)
- req->vendor = pdlist->val.uint16;
+ req->vendor = pdlist ? pdlist->val.uint16 : 0x0000;
pdlist = sdp_data_get(rec, 0x0202);
- if (pdlist)
- req->product = pdlist->val.uint16;
+ req->product = pdlist ? pdlist->val.uint16 : 0x0000;
pdlist = sdp_data_get(rec, 0x0203);
- if (pdlist)
- req->version = pdlist->val.uint16;
+ req->version = pdlist ? pdlist->val.uint16 : 0x0000;
sdp_record_free(rec);
}
@@ -125,14 +122,15 @@ int get_hid_device_info(bdaddr_t *src, bdaddr_t *dst, struct hidp_connadd_req *r
}
pdlist = sdp_data_get(rec, 0x0201);
- if (pdlist)
- req->parser = pdlist->val.uint16;
- else
- req->parser = 0x0100;
+ req->parser = pdlist ? pdlist->val.uint16 : 0x0100;
+
+ if (subclass) {
+ pdlist = sdp_data_get(rec, 0x0202);
+ *subclass = pdlist ? pdlist->val.uint8 : 0;
+ }
pdlist = sdp_data_get(rec, 0x0203);
- if (pdlist)
- req->country = pdlist->val.uint8;
+ req->country = pdlist ? pdlist->val.uint8 : 0;
pdlist = sdp_data_get(rec, 0x0206);
if (pdlist) {