open-merou

Open Mérou, a free iOS app for the Oceanic+ underwater iPhone housing
git clone https://git.schurger.org/open-merou.git
Log | Files | Refs | README | LICENSE

commit bb33c35665e9322b1a06ebdd7ebc55b3b2291e7a
Author: Jean Schurger <jean@schurger.org>
Date:   Fri, 13 Nov 2026 13:23:59 -0500

Housing BLE protocol: capture of 2026-11-13, pklg decoder, UUIDs confirmed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYGSNhtY1AmBH7DQGNs

Diffstat:
A.gitignore | 1+
Adocs/PROTOCOLE.md | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/pklg.py | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 233 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +captures/ diff --git a/docs/PROTOCOLE.md b/docs/PROTOCOLE.md @@ -0,0 +1,74 @@ +# Protocole BLE du boîtier Oceanic+ (rétro-ingénierie) + +Source : capture HCI iOS (sysdiagnose) du 2026-11-13, app officielle en version gratuite, +iPhone iOS 24B119. Décodage : `tools/pklg.py`. Les heures du journal sont décalées de -5 h +par rapport à l'heure locale (07:55 dans le journal = 12:55 à l'horloge). + +Rien n'est chiffré au niveau applicatif : valeurs brutes, petit-boutistes. + +## Identité (nRF Connect, 2026-11-13) + +- Nom annoncé : `HUISH`, connectable. Puce Nordic (nRF5 SDK), DFU disponible. +- Données fabricant : Nordic (0x0059) `D0B4 AF9F 7FAA`. +- Services standards : 1800, 1801, Battery 180F (2A19 = handle 0x0016), Device Information 180A + (2A29 fabricant, 2A24 modèle, 2A25 n° de série, 2A27 révision matérielle…). +- **Nordic LED Button Service** (exemple « Blinky » du SDK) `00001523-1212-EFDE-1523-785FEABCD123` : + - `00001524-…` Button State (read, notify) = handle 0x0010, codes des boutons ci-dessous ; + - `00001525-…` LED State (read, write) : rôle inconnu, non utilisé dans la capture. +- Service propre `00001623-1212-EFDE-1523-785FEABCD123` (caractéristiques 1624 à 1629, voir tableau). +- Secure DFU `FE59`, caractéristique Buttonless DFU Without Bonds `8EC90003-F315-4F60-9F…`. + **Ne jamais y écrire** : le boîtier passerait en mode mise à jour. + +Base commune des UUID : `0000XXXX-1212-EFDE-1523-785FEABCD123`. + +## Caractéristiques observées (par handle ATT ; UUID à confirmer) + +| Handle | UUID (XXXX) | Propriétés | Format | Rôle | +|---|---|---|---|---| +| 0x0010 | 1524 (service 1523) | read, notify | 1 octet | **Bouton** : quartet haut = bouton, quartet bas = 0 court / 1 long | +| 0x0013 | 1525 (service 1523) | read, write | ? | « LED » de l'exemple Nordic, non utilisée par l'app | +| 0x0016 | 2A19 (180F) | read, notify | 1 octet | **Batterie** (%) : 92→88 pendant le pompage | +| 0x0027 | 1624 (service 1623) | read, write | 1 octet | **Pompe** : `01` = marche, `00` = arrêt | +| 0x0029 | 1625 | read, notify (~3 Hz) | uint32 | Hypothèse : **pression extérieure** (profondimètre) en daPa : 9940 = 99,4 kPa à l'air | +| 0x002C | 1626 | read, notify (~3 Hz) | int32 | **Température** interne, centièmes de °C (2100 = 21,00 °C) | +| 0x002F | 1627 | read, notify (~3 Hz) | uint32 | **Pression** interne absolue, Pa (100 960 = 1009,6 hPa) | +| 0x0032 | 1628 | read, notify | ? | Inconnu, jamais notifié dans la capture (alarme d'eau ?) | +| 0x0035 | 1629 | read, notify | 1 octet | **État de la pompe** : `01` = en marche, `02` = arrêtée | + +Correspondance handles ↔ UUID **confirmée** par le journal de découverte nRF Connect (13:18) : +1523 (2 caractéristiques), 180F, 180A à 6 caractéristiques (2A29, 2A24, 2A25, 2A27, 2A26, 2A28), +1623 = 0x0025 (1624 sans descripteur, 1625–1629 avec CCCD, 3 handles chacun), FE59. Chaque handle +observé tombe exactement sur la valeur de la caractéristique attendue. + +### Boutons (0x0010) + +| Valeur | Bouton | +|---|---| +| 0x10 | gauche | +| 0x20 | obturateur (déclencheur) | +| 0x30 | droite | +| 0x40 | haut | +| 0x50 | bas | +| 0x_1 | appui long (2 s), ex. 0x31 = droite long | + +Le boîtier ne fait qu'annoncer les appuis : tout le comportement (photo, menus, pompe) est dans l'app. + +## Cycle de vide observé + +1. 12:55:02 appui droite (0x30) → l'app écrit `01` dans 0x0027 → 0x0035 = `01`. +2. Pression : 100,96 kPa → 79,57 kPa en 10 s (≈ 2 kPa/s) ; 0x0016 : 92 → 88. +3. 12:55:12 l'app écrit `00` dans 0x0027 (P = 79 574 Pa, premier échantillon < 80 000 Pa, + ou délai de 10 s : à départager) → 0x0035 = `02`. +4. Test d'étanchéité de 3 min fait **par l'app** sur la pression : 79,57 → 80,01 kPa en 4 min, + pendant que la température monte de 21,2 à 22,2 °C (la loi des gaz explique ~+280 Pa sur +434). +5. Ouverture (côté app, guidée) : appui long droite (0x31) = lancer la séquence d'ouverture, + puis appuis droite (0x30) = confirmations d'étapes (ouvrir le bouchon, purge, fermer le bouchon). + 12:59:40 retour à 99,3 kPa quand le bouchon est ouvert : mise à l'air mécanique, aucune écriture BLE. +6. Appui long droite hors séquence = extinction du boîtier. + +## À faire + +- Lire 1628 (rôle inconnu) et les chaînes Device Information. +- 1625 = pression extérieure ? (valeur sous l'eau, ou en appuyant sur le capteur). +- Seuil d'arrêt de la pompe (pression ou délai) : deuxième capture. +- Ce qui se passe à l'extinction (appui long droite). diff --git a/tools/pklg.py b/tools/pklg.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python3 +"""Décodeur minimal de journaux Apple PacketLogger (.pklg) : HCI, LE, L2CAP, ATT. + +Usage : pklg.py fichier.pklg [--handle 0x0040] [--att] [--notes] [--conn] +""" +import argparse +import datetime as dt +import struct +import sys + +TYPES = {0x00: "CMD", 0x01: "EVT", 0x02: "ACL>", 0x03: "ACL<", 0x08: "SCO>", 0x09: "SCO<"} + +ATT_OPS = { + 0x01: "ERR", 0x02: "MTU_REQ", 0x03: "MTU_RSP", 0x04: "FIND_INFO_REQ", 0x05: "FIND_INFO_RSP", + 0x06: "FIND_BY_TYPE_REQ", 0x07: "FIND_BY_TYPE_RSP", 0x08: "READ_BY_TYPE_REQ", 0x09: "READ_BY_TYPE_RSP", + 0x0A: "READ_REQ", 0x0B: "READ_RSP", 0x0C: "READ_BLOB_REQ", 0x0D: "READ_BLOB_RSP", + 0x10: "READ_BY_GROUP_REQ", 0x11: "READ_BY_GROUP_RSP", 0x12: "WRITE_REQ", 0x13: "WRITE_RSP", + 0x1B: "NOTIFY", 0x1D: "INDICATE", 0x1E: "CONFIRM", 0x52: "WRITE_CMD", 0xD2: "SIGNED_WRITE", +} + + +def records(path): + data = open(path, "rb").read() + # Détecter l'ordre des octets : la longueur du premier enregistrement doit être plausible. + be = struct.unpack(">I", data[:4])[0] + le = struct.unpack("<I", data[:4])[0] + endian = ">" if 9 <= be < 0x10000 else "<" + if not (9 <= (be if endian == ">" else le) < 0x10000): + sys.exit("format pklg non reconnu") + off = 0 + while off + 13 <= len(data): + (length,) = struct.unpack(endian + "I", data[off:off + 4]) + if endian == ">": + secs, usecs = struct.unpack(">II", data[off + 4:off + 12]) + else: + usecs, secs = struct.unpack("<II", data[off + 4:off + 12]) + typ = data[off + 12] + payload = data[off + 13:off + 4 + length] + off += 4 + length + yield secs + usecs / 1e6, typ, payload + + +def ts(t): + return dt.datetime.fromtimestamp(t).strftime("%H:%M:%S.%f")[:-3] + + +def uuid_str(b): + if len(b) == 2: + return "%04X" % struct.unpack("<H", b)[0] + h = b[::-1].hex().upper() + return f"{h[:8]}-{h[8:12]}-{h[12:16]}-{h[16:20]}-{h[20:]}" + + +def att_decode(p): + op = p[0] + name = ATT_OPS.get(op, "OP_%02X" % op) + rest = p[1:] + if op in (0x12, 0x52, 0x1B, 0x1D, 0x0A) and len(rest) >= 2: + (h,) = struct.unpack("<H", rest[:2]) + return f"{name} h=0x{h:04X} {rest[2:].hex(' ')}" + if op == 0x01 and len(rest) >= 4: + req, h, code = struct.unpack("<BHB", rest[:4]) + return f"ERR req={ATT_OPS.get(req, req)} h=0x{h:04X} code=0x{code:02X}" + if op == 0x09 and rest: + n = rest[0] + items = [] + for i in range(1, len(rest) - n + 1, n): + e = rest[i:i + n] + h = struct.unpack("<H", e[:2])[0] + v = e[2:] + if len(v) in (5, 19): # déclaration de caractéristique + props, vh = v[0], struct.unpack("<H", v[1:3])[0] + items.append(f"[decl 0x{h:04X} props=0x{props:02X} val=0x{vh:04X} uuid={uuid_str(v[3:])}]") + else: + items.append(f"[0x{h:04X} {v.hex(' ')}]") + return f"{name} " + " ".join(items) + if op == 0x11 and rest: + n = rest[0] + items = [] + for i in range(1, len(rest) - n + 1, n): + e = rest[i:i + n] + s, en = struct.unpack("<HH", e[:4]) + items.append(f"[svc 0x{s:04X}-0x{en:04X} {uuid_str(e[4:])}]") + return f"{name} " + " ".join(items) + if op == 0x05 and rest: + fmt = rest[0] + n = 4 if fmt == 1 else 18 + items = [] + for i in range(1, len(rest) - n + 1, n): + e = rest[i:i + n] + items.append(f"[0x{struct.unpack('<H', e[:2])[0]:04X} {uuid_str(e[2:])}]") + return f"{name} " + " ".join(items) + return f"{name} {rest.hex(' ')}" + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("file") + ap.add_argument("--handle", type=lambda x: int(x, 0), help="ne garder qu'une connexion HCI") + ap.add_argument("--att", action="store_true", help="afficher l'ATT") + ap.add_argument("--notes", action="store_true", help="afficher les notes texte de bluetoothd") + ap.add_argument("--conn", action="store_true", help="connexions LE et noms annoncés") + ap.add_argument("--grep", help="filtrer les notes") + a = ap.parse_args() + + frag = {} + for t, typ, p in records(a.file): + if typ in (0x02, 0x03) and a.att and len(p) >= 4: + hf, ln = struct.unpack("<HH", p[:4]) + handle, pb = hf & 0x0FFF, (hf >> 12) & 0x3 + if a.handle is not None and handle != a.handle: + continue + body = p[4:4 + ln] + if pb in (0, 2): # début + frag[(handle, typ)] = body + else: + frag[(handle, typ)] = frag.get((handle, typ), b"") + body + buf = frag[(handle, typ)] + if len(buf) < 4: + continue + l2len, cid = struct.unpack("<HH", buf[:4]) + if len(buf) < 4 + l2len: + continue + frag.pop((handle, typ)) + if cid == 4: + d = "→" if typ == 0x02 else "←" + print(f"{ts(t)} {d} 0x{handle:03X} {att_decode(buf[4:4 + l2len])}") + elif cid == 6: + print(f"{ts(t)} {'→' if typ == 0x02 else '←'} 0x{handle:03X} SMP {buf[4:4 + l2len].hex(' ')}") + elif typ == 0x01 and a.conn and len(p) >= 3 and p[0] == 0x3E: + sub = p[2] + if sub in (0x01, 0x0A): + status, h = p[3], struct.unpack("<H", p[4:6])[0] + addr = p[8:14][::-1].hex(":") + print(f"{ts(t)} LE_CONN status={status} handle=0x{h:03X} peer={addr} type={p[7]}") + elif sub in (0x02, 0x0D): + # rapports d'annonce : chercher les noms (AD type 0x08/0x09) + raw = p[3:] + i = 0 + while i < len(raw) - 1: + if raw[i] in (0x08, 0x09) and 0 < raw[i - 1] < 32 if i else False: + pass + i += 1 + elif typ == 0x01 and a.conn and len(p) >= 2 and p[0] == 0x05: + status, h, reason = p[2], struct.unpack("<H", p[3:5])[0], p[5] + print(f"{ts(t)} DISCONNECT handle=0x{h:03X} reason=0x{reason:02X}") + elif typ not in TYPES and a.notes: + try: + s = p.decode("utf-8", "replace").strip("\x00").strip() + except Exception: + continue + if a.grep and a.grep.lower() not in s.lower(): + continue + print(f"{ts(t)} [{typ:02X}] {s}") + + +if __name__ == "__main__": + main()