mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-16 16:54:38 +08:00
Add support for writing valueless BCCMD variables
This commit is contained in:
parent
0cc4f1817b
commit
b207244243
46
tools/csr.c
46
tools/csr.c
@ -427,6 +427,52 @@ char *csr_pskeytostr(uint16_t pskey)
|
||||
}
|
||||
}
|
||||
|
||||
int csr_write_varid_valueless(int dd, uint16_t seqnum, uint16_t varid)
|
||||
{
|
||||
unsigned char cmd[] = { 0x02, 0x00, 0x09, 0x00,
|
||||
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));
|
||||
|
||||
switch (varid) {
|
||||
case CSR_VARID_COLD_RESET:
|
||||
case CSR_VARID_WARM_RESET:
|
||||
case CSR_VARID_COLD_HALT:
|
||||
case CSR_VARID_WARM_HALT:
|
||||
return hci_send_cmd(dd, OGF_VENDOR_CMD, 0x00, sizeof(cmd) + 1, cp);
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -75,6 +75,7 @@ char *csr_buildidtostr(uint16_t id);
|
||||
char *csr_chipvertostr(uint16_t ver, uint16_t rev);
|
||||
char *csr_pskeytostr(uint16_t pskey);
|
||||
|
||||
int csr_write_varid_valueless(int dd, uint16_t seqnum, uint16_t varid);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user