ItzOmii / tbbt-a9-pppp-ha Public based on devbis/pppp_camera ItzOmii/tbbt-a9-pppp-ha
README.md·protocol notes, patch and reproduction walkthrough

TBBT / YsxLite A9 mini cameras: getting live video into Home Assistant

device TBBT-665567-AMFSR also sold as YsxLite A9 mini camera firmware mcuver 61.2.22.3 protocol PPPP over UDP/32108 video MJPEG 240×320 integration pppp_camera 1.1.2 library aiopppp 0.2.2 — patched status solved
NOTE — what this document is for

This is a solved reverse-engineering case, written so somebody with the same camera can hand the page to an AI agent and have it reproduce the fix. Every command, packet id and output below came from a real session. Where a step has an expected output, the output is quoted; where a wrong turn looks like the right answer, it is listed under Traps.

WARNING — "A9" is not one camera

The A9 mini camera name covers at least two unrelated stacks. This page is the PPPP variant: UDP/32108, binary command ids, a login that returns a session ticket. The other common variant runs in AP mode on 192.168.4.x with unencrypted two-byte commands to ports 8070/8080 — a completely different protocol, documented in DEEFRAG/A9. If your capture shows 19 xx-style two-byte commands and no DRW framing, you are on that one and nothing here will fit.

TL;DR

Cheap PPPP battery cameras login, answer status, switch their lamps and hand out a session ticket to a client using aiopppp — then never start video. Three things were wrong in the client, not the camera:

#DeltaWrongRight
1Framing bytesBinaryCmdPkt.START_CMD = b'\x11\x0a'b'\x01\x0a'
2Login payload encodingxq-encoded, the library default for every commandplain text, never encoded
3Login ACK decodingxq-decoded 4-byte ticketraw ff 00 00 00 + 4-byte ticket

With all three the camera ACKs 0x3010 LiveVideoStart with 0x3110 and streams JPEG frames. With any one missing it stays silent — and still ACKs 0x3018 VideoParamSet, which is what makes the failure confusing.

Affected devices and environment

CameraTBBT-665567-AMFSR and TBBT-681302-FNECR — two units, same firmware, same behaviour
Also known as"A9 mini camera" — the same hardware is rebadged under many names, and the vendor app is YsxLite (iOS and Android). Check the firmware variant before assuming this page applies: see the note below.
Firmwaremcuver 61.2.22.3, PPPP device id prefixed TBBT
Authadmin + an 8-character password generated at pairing. Not 6666.
TransportUDP/32108, PPPP "DRW" framing, P2P punch packets to wake the camera
VideoMJPEG — JPEG ff d8 … ff d9 chunks in DRW video packets, 240×320
Home Assistant2026.10.4 in Docker, network_mode: host, config at ~/homeassistant/config
Integrationdevbis/pppp_camera 1.1.2 (HACS custom repository); requires aiopppp==0.2.2 and ffmpeg
Reference hostmeepBox — an always-on i5 Linux box, no GPU, 10.0.0.111, Home Assistant UI on :8123
TopologyOne flat 10.0.0.0/24: cameras 10.0.0.238 and 10.0.0.25, iPhone running the vendor app 10.0.0.185, router 10.0.0.1. Phone and cameras are both Wi-Fi clients, bridged inside the router.

Symptoms

WARNING (MainThread) [custom_components.pppp_camera] Error getting video frame: Not connected to the camera

Root cause

The camera issues a session ticket to a login it never parsed. Everything that does not need media keeps working — status reads, lamp commands, PTZ — because those are answered without checking that the session is really authenticated. Media does check, so it is ignored silently.

1. Binary commands use start bytes 01 0A

The vendor app sends 01 0A where aiopppp sends 11 0A, and the camera mirrors whatever it receives, so the receive path must accept both or ACKs are dropped.

class BinaryCmdPkt(DrwPkt):
    START_CMD = b'\x01\x0a'                       # was b'\x11\x0a'

# packets.py, receive path
elif data[4:6] in (b'\x11\x0a', b'\x01\x0a'):  # accept both

2. The login payload is plain text

aiopppp xq-encodes every payload (each byte ±1 by parity, then rotate by 4). The camera does not decode the login, so encoded credentials arrive as noise — and it returns a ticket anyway, so every log line looks like a successful login.

