生命周期与资源释放
页面级资源应随 ArkUI 页面释放;只有应用不再使用整个 SDK 时才关闭模块。
清理缓存
await GizSDKManager.cleanCache();该接口清理日志和数据点配置缓存,不等同于 logout()。
查询模块状态
const bluetoothReady: boolean = GizBluetoothManager.isReady();
const bluetoothStatus: string = GizBluetoothManager.getStatus();
const lanReady: boolean = GizLanManager.isReady();
const lanStatus: string = GizLanManager.getStatus();
const mqttReady: boolean = GizMqttManager.isReady();
const mqttStatus: string = GizMqttManager.getStatus();getStatus() 返回诊断字符串,不应作为稳定枚举写入业务状态机。
模块版本统一在初始化页面读取,具体版本以 OHPM 和运行结果为准。
页面级释放
GizBluetoothManager.stopBleScan();
await GizLanManager.stopDiscovery();
await device.bleCapability.disconnect(device);
await device.lanCapability.disconnect(device);
unsubscribeBluetooth();
unsubscribeLan();
unsubscribeData();
unsubscribeStatus();关闭全部模块
GizMqttManager.shutdown();
GizLanManager.shutdown();
GizBluetoothManager.shutdown();
GizSDKManager.shutdown();先关闭通信模块,再关闭核心模块。deregister() 是核心 shutdown() 的兼容命名。