mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 12:51:47 +00:00
Stub out python client gen
This commit is contained in:
parent
70eae6b348
commit
2a1bfafa1a
25
data/templates/xap/client/python/types.py.j2
Normal file
25
data/templates/xap/client/python/types.py.j2
Normal file
@ -0,0 +1,25 @@
|
||||
from enum import IntFlag, IntEnum
|
||||
|
||||
|
||||
class XAPRouteError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class XAPSecureStatus(IntEnum):
|
||||
LOCKED = 0x00
|
||||
UNLOCKING = 0x01
|
||||
UNLOCKED = 0x02
|
||||
|
||||
|
||||
class XAPEventType(IntEnum):
|
||||
{%- for id, message in xap.broadcast_messages.messages | dictsort %}
|
||||
{{ message.define }} = {{ id }}
|
||||
{%- endfor %}
|
||||
|
||||
|
||||
class XAPFlags(IntFlag):
|
||||
{%- for bitnum, bitinfo in xap.response_flags.bits | dictsort %}
|
||||
{%- if bitinfo.define != "-" %}
|
||||
{{ bitinfo.define }} = 1 << {{ bitnum }}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
@ -80,6 +80,7 @@ subcommands = [
|
||||
'qmk.cli.xap',
|
||||
'qmk.cli.xap.generate_docs',
|
||||
'qmk.cli.xap.generate_json',
|
||||
'qmk.cli.xap.generate_python',
|
||||
'qmk.cli.xap.generate_qmk',
|
||||
]
|
||||
|
||||
|
22
lib/python/qmk/cli/xap/generate_python.py
Normal file
22
lib/python/qmk/cli/xap/generate_python.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""This script generates the python XAP client.
|
||||
"""
|
||||
from qmk.constants import QMK_FIRMWARE, GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE
|
||||
|
||||
from qmk.xap.common import latest_xap_defs, render_xap_output
|
||||
from qmk.commands import dump_lines
|
||||
|
||||
from milc import cli
|
||||
|
||||
|
||||
@cli.subcommand('Generates the python XAP client.', hidden=False if cli.config.user.developer else True)
|
||||
def xap_generate_python(cli):
|
||||
defs = latest_xap_defs()
|
||||
|
||||
parent = QMK_FIRMWARE / 'lib' / 'python' / 'xap_client'
|
||||
for name in ['types.py']:
|
||||
lines = [GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE]
|
||||
|
||||
output = render_xap_output('client/python', f'{name}.j2', defs)
|
||||
lines += output.split('\n')
|
||||
|
||||
dump_lines(parent / name, lines)
|
@ -102,7 +102,7 @@ class XAPShell(cmd.Cmd):
|
||||
while 1:
|
||||
(event, data) = self.device.listen()
|
||||
|
||||
if event == XAPEventType.SECURE:
|
||||
if event == XAPEventType.SECURE_STATUS:
|
||||
secure_status = XAPSecureStatus(data[0]).name
|
||||
|
||||
cli.log.info(' Secure[%s]', secure_status)
|
||||
|
@ -12,7 +12,6 @@ from platform import platform
|
||||
|
||||
from .types import XAPSecureStatus, XAPFlags, XAPRouteError
|
||||
|
||||
|
||||
RequestPacket = namedtuple('RequestPacket', 'token length data')
|
||||
RequestStruct = Struct('<HB61s')
|
||||
|
||||
|
@ -1,23 +1,51 @@
|
||||
# Copyright 2022 QMK
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# 88888888888 888 d8b .d888 d8b 888 d8b
|
||||
# 888 888 Y8P d88P" Y8P 888 Y8P
|
||||
# 888 888 888 888
|
||||
# 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
|
||||
# 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
|
||||
# 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
|
||||
# 888 888 888 888 X88 888 888 888 Y8b. 888 X88
|
||||
# 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
|
||||
#
|
||||
# 888 888
|
||||
# 888 888
|
||||
# 888 888
|
||||
# .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
|
||||
# d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
|
||||
# 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
|
||||
# Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
|
||||
# "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
|
||||
# 888
|
||||
# Y8b d88P
|
||||
# "Y88P"
|
||||
#
|
||||
################################################################################
|
||||
|
||||
from enum import IntFlag, IntEnum
|
||||
|
||||
|
||||
class XAPRouteError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class XAPSecureStatus(IntEnum):
|
||||
LOCKED = 0x00
|
||||
UNLOCKING = 0x01
|
||||
UNLOCKED = 0x02
|
||||
|
||||
|
||||
class XAPFlags(IntFlag):
|
||||
FAILURE = 0
|
||||
SUCCESS = 1 << 0
|
||||
SECURE_FAILURE = 1 << 1
|
||||
|
||||
|
||||
class XAPEventType(IntEnum):
|
||||
SECURE = 0x01
|
||||
KEYBOARD = 0x02
|
||||
LOG_MESSAGE = 0x00
|
||||
SECURE_STATUS = 0x01
|
||||
KB = 0x02
|
||||
USER = 0x03
|
||||
|
||||
|
||||
class XAPRouteError(Exception):
|
||||
pass
|
||||
class XAPFlags(IntFlag):
|
||||
SUCCESS = 1 << 0
|
||||
SECURE_FAILURE = 1 << 1
|
||||
|
Loading…
Reference in New Issue
Block a user