
Samsung TV Remote – Wi-Fi & IR
Reverse-engineering Samsung's TV control protocols to build a dual-mode remote that works over both IR hardware and Wi-Fi networks.
1. The Problem
TV remotes get lost, break, or run out of batteries. Samsung's official SmartThings app works for Wi-Fi control but is bloated (100MB+), requires account login, and doesn't support IR. Third-party remotes on the Play Store are ad-heavy and often don't work. Users wanted something simple: open the app, tap a button, and the TV responds.
2. The Solution
A lightweight remote app with two control modes: IR blaster for older Samsung TVs (no Wi-Fi needed) and Wi-Fi control for smart TVs. The app auto-detects which mode to use based on the phone's hardware capabilities and available TVs on the network. The UI mimics a real remote layout — power, volume, channels, directional pad, number pad — so there's zero learning curve.
3. Technical Deep Dive: IR Blaster API
Android's ConsumerIrManager API sends raw IR signals at specific frequencies. Samsung TVs use the NEC protocol at 38kHz. The challenge was finding the correct IR codes for every Samsung remote function — there's no official database. I built a custom IR code database by decoding signals from a real Samsung remote using timing patterns, then encoding them into the format Android's API expects (alternating mark/space microsecond arrays).
4. Technical Deep Dive: Wi-Fi Control
Samsung smart TVs expose a WebSocket server on port 8001/8002. The connection flow: (1) Discover TVs on the local network using UPnP/SSDP multicast, (2) Connect via WebSocket with a handshake that includes app name and device token, (3) Send key commands as JSON payloads. The tricky part was handling Samsung's pairing flow — the TV shows a popup asking the user to allow the connection, and the app needs to wait for approval before sending commands.
5. Architecture
Clean separation between control modes: an abstract RemoteController interface with IRRemoteController and WiFiRemoteController implementations. The UI layer doesn't care whether a button press goes through IR or WebSocket — it just calls remoteController.sendKey(KEY_VOLUME_UP). Network discovery runs on a background coroutine with a timeout, and the connection state is managed with StateFlow for reactive UI updates.
6. What I Learned
This project pushed me into hardware-software interaction territory. Understanding IR protocols, signal timing, and radio frequencies was completely new. On the networking side, implementing UPnP discovery and WebSocket communication taught me about multicast, device pairing handshakes, and handling unreliable network connections gracefully (TVs drop WebSocket connections frequently).