Files
glass/glass-mouse/scripts/_derive.py
T
admin 2840e82685 Initial commit: Android GlassMouse + iOS GlassRemote 智能眼镜遥控项目
包含本次会话修复:
- iOS clickReady 警告 bug(默认 false 永远显示)
- BLE 'handle is invalid' 排查(stale handle auto-retry 实验 + 回退)

项目结构:
- glass-mouse/: 眼镜端原生 Kotlin App,前台服务 MouseService + 自定义 BLE GATT 桥接 ProxyBleServer + 无障碍 GestureDescription 注入
- ios/GlassRemote/: iPhone 端 SwiftUI + CoreBluetooth,通过 BLE 直连眼镜
- HTTP 投屏服务(:8000) 接 PPT/WPS 备注宏 POST 推送

技术栈: Android Kotlin (gradle 8.14.4, compileSdk 34), iOS Swift 5.10 (Xcode 26.5)
2026-08-26 10:34:23 +08:00

54 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# 用一条已知合法的 aa55 帧反推帧格式(校验和算法)。不需要 BLE。
frame_hex = "aa55001700010000030100071011a201024200e154"
b = bytes.fromhex(frame_hex)
print("total bytes:", len(b), b.hex())
def chk_sum(data): return sum(data) & 0xff
def chk_comp(data): return (0x100 - sum(data)) & 0xff
def chk_xor(data):
r = 0
for x in data: r ^= x
return r
def chk_crc8(data):
crc = 0
for x in data:
crc ^= x
for _ in range(8):
crc = ((crc << 1) ^ 0x07) & 0xff if (crc & 0x80) else (crc << 1) & 0xff
return crc
algos = {"sum": chk_sum, "comp": chk_comp, "xor": chk_xor, "crc8": chk_crc8}
header = 2 # aa55
for lf in [0, 1, 2]:
payload_start = header + lf
if payload_start >= len(b):
continue
for s in range(payload_start + 1, len(b)):
payload = b[payload_start:s]
chkbytes = b[s:]
for an, algo in algos.items():
for scope in ["hp", "p"]:
data = (b[:payload_start] + payload) if scope == "hp" else payload
c = algo(data)
if len(chkbytes) == 1 and c == chkbytes[0]:
print(f"[1B] lf={lf} split={s} algo={an} scope={scope} -> MATCH chk={c:02x}")
if len(chkbytes) == 2:
if c == int.from_bytes(chkbytes, "big"):
print(f"[2B] lf={lf} split={s} algo={an} scope={scope} BE -> MATCH")
if c == int.from_bytes(chkbytes, "little"):
print(f"[2B] lf={lf} split={s} algo={an} scope={scope} LE -> MATCH")
# 额外:列出各 split 下的候选 (type/len 字节 + payload + chk)
print("\n--- 候选分段 ---")
for lf in [0, 1, 2]:
ps = header + lf
if ps >= len(b): continue
if lf == 1:
print(f"lf=1: type/len byte = {b[header]:02x}")
if lf == 2:
print(f"lf=2: len bytes BE={b[header]:02x}{b[header+1]:02x}={int.from_bytes(b[header:header+2],'big')} "
f"LE={int.from_bytes(b[header:header+2],'little')}")