if self.cmd_payload:
    if getattr(self.command, 'value', None) == 0x1020:   # CMD_SYSTEM_USER_CHK
        data += self.cmd_payload                          # plain text: no xq
    else:
        data += xq_bytes_encode(self.cmd_payload, 4)

3. The login ACK is not xq-encoded either

The ACK body is ff 00 00 00 followed by the 4-byte session ticket. Decoding it yields a garbage ticket, so every later command carries credentials the camera does not recognise.

# packets.py, receive path
if len(cmd_bin_payload) and command_num != 0x1120:       # ACK_SYSTEM_USER_CHK
    cmd_bin_payload = xq_bytes_decode(cmd_bin_payload, 4)

# session.py, login()
if len(auth_result) == 8 and auth_result[:4] == b'\xff\x00\x00\x00':
    self.ticket = auth_result[4:8]                       # success
elif auth_result != b'':
    raise AuthError(f'Login failed: [{auth_result.hex(" ")}]')

The patch

All six hunks live in one idempotent script. It matches exact source anchors, never applies a hunk twice, and exits non-zero if a future aiopppp release moves an anchor — so a build fails loudly instead of shipping a broken camera.

patch_aiopppp_tbbt.py — apply inside the Home Assistant image
#!/usr/bin/env python3
"""Patch aiopppp for TBBT/SmartCam PPPP battery cameras (firmware mcuver 61.2.22.3).

Applied inside the Home Assistant image so the fixes survive container rebuilds.

Discovered by packet-capturing the vendor iPhone app:
  * binary commands use start bytes 0x010A, not 0x110A
  * the login (CMD_SYSTEM_USER_CHK 0x1020) carries PLAIN 'admin'+password, not xq-encoded
  * the login ack is 'ff 00 00 00' + 4-byte session ticket, sent unencoded
  * without all of the above the camera acks VideoParamSet but silently ignores
    LiveVideoStart -> no video. With them, video streams as MJPEG.
"""
import sys

SP = "/usr/local/lib/python3.14/site-packages/aiopppp/session.py"
PP = "/usr/local/lib/python3.14/site-packages/aiopppp/packets.py"
MARK = "TBBT"

session_subs = [
    ("""            if drw_pkt.command == BinaryCommands.ACK_SYSTEM_USER_CHK and len(drw_pkt.cmd_payload) >= 20:
                # this is from cam-reverse code
                self.ticket = drw_pkt.cmd_payload[16:20]""",
     """            if drw_pkt.command == BinaryCommands.ACK_SYSTEM_USER_CHK:
                _p = drw_pkt.cmd_payload
                if len(_p) >= 20:
                    # this is from cam-reverse code
                    self.ticket = _p[16:20]
                elif len(_p) == 8 and _p[:4] == b'\\xff\\x00\\x00\\x00':
                    # TBBT firmware: marker + 4-byte session ticket
                    self.ticket = _p[4:8]"""),
    ("""        if auth_result != b'':
            raise AuthError(f'Login failed: [{auth_result.hex(" ")}]')
        return True""",
     """        if auth_result != b'':
            if len(auth_result) == 8 and auth_result[:4] == b'\\xff\\x00\\x00\\x00':
                # TBBT firmware: ff 00 00 00 + 4-byte ticket == success
                self.ticket = auth_result[4:8]
                logger.info('Login ok (TBBT variant), ticket=%s', self.ticket.hex())
            else:
                raise AuthError(f'Login failed: [{auth_result.hex(" ")}]')
        return True"""),
]

packet_subs = [
    ("""class BinaryCmdPkt(DrwPkt):
    START_CMD = b'\\x11\\x0a'""",
     """class BinaryCmdPkt(DrwPkt):
    START_CMD = b'\\x01\\x0a'  # TBBT"""),
    ("""        if self.cmd_payload:
            data += xq_bytes_encode(self.cmd_payload, 4)
        return data""",
     """        if self.cmd_payload:
            if getattr(self.command, 'value', None) == 0x1020:
                # TBBT: credentials are plain text, not xq-encoded
                data += self.cmd_payload
            else:
                data += xq_bytes_encode(self.cmd_payload, 4)
        return data"""),
    ("""    elif data[4:6] == b'\\x11\\x0a':""",
     """    elif data[4:6] in (b'\\x11\\x0a', b'\\x01\\x0a'):  # TBBT"""),
    ("""                if len(cmd_bin_payload):
                    cmd_bin_payload = xq_bytes_decode(cmd_bin_payload, 4)""",
     """                if len(cmd_bin_payload) and command_num != 0x1120:
                    # TBBT: login ack (0x1120) is not xq-encoded
                    cmd_bin_payload = xq_bytes_decode(cmd_bin_payload, 4)"""),
]


