Skip to content

Commit

Permalink
[TESTS] Add cmd for injecting VID & PID
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Dec 28, 2024
1 parent 49b2889 commit 12e4097
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main/tests/cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum {
TESTS_CMDS_OUT_CFG,
TESTS_CMDS_IN_CFG,
TESTS_CMDS_SYSTEM_ID,
TESTS_CMDS_VID_PID,
};

static uint32_t log_offset = 0;
Expand Down Expand Up @@ -121,6 +122,19 @@ char *tests_cmds_hdlr(struct tests_cmds_pkt *pkt) {
/* Set System ID */
wired_adapter.system_id = pkt->data[0];
break;
case TESTS_CMDS_VID_PID:
/* Set device VID & PID */
device = devices[pkt->handle];
if (device) {
bt_data = &bt_adapter.data[device->ids.id];
bt_data->base.vid = *(uint16_t *)&pkt->data[0];
bt_data->base.pid = *(uint16_t *)&pkt->data[2];
printf("# %s: dev: %ld VID: 0x%04X PID: 0x%04X\n", __FUNCTION__,
device->ids.id, bt_data->base.vid, bt_data->base.pid);
TESTS_CMDS_LOG("\"device_vid_pid\": {\"device_id\": %d, \"vid\": %d, \"pid\": %d},\n",
device->ids.id, bt_data->base.vid, bt_data->base.pid);
}
break;
default:
printf("# %s invalid cmd: 0x%02X\n", __FUNCTION__, pkt->cmd);
break;
Expand Down
4 changes: 4 additions & 0 deletions tests/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def send_system_id(self, system_id):
self.__write(0x0A, self.handle, system_id.to_bytes(1, 'big'))
return self.__read()

def send_vid_pid(self, vid, pid):
self.__write(0x0B, self.handle, struct.pack("<HH", vid, pid))
return self.__read()


def main():
name = 'BlueRetro Test'
Expand Down

0 comments on commit 12e4097

Please sign in to comment.