mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-02-18 18:46:54 +00:00
Add route for hardware_id
This commit is contained in:
parent
81cce42118
commit
1d96fc866d
@ -317,6 +317,14 @@
|
||||
return_type: u8
|
||||
return_execute: request_bootloader_jump
|
||||
}
|
||||
0x08: {
|
||||
type: command
|
||||
name: info.json
|
||||
define: HARDWARE_ID
|
||||
description: Retrieves a unique identifier for the board.
|
||||
return_type: u32[4]
|
||||
return_execute: get_hardware_id
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -35,6 +35,9 @@ def print_dotted_output(kb_info_json, prefix=''):
|
||||
continue
|
||||
elif key == 'layouts' and prefix == '':
|
||||
cli.echo(' {fg_blue}layouts{fg_reset}: %s', ', '.join(sorted(kb_info_json['layouts'].keys())))
|
||||
elif isinstance(kb_info_json[key], bytes):
|
||||
conv = "".join(["{:02X}".format(b) for b in kb_info_json[key]])
|
||||
cli.echo(' {fg_blue}%s{fg_reset}: %s', new_prefix, conv)
|
||||
elif isinstance(kb_info_json[key], dict):
|
||||
print_dotted_output(kb_info_json[key], new_prefix)
|
||||
elif isinstance(kb_info_json[key], list):
|
||||
@ -105,6 +108,10 @@ def _query_device(device):
|
||||
return {'xap': ver, 'secure': secure}
|
||||
|
||||
|
||||
def _query_device_id(device):
|
||||
return _xap_transaction(device, 0x01, 0x08)
|
||||
|
||||
|
||||
def _query_device_info_len(device):
|
||||
len_data = _xap_transaction(device, 0x01, 0x05)
|
||||
if not len_data:
|
||||
@ -146,6 +153,7 @@ def _list_devices():
|
||||
if cli.config.general.verbose:
|
||||
# TODO: better formatting like "lsusb -v"?
|
||||
data = _query_device_info(device)
|
||||
data["_id"] = _query_device_id(device)
|
||||
print_dotted_output(data)
|
||||
|
||||
|
||||
|
@ -150,8 +150,10 @@ def _append_route_types(lines, container, container_id=None, route_stack=None):
|
||||
|
||||
elif 'return_type' in container:
|
||||
return_type = container['return_type']
|
||||
if return_type == 'u8[32]':
|
||||
lines.append(f'typedef struct {{ uint8_t x[32]; }} {route_name}_t;')
|
||||
found = re.search(r'(u\d+)\[(\d+)\]', return_type)
|
||||
if found:
|
||||
return_type, size = found.groups()
|
||||
lines.append(f'typedef struct {{ {_get_c_type(return_type)} x[{size}]; }} {route_name}_t;')
|
||||
else:
|
||||
lines.append(f'typedef {_get_c_type(return_type)} {route_name}_t;')
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <quantum.h>
|
||||
#include <xap.h>
|
||||
|
||||
#include "hardware_id.h"
|
||||
#include "secure.h"
|
||||
#ifndef SECURE_ENABLE
|
||||
# define secure_get_status() SECURE_UNLOCKED
|
||||
@ -98,6 +99,11 @@ bool xap_respond_request_bootloader_jump(xap_token_t token, const void *data, si
|
||||
}
|
||||
#endif
|
||||
|
||||
bool xap_respond_get_hardware_id(xap_token_t token, const void *data, size_t length) {
|
||||
hardware_id_t ret = get_hardware_id();
|
||||
return xap_respond_data(token, &ret, sizeof(ret));
|
||||
}
|
||||
|
||||
#if ((defined(DYNAMIC_KEYMAP_ENABLE)))
|
||||
bool xap_respond_dynamic_keymap_get_keycode(xap_token_t token, const void *data, size_t length) {
|
||||
if (length != sizeof(xap_route_dynamic_keymap_get_keymap_keycode_arg_t)) {
|
||||
|
Loading…
Reference in New Issue
Block a user