def apply(path, subs):
    src = open(path).read()
    changed = 0
    for old, new in subs:
        if new in src:
            continue  # already patched
        if old not in src:
            print(f"ANCHOR MISS in {path}:\n{old[:100]}")
            sys.exit(1)
        src = src.replace(old, new, 1)
        changed += 1
    if changed:
        open(path, "w").write(src)
    print(f"{path}: {changed} hunk(s) applied")


apply(SP, session_subs)
apply(PP, packet_subs)
print("aiopppp patched for TBBT cameras")

aiopppp is not part of the Home Assistant image — the custom integration pip-installs it at first start — so patching a running container is lost on the next image pull. Bake it in:

Dockerfile — builds homeassistant-tbbt:local
FROM homeassistant/home-assistant:stable

# TBBT PPPP battery cams (TBBT-665567-AMFSR / TBBT-681302-FNECR) need aiopppp patched:
# 010A start bytes, plain-text login, unencoded 'ff 00 00 00 <ticket>' login ack.
# Without it the camera acks VideoParamSet but never starts video (no MJPEG stream).
# aiopppp is normally installed at first start by the pppp_camera custom component,
# so install it here and patch it in the image instead.
RUN pip3 install --no-cache-dir aiopppp==0.2.2

COPY patch_aiopppp_tbbt.py /tmp/patch_aiopppp_tbbt.py
RUN python3 /tmp/patch_aiopppp_tbbt.py && rm /tmp/patch_aiopppp_tbbt.py
# docker-compose.yml
services:
  homeassistant:
    build: .
    image: homeassistant-tbbt:local
    container_name: homeassistant
    restart: unless-stopped
    network_mode: host

Verify

Check bytes, not entity state. streaming only means Home Assistant is willing to ask; a JPEG magic number means the camera answered.

docker exec homeassistant python3 /tmp/ha_save_snaps.py
# camera.tbbt_665567_amfsr: http=200 bytes=11488 jpeg=True
# camera.tbbt_681302_fnecr: http=200 bytes=10780 jpeg=True

$ file /tmp/ha_238.jpg
/tmp/ha_238.jpg: JPEG image data, baseline, precision 8, 240x320, components 3

Outside Home Assistant, this harness connects, starts video and writes the first frame. It is the shortest path from "patched" to "proven".

harness_frame_test.py — standalone; prints frame size and magic bytes
import asyncio, logging, sys, struct
sys.path.insert(0, '/tmp')
logging.basicConfig(level=logging.ERROR, stream=sys.stdout)
from aiopppp import Device
from aiopppp.encrypt import ENC_METHODS

IP = sys.argv[1]
PWD = sys.argv[2]
OUT = sys.argv[3] if len(sys.argv) > 3 else '/tmp/ha_frame.jpg'


def drw(idx, start, cmd, dest, token, payload=b''):
    body = (b'\xd1\x00' + struct.pack('>H', idx) + start
            + struct.pack('<H', cmd) + struct.pack('<H', len(payload) + len(token))
            + struct.pack('<H', dest) + token + payload)
    return b'\xf1\xd0' + struct.pack('>H', len(body)) + body


