Skip to main content
Version: v3

Overall Architecture

Architecture Diagram

The complete Mini Program includes Device App, Settings App and Side Service.

  • Device App
    • The Device App runs on a watch device
    • The operating system of the watch device is Zepp OS
    • The Device App can call the widget API to draw UI and call a series of sensors to obtain data
  • Settings App(optional)
    • Settings App runs in the Zepp App on mobile devices
    • Settings App draws UI by calling render function
  • Side Service(optional)
    • Side Service runs in the Zepp App on mobile devices
    • Side Service can communicate with external servers through Fetch API

Communication Relationships

BLE

BLE is used for communication between Device App and Side Service. The underlying BLE API is not user-friendly, so we provide the ZML tool library, which has a more complete implementation of the communication process and exposes the easy-to-use API.

  • Use this.request method to send messages in Device App and onRequest to receive messages in Side Service
  • Use this.call method to send messages in Side Service and onCall to receive messages in Device App
info

For more information about ZML, please refer to ZML - Github

Settings Storage

Communication between Settings App and Side Service relies on Settings Storage API.

info

To facilitate the display of data relationships, two Settings Storage are drawn in the figure, which are actually the same thing.

Settings Storage use setItem to set the data and use getItem to get the value.

  • Settings App -> Side Service (the red line)
    • Use addListener API in Side Service to register callback function to listen to data changes in Settings Storage
    • Use setItem to change data in the Settings App and trigger the registered callback function
    • When use setItem to set data in the Side Service, automatically call Settings App build lifecycle, redraw UI.
  • Side Service -> Settings App (the blue line)
    • Use setItem to change data in the Side Service
    • Settings Storage detects that data has changed, automatically triggers the re-rendering of the Settings App, and executes the build lifecycle

Side Service communicates with third-party Service using Fetch API

Usage reference Fetch API

More Info

caution

Direct communication between "Device App" and "Settings App" is not possible and requires a "Side Service".

tip