Files
glass/glass-mouse/scripts/_crack.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

66 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
# 离线破译 INMO 0x2021 帧结构(用真机读到的那一条合法帧,不需 BLE)
import binascii
# 真机枚举时 0x2021 的 read 返回值(一条已知合法的完整帧)
F = bytes.fromhex("aa55001700010000030100071011a201024200e154")
print("帧总长:", len(F), F.hex())
def reflect(x, n):
r = 0
for i in range(n):
if x & (1 << i):
r |= 1 << (n - 1 - i)
return r
def crc8(data, poly, init=0, refin=False, refout=False, xorout=0):
crc = init
for b in data:
if refin:
b = reflect(b, 8)
crc ^= b
for _ in range(8):
crc = ((crc << 1) ^ poly) & 0xff if (crc & 0x80) else (crc << 1) & 0xff
if refout:
crc = reflect(crc, 8)
return crc ^ xorout
def crc16(data, poly, init=0, refin=False, refout=False, xorout=0):
crc = init
for b in data:
if refin:
b = reflect(b, 8)
crc ^= b << 8
for _ in range(8):
crc = ((crc << 1) ^ poly) & 0xffff if (crc & 0x8000) else (crc << 1) & 0xffff
if refout:
crc = reflect(crc, 16)
return crc ^ xorout
# ---- 假设 A:aa55 头 + DATA + 1字节校验(=末字节) ----
dataA = F[2:-1]
chkA = F[-1]
s = sum(dataA) & 0xff
print("\n[假设A] header=aa55, DATA=F[2:-1](%d字节), 校验=F[-1]=%#x" % (len(dataA), chkA))
print(" sum%%256 =%#x xor=%#x (256-sum)=%#x" % (s, 0, (256 - s) & 0xff))
for poly in [0x07, 0x9B, 0x1D, 0x2F, 0xA7, 0x8C, 0x3D, 0xD5]:
print(" crc8 poly=%#04x -> %#04x" % (poly, crc8(dataA, poly)))
for poly in [0x1021, 0x8005, 0x8408, 0xA02B, 0xC867]:
print(" crc16 poly=%#06x -> %#06x" % (poly, crc16(dataA, poly)))
# ---- 假设 B:aa55 头 + 2字节长度? 试 len=F[2:4]=0017 ----
print("\n[结构观察] F[2:4] =", F[2:4].hex(), "= 0x%04x = %d" % (int.from_bytes(F[2:4], "big"), int.from_bytes(F[2:4], "big")))
print(" F[4:] 长度 =", len(F[4:]), "(若 0017 是长度,应=%d)" % int.from_bytes(F[2:4], "big"))
print(" F[2:] 长度 =", len(F[2:]), "(若 0017 含在总长里)")
# ---- 假设 C:2字节校验(末2字节) ----
dataC = F[2:-2]
chkC = F[-2:]
print("\n[假设C] DATA=F[2:-2](%d字节), 校验=F[-2:]=%s" % (len(dataC), chkC.hex()))
print(" sum%%256 =%#x (256-sum)=%#x" % (sum(dataC) & 0xff, (256 - sum(dataC)) & 0xff))
print(" crc16(0x1021) =%#06x crc16(0x8005)=%#06x" % (crc16(dataC, 0x1021), crc16(dataC, 0x8005)))