async def main():
    dev = Device(IP, "admin", PWD)
    await dev.connect(timeout=30)
    sess = dev.session
    enc = ENC_METHODS[sess.dev.encryption][1]

    def send_raw(cmd, dest, payload=b''):
        idx = sess.outgoing_command_idx
        sess.outgoing_command_idx += 1
        sess.transport.sendto(enc(drw(idx, b'\x01\x0a', cmd, dest, sess.ticket, payload)),
                              (sess.dev.addr, sess.dev.port))

    send_raw(0x1008, 0x00ff)
    await asyncio.sleep(0.3)
    for _ in range(6):
        send_raw(0x3018, 0x00ff, bytes.fromhex("0100000000000000"))
        send_raw(0x3010, 0x0000)
        send_raw(0x3018, 0x00ff, bytes.fromhex("0700000020000000"))
    print("ticket:", sess.ticket.hex())

    got = None
    for attempt in range(12):
        try:
            fr = await asyncio.wait_for(dev.get_video_frame(), timeout=8)
        except Exception as e:
            print("frame attempt", attempt, "->", type(e).__name__)
            continue
        data = fr.data if hasattr(fr, 'data') else bytes(fr)
        print("frame:", len(data), "bytes, magic:", data[:4].hex(' '))
        if data[:2] == b'\xff\xd8':
            got = data
            break
        if b'\xff\xd8' in data:
            got = data[data.index(b'\xff\xd8'):]
            break
    if got:
        open(OUT, 'wb').write(got)
        print("saved", OUT, len(got))
    else:
        print("NO JPEG FRAME")
    try:
        await dev.close()
    except Exception:
        pass


asyncio.run(main())

Reproduction walkthrough

For another owner of this camera, or an agent working on their behalf. Each step states what success looks like; if you do not get it, the note says where to look instead.

  1. Recover the camera's real password

    Pairing generates an 8-character password and the app holds it. If the app cannot show it, read it from a login capture: the 0x1020 payload is 160 bytes, ASCII username at offset 0, ASCII password at offset 32. Do not settle for 6666 — see Traps.

  2. Install Home Assistant and the integration

    HACS custom repository devbis/pppp_camera, then add the camera through the config flow using admin plus the real password. Pass: the entry loads and the lamp switches operate. That proves the session reaches the camera; everything after is purely about media.

  3. Put a capture point in the network path

    Any wired Linux host on the same subnet. Allow forwarding for the phone↔camera pair first — the step everyone skips — then ARP-poison the camera side and capture. Poisoning only the camera is enough to see the camera's replies; poison the phone as well only if you need the app's own commands.

    iptables -I FORWARD 1 -s 10.0.0.185 -d 10.0.0.238 -j ACCEPT
    iptables -I FORWARD 1 -s 10.0.0.238 -d 10.0.0.185 -j ACCEPT
    python3 arp_poison.py 900 10.0.0.238 CAM_MAC 10.0.0.1 10.0.0.238 CAM_MAC 10.0.0.185
    tcpdump -i eth0 -n -s0 -w /tmp/cam.pcap "host 10.0.0.238"
  4. Stream from the vendor app and read the capture

    Look for 0x1020 login, the video burst (0x3018 and 0x3010 within a few milliseconds), and the camera's 0x3110 reply. Fail: 0x3118 present and 0x3110 absent means you have this exact bug. Diff the app's start bytes against your client's — that difference is delta 1.

  5. Patch, do not rewrite

    Apply the three deltas to aiopppp, inside the image. Reimplementing the protocol from scratch is a longer road to the same three findings.

  6. Prove it with JPEG magic bytes

    Run the harness, or fetch /api/camera_proxy/camera.your_entity and check the body begins ff d8. A dark 240×320 frame of a back yard is success.

Traps that look like answers

WARNING

Every item below produced a confident wrong answer during this session. They are listed in the order they cost time.

Appendix: the app's command sequence

0x1020  login        token 00000000, payload 32s "admin" + 128s password  (PLAIN TEXT)
0x1008  status get   token = session ticket
0x3018  vparam       01 00 00 00 00 00 00 00    type 1 (resolution) = 0
0x3010  live start   no payload, dest 0x0000
0x3018  vparam       07 00 00 00 20 00 00 00    type 7 = 32
0x3019  vparam get
0x50ff  passthrough  JSON strings (PTZ)
0x3011  live stop

ACKs come back as the request's command id plus 0x100: 0x3018→0x3118, 0x3010→0x3110 (264-byte payload), 0x1008→0x1108. Video arrives as DRW video packets from UDP/32108 to the client's source port, JPEG chunks of roughly 1 KB. The whole video group is sent as one burst; spacing it over hundreds of milliseconds is enough to be ignored.

References

Credits and provenance

Built on devbis/pppp_camera and aiopppp; the login and ticket handling follows the cam-reverse lineage of PPPP work. Captures, patch and reproduction were done on meepBox (10.0.0.111) against two TBBT cameras on one flat home LAN. The packet captures remain on that host in case a firmware update breaks this again.