Files
DSHWatch_Server/docs/BUILD_DEPLOY.md
T

69 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DSHWatch 构建与部署指南(v0.1)
> 说明:手表与手机必须 **同包名 + 同签名** 才能通过 @system.interconnect 通信。包名统一为 com.dshwatch.app。
## 1. 启动中继服务器(DSHWatch_Server)
cd DSHWatch_Server
cp config.example.json config.json # 修改 token
npm install
npm start
健康检查:GET http://127.0.0.1:8787/health
## 2. 配置 Harness 插件(dsh-watch)
在 DSH profile 的 cordis.patch.yml 里:
- id: dsh-watch
config:
mode: relay
serverUrl: "ws://你的服务器:8787"
userId: "someone"
token: "与 config.json 相同"
reconnectMs: 5000
timeoutMs: 30000
或直连模式:
- id: dsh-watch
config:
mode: direct
host: "0.0.0.0"
port: 18321
token: "自己定的 token"
## 3. 构建手机端 Android APK(DSHWatchPhone)
开发阶段可直接用官方 demo 证书(.dsh/downloads/interconnect_demo 里):
- 确保 app/libs/xms-wearable-lib_1.4_release.aar 存在(已放)。
- 放好 keystore.properties(含 keystore 路径/密码),keystore/keystore.jks 在本地。
- Android Studio 打开,Build -> Build APK。
# 已准备:keystore.properties (demo 证书 xmswearable)
./gradlew assembleDebug
注意:keystore.properties 与 keystore/ 不要提交到 git。
## 4. 构建手表端 rpk(DSHWatch)
AIoT IDE 打开 DSHWatch,用与手机 APK 相同的证书签名。
- DSHWatch/sign/debug 与 sign/release 已放入 demo 的 certificate.pem / private.pem(本地,gitignored)。
- 在 IDE 里「构建」或「发布」,生成 rpk。
## 5. 安装与联调
1. 手机安装 APK;手表装 rpk(小米运动健康 -> Debug -> 第三方应用)。
2. 手机 APP 打开,填服务器地址 / userId / token,点刷新。
3. 手表打开 DSHWatch,确认 interconnect 连上手机(显示"已连接")。
4. 手表发指令 -> 手机转发 -> 服务器 -> Harness -> 回显。
## 6. 常见坑
- **签名不一致**:手表 rpk 与手机 APK 必须同一套证书;改了证书要重装两个端。
- **连接状态拿不到**:进页面是 DISCONNECTED 是正常的,需轮询 getReadyState。
- **包名不一致**:两端都是 com.dshwatch.app。
- **麦克风**:MP 手环 10/10 Pro 大概率不支持应用级录音(system.record 官方表未列)。