VISCORE
← All works

Robotics & EmbeddedMar – May 2026Paused

OpenHomeGuard, a HarmonyOS Smart Home

A HarmonyOS smart-home entry for the Software Cup: a phone app controls lights, door access and air conditioning on an ESP32 over an encrypted channel.

App side and secure-communication designTeam project

  • ArkTS
  • ArkUI
  • DevEco Studio
  • WebSocket
  • MQTT 3.1.1
  • EMQX
  • TLS
  • ECDH
  • SM4 / SM3
  • HUKS
  • ESP32
3D-printed house model with sensors; OLED status at top left
6Core app pages completedDoor access, lighting, air conditioning, environment, devices, logs

Background

Software Cup problem A9. The problem centres on communication security: commands must not be readable or alterable in transit, and keys must not sit in the app in plain text. On top of that, OpenHarmony has no convenient MQTT library.

What the system does

HarmonyOS app⇄EMQX broker⇄ESP32 device

Both legs run over TLS.

  • Six feature pages: door access, lighting, air conditioning, environment, devices and logs
  • Commands travel under two layers of encryption
  • The ESP32 drives LEDs, a servo and an infrared air conditioner, and reads motion, temperature and humidity

My work

  • App interface: built the 6 core pages and their interactions in ArkTS / ArkUI.
  • MQTT client: implemented a lightweight MQTT 3.1.1 client (CONNECT / PUBLISH / SUBSCRIBE) on the native OpenHarmony WebSocket, with EMQX deployed in Docker as the broker.
  • Security scheme: TLS 1.3 protects the link. At the command layer, ECDH (P-256) agrees a session key and HKDF-SM3 derives separate encryption and MAC keys; commands are encrypted with SM4-CBC and protected against tampering with HMAC-SM3, encrypt-then-MAC, with the MAC also covering the nonce to block replays. On the app side, keys are held by HUKS and never appear in the code in plain text.

Problems and fixes

No ready-made MQTT library. Rather than bring in a third-party library, I implemented the connect, publish and subscribe packets myself on the native WebSocket, following the MQTT 3.1.1 specification.

Results

  • App pages, interactions and the MQTT client are complete; about 70% overall.
  • The backend gateway and the SM4/SM3 command channel have an in-process end-to-end self-test script; decryption in the ESP32 firmware and integration with the app are unfinished, and the project is paused.

Retrospective

  • Device-side integration was never finished. The SM4/SM3 channel has only been self-tested inside the gateway process, not end to end on real hardware. This page is based on the backend gateway source and the development records from that time; the app source is not in that archive.

Project images

App home screen in the HarmonyOS simulator