Skip to main content

Posts

Showing posts with the label IoT

Troubleshooting Bluetooth LE (BLE) Background Scanning Drops on MIUI

  Building reliable Bluetooth Low Energy IoT ecosystems requires maintaining persistent connections between peripheral hardware and mobile devices. However, developers frequently encounter a hard wall when deploying to devices running Xiaomi's MIUI. A perfectly engineered Foreground Service handling Android BLE scanning will inexplicably drop after 10 to 15 minutes of screen-off time. This aggressive background termination disrupts continuous data synchronization. In sectors like HealthTech app development, where continuous glucose monitors or wearable heart rate trackers require uninterrupted data flow, these drops represent critical system failures. To maintain reliable Android background Bluetooth functionality, we must bypass standard App Standby mechanisms and adapt to MIUI's proprietary resource management. Understanding the Root Cause: MIUI's PowerKeeper vs. Standard BLE Android's native power management relies on Doze mode and App Standby buckets. Standard docum...

Xiaomi IoT Local Control: Extracting Tokens for Home Assistant

  Cloud latency is the silent killer of home automation. You press a wireless switch, and three seconds later, the light turns on. In the world of IoT engineering, a three-second delay is an eternity. For developers using Xiaomi (Mijia/Roborock) devices, the hardware is excellent, but the ecosystem forces a dependency on Chinese or European cloud servers. To achieve sub-100ms response times in Home Assistant, you need  local control . Local control via the  python-miio  library or Home Assistant's native Xiaomi integration requires a 32-character hexadecimal API token. Xiaomi deliberately hides this token within the Mi Home app's encrypted database. This guide details how to programmatically extract these tokens using Python, bypassing the need for rooted Android devices or compromised APKs. The Architecture of the Lockout Before extracting the key, it is vital to understand the lock. Xiaomi's IoT protocol (miIO) relies on a proprietary implementation of UDP communic...