summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-11-01 19:05:48 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-11-01 19:05:48 +0000
commite6f085ddedd4159c9c07fba0c2babaa0f0053b01 (patch)
tree184b9ce7e60f5d9fac1c92bb18386deff81e6d77 /tools
parent37c4010967b3e87fa1d510a66adb1c61526fef09 (diff)
Add support for writing complex BCCMD commands
Diffstat (limited to 'tools')
-rw-r--r--tools/csr.c39
-rw-r--r--tools/csr.h1
2 files changed, 40 insertions, 0 deletions
diff --git a/tools/csr.c b/tools/csr.c
index b3d26adf..698122dc 100644
--- a/tools/csr.c
+++ b/tools/csr.c
@@ -2312,6 +2312,45 @@ int csr_write_varid_valueless(int dd, uint16_t seqnum, uint16_t varid)
return 0;
}
+int csr_write_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length)
+{
+ unsigned char cmd[] = { 0x02, 0x00, ((length / 2) + 5) & 0xff, ((length / 2) + 5) >> 8,
+ seqnum & 0xff, seqnum >> 8, varid & 0xff, varid >> 8, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ unsigned char cp[254], rp[254];
+ struct hci_request rq;
+
+ memset(&cp, 0, sizeof(cp));
+ cp[0] = 0xc2;
+ memcpy(cp + 1, cmd, sizeof(cmd));
+ memcpy(cp + 11, value, length);
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_VENDOR_CMD;
+ rq.ocf = 0x00;
+ rq.event = EVT_VENDOR;
+ rq.cparam = cp;
+ rq.clen = sizeof(cmd) + 1;
+ rq.rparam = rp;
+ rq.rlen = sizeof(rp);
+
+ if (hci_send_req(dd, &rq, 2000) < 0)
+ return -1;
+
+ if (rp[0] != 0xc2) {
+ errno = EIO;
+ return -1;
+ }
+
+ if ((rp[9] + (rp[10] << 8)) != 0) {
+ errno = ENXIO;
+ return -1;
+ }
+
+ return 0;
+}
+
int csr_read_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length)
{
unsigned char cmd[] = { 0x00, 0x00, ((length / 2) + 5) & 0xff, ((length / 2) + 5) >> 8,
diff --git a/tools/csr.h b/tools/csr.h
index af5af63f..760235b1 100644
--- a/tools/csr.h
+++ b/tools/csr.h
@@ -502,6 +502,7 @@ char *csr_pskeytostr(uint16_t pskey);
char *csr_pskeytoval(uint16_t pskey);
int csr_write_varid_valueless(int dd, uint16_t seqnum, uint16_t varid);
+int csr_write_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length);
int csr_read_varid_complex(int dd, uint16_t seqnum, uint16_t varid, uint8_t *value, uint16_t length);
int csr_read_varid_uint16(int dd, uint16_t seqnum, uint16_t varid, uint16_t *value);
int csr_read_varid_uint32(int dd, uint16_t seqnum, uint16_t varid, uint32_t *value);