mini_program_gizwits_sdk 3.7.2-gefeier → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +143 -0
  2. package/dist/index.js +6 -4
  3. package/dist/src/crc/calculators/crc16modbus.d.ts +2 -0
  4. package/dist/src/crc/calculators/crc32.d.ts +2 -0
  5. package/dist/src/crc/crc16modbus.d.ts +7 -0
  6. package/dist/src/crc/crc32.d.ts +7 -0
  7. package/dist/src/crc/create_buffer.d.ts +4 -0
  8. package/dist/src/crc/define_crc.d.ts +7 -0
  9. package/dist/src/crc/index.d.ts +19 -0
  10. package/dist/src/crc/types.d.ts +10 -0
  11. package/dist/src/handler/EventListener.d.ts +9 -0
  12. package/dist/src/handler/ble.d.ts +130 -0
  13. package/dist/src/handler/lan.d.ts +79 -0
  14. package/dist/src/handler/socket.d.ts +161 -0
  15. package/dist/src/protocol/Bind.d.ts +7 -0
  16. package/dist/src/protocol/DeviceInfo.d.ts +11 -0
  17. package/dist/src/protocol/DiscoverUDP.d.ts +17 -0
  18. package/dist/src/protocol/GetDeviceStatus.d.ts +5 -0
  19. package/dist/src/protocol/Login.d.ts +12 -0
  20. package/dist/src/protocol/Ntp.d.ts +5 -0
  21. package/dist/src/protocol/OTA/AwaitNoti.d.ts +7 -0
  22. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +10 -0
  23. package/dist/src/protocol/OTA/OTAPackPackage.d.ts +8 -0
  24. package/dist/src/protocol/OTA/OtaComplete.d.ts +8 -0
  25. package/dist/src/protocol/OTA/PreOTA.d.ts +11 -0
  26. package/dist/src/protocol/OTA/ResetPosition.d.ts +6 -0
  27. package/dist/src/protocol/OTAStatus.d.ts +4 -0
  28. package/dist/src/protocol/OffLineData.d.ts +23 -0
  29. package/dist/src/protocol/ProtocolBase.d.ts +12 -0
  30. package/dist/src/protocol/Reset.d.ts +8 -0
  31. package/dist/src/protocol/SetReset.d.ts +7 -0
  32. package/dist/src/protocol/TransparentData.d.ts +12 -0
  33. package/dist/src/protocol/WifiConfig.d.ts +11 -0
  34. package/dist/src/protocol/dataPoint.d.ts +34 -0
  35. package/dist/src/protocol/tool.d.ts +14 -0
  36. package/dist/src/sdk.d.ts +158 -0
  37. package/dist/src/services/devices.d.ts +52 -0
  38. package/dist/src/services/login.d.ts +4 -0
  39. package/dist/src/services/monitor.d.ts +12 -0
  40. package/dist/src/services/ota.d.ts +7 -0
  41. package/dist/src/services/tool.d.ts +4 -0
  42. package/dist/src/services/uploadP0.d.ts +14 -0
  43. package/dist/src/types/index.d.ts +414 -0
  44. package/dist/src/types/otaStatus.d.ts +72 -0
  45. package/dist/src/utils/GizLog.d.ts +18 -0
  46. package/dist/src/utils/bleConfigLog.d.ts +11 -0
  47. package/dist/src/utils/connectedBssid.d.ts +6 -0
  48. package/dist/src/utils/errorCode.d.ts +3 -0
  49. package/dist/src/utils/globalData.d.ts +2 -0
  50. package/dist/src/utils/openApiRequest.d.ts +27 -0
  51. package/dist/src/utils/productConfigFileManage.d.ts +15 -0
  52. package/dist/src/utils/randomCode.d.ts +3 -0
  53. package/dist/src/utils/request.d.ts +1 -0
  54. package/dist/src/utils/sentry.d.ts +2 -0
  55. package/dist/src/utils/sleep.d.ts +2 -0
  56. package/dist/src/utils/utils.d.ts +55 -0
  57. package/dist/src/utils/wechatApi.d.ts +24 -0
  58. package/dist/src/utils/wifiConfigLogReport.d.ts +28 -0
  59. package/dist/src/wifiConfig/ConfigBase.d.ts +30 -0
  60. package/dist/src/wifiConfig/ap.d.ts +11 -0
  61. package/dist/src/wifiConfig/ble.d.ts +43 -0
  62. package/dist/src/wifiConfig/nfc/disposeData.d.ts +2 -0
  63. package/dist/src/wifiConfig/nfc/formatData.d.ts +3 -0
  64. package/dist/src/wifiConfig/nfc/formatSSID.d.ts +6 -0
  65. package/dist/src/wifiConfig/nfc/index.d.ts +22 -0
  66. package/dist/src/wifiConfig/nfc/isIncludedCH.d.ts +1 -0
  67. package/dist/src/wifiConfig/nfc/nfcAConnect.d.ts +6 -0
  68. package/dist/src/wifiConfig/nfc/nfcATransceive.d.ts +5 -0
  69. package/dist/src/wifiConfig/nfc/ssIDToASC.d.ts +1 -0
  70. package/dist/src/wifiConfig/nfc/stringToGbk.d.ts +1 -0
  71. package/dist/src/wifiConfig/nfc/transceive.wx.d.ts +2 -0
  72. package/dist/src/wifiConfig/nfc/types.d.ts +15 -0
  73. package/docs/ota-status.md +139 -0
  74. package/package.json +9 -3
  75. package/.istanbul.yml +0 -4
  76. package/.travis.yml +0 -23
  77. package/.vscode/launch.json +0 -19
  78. package/.vscode/settings.json +0 -3
  79. package/yarn-error.log +0 -6901
@@ -0,0 +1,28 @@
1
+ import { AppInfo, MobileInfo, WifiConfigLog } from "../types";
2
+ declare class WifiConfigLogReport {
3
+ isSuccess: boolean;
4
+ ssid: string;
5
+ mode: number;
6
+ timeout: number;
7
+ isBind: boolean;
8
+ mobileInfo: MobileInfo;
9
+ appInfo: AppInfo;
10
+ productKey: string;
11
+ logs: WifiConfigLog[];
12
+ constructor();
13
+ init: (data: {
14
+ productKey?: string;
15
+ ssid: string;
16
+ mode: number;
17
+ timeout: number;
18
+ isBind: boolean;
19
+ }) => void;
20
+ getEnv: () => void;
21
+ updateProductKey: (key: string) => void;
22
+ appendEvent: (log: WifiConfigLog) => void;
23
+ report: () => Promise<void>;
24
+ cancel: () => Promise<void>;
25
+ clean: () => void;
26
+ }
27
+ declare const _default: WifiConfigLogReport;
28
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import { IRandomCodesResult, IRejectCallback, IResult, TimeoutHandle } from "../types";
2
+ import { ConfigEventData, ConfigStage, ConfigStatus, IDevice } from "../types";
3
+ declare class ConfigBase {
4
+ ssid: string;
5
+ bssid: string;
6
+ password: string;
7
+ specialProductKeys: string[];
8
+ disableSearchDevice: boolean;
9
+ specialProductKeySecrets: string[];
10
+ timeoutHandler: TimeoutHandle;
11
+ eventCallBack: (event: ConfigEventData) => void;
12
+ private readonly progressStartedAt;
13
+ protected emitConfigEvent(event: ConfigEventData, callback?: (event: ConfigEventData) => void): void;
14
+ protected progress(stage: ConfigStage, status: ConfigStatus, fields?: Partial<ConfigEventData>): void;
15
+ private setDeviceOnboardingDeployRej?;
16
+ constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[]);
17
+ cleanTimeout: () => void;
18
+ stopDeviceOnboardingDeploy: () => void;
19
+ appendExtendData: (key: string) => string;
20
+ hasTimeoutHandler: (cb?: IRejectCallback) => boolean;
21
+ handleTimeout: () => void;
22
+ protected searchDevice: ({ ssid, password }: {
23
+ ssid: string;
24
+ password: string;
25
+ }) => Promise<IResult<IRandomCodesResult[]>>;
26
+ initDeviceOnboardingDeploy: (_res: any, rej: any) => void;
27
+ protected startTimeoutTimer: (timeout: number) => void;
28
+ protected bindDevices: (devices: IDevice[]) => Promise<IResult<IDevice[]>>;
29
+ }
30
+ export default ConfigBase;
@@ -0,0 +1,11 @@
1
+ import { IDevice, IRandomCodesResult, IResult, configDeviceParams, ISetDeviceOnboardingDeployProps } from "../types";
2
+ import ConfigBase from "./ConfigBase";
3
+ declare class ApConfig extends ConfigBase {
4
+ disableSendUDP: boolean;
5
+ private sendMessageInterval;
6
+ private UDPSocketHandler;
7
+ destroy: () => void;
8
+ configDevice: ({ ssid, password, softAPSSIDPrefix }: configDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
9
+ setDeviceOnboardingDeploy: ({ timeout, isBind, productKey, softAPSSIDPrefix, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
10
+ }
11
+ export default ApConfig;
@@ -0,0 +1,43 @@
1
+ import { BleHandle } from "../handler/ble";
2
+ import ConfigBase from "./ConfigBase";
3
+ import { IDevice, IError, ConfigEventData, IRandomCodesResult, IResult, configBLEDeviceParams } from "../types";
4
+ type EnableAndGetBluetoothDevicesRes = Promise<{
5
+ success: false;
6
+ err: IError;
7
+ } | {
8
+ success: true;
9
+ bleDevices?: IDevice[];
10
+ }>;
11
+ interface IArgs {
12
+ bleDeviceId: string;
13
+ arrayBuffer: ArrayBuffer;
14
+ usesBssid?: boolean;
15
+ serviceUUIDSuffix?: string;
16
+ characteristicUUIDSuffix?: string;
17
+ bleHandle: BleHandle;
18
+ eventCallBack?: (event: ConfigEventData) => void;
19
+ }
20
+ interface ISetDeviceOnboardingDeployProps {
21
+ timeout: number;
22
+ isBind: boolean;
23
+ softAPSSIDPrefix: string;
24
+ productKey?: string;
25
+ eventCallBack?: (event: ConfigEventData) => void;
26
+ }
27
+ declare class BLEConfig extends ConfigBase {
28
+ bleHandle: BleHandle;
29
+ constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[], bleHandle: BleHandle);
30
+ sendBLEConfigCmd: ({ bleDeviceId, arrayBuffer, usesBssid, serviceUUIDSuffix, characteristicUUIDSuffix, bleHandle, eventCallBack }: IArgs) => Promise<boolean | void>;
31
+ destroy: () => void;
32
+ isValidBleDevice: (device: IDevice, softAPSSIDPrefix?: string) => boolean;
33
+ enableBluetoothDevicesDescovery: () => Promise<{
34
+ success: false;
35
+ err: IError;
36
+ } | {
37
+ success: true;
38
+ }>;
39
+ enableAndGetBluetoothDevices: (softAPSSIDPrefix?: string) => EnableAndGetBluetoothDevicesRes;
40
+ setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, productKey, eventCallBack, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
41
+ configBLEDevice: ({ ssid, password, softAPSSIDPrefix, }: configBLEDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
42
+ }
43
+ export default BLEConfig;
@@ -0,0 +1,2 @@
1
+ import { IDATA } from './types';
2
+ export declare const disposeData: (SSID: Uint8Array, isSSIDincludeCH: boolean, pwd: Uint8Array, passIP: Uint8Array, BSSID: Uint8Array) => IDATA;
@@ -0,0 +1,3 @@
1
+ type IType = 'BSSID' | 'pwd' | 'address';
2
+ export declare const formatData: (data: string, type: IType) => Uint8Array;
3
+ export {};
@@ -0,0 +1,6 @@
1
+ interface IExport {
2
+ SSIDTLV: any;
3
+ isSSIDIncludedCH: boolean;
4
+ }
5
+ export declare const formatSSID: (SSID: string) => IExport;
6
+ export {};
@@ -0,0 +1,22 @@
1
+ import ConfigBase from "../ConfigBase";
2
+ import { IDevice, IResult } from '../../types';
3
+ interface configDeviceParams {
4
+ ssid: string;
5
+ password: string;
6
+ bssid: string;
7
+ address: string;
8
+ }
9
+ interface ISetDeviceOnboardingDeployProps {
10
+ timeout: number;
11
+ isBind: boolean;
12
+ BSSID: string;
13
+ softAPSSIDPrefix: string;
14
+ }
15
+ declare class NFCConfig extends ConfigBase {
16
+ address: string;
17
+ constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[], address: string);
18
+ destroy: () => void;
19
+ configDevice: ({ ssid, password, bssid, address }: configDeviceParams) => Promise<IResult<import("../../types").IRandomCodesResult[]>>;
20
+ setDeviceOnboardingDeploy: ({ timeout, isBind, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
21
+ }
22
+ export default NFCConfig;
@@ -0,0 +1 @@
1
+ export default function isIncludedCH(str: string): boolean;
@@ -0,0 +1,6 @@
1
+ type T = {
2
+ success: boolean;
3
+ nfcA: any;
4
+ };
5
+ export declare const nfcAConnect: (NFCAdapter: any) => Promise<T>;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ type T = {
2
+ transceiveSuccess: boolean;
3
+ };
4
+ export declare const nfcATransceive: (nfcA: any, buffer: ArrayBuffer) => Promise<T>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export declare const ssIDToASC: (SSID: string) => Uint8Array;
@@ -0,0 +1 @@
1
+ export default function stringToGbk(str: string): Uint8Array;
@@ -0,0 +1,2 @@
1
+ import { IDATA } from './types';
2
+ export declare const transceive: (DATA: IDATA) => void;
@@ -0,0 +1,15 @@
1
+ type PageStateProps = {
2
+ store: {};
3
+ };
4
+ interface WifiInfo {
5
+ SSID: string;
6
+ BSSID: string;
7
+ secure: boolean;
8
+ signalStrength: number;
9
+ frequency: number;
10
+ }
11
+ type IDATA = {
12
+ ArrayBuffer_sign: ArrayBuffer;
13
+ ArrayBuffer_others: ArrayBuffer;
14
+ };
15
+ export { PageStateProps, WifiInfo, IDATA };
@@ -0,0 +1,139 @@
1
+ # OTA 状态回调与查询
2
+
3
+ 本接口实现 OTA 状态扩展 v1:设备以 `0x15` 上报完整快照,应用以 `0x16` 查询当前状态。它们是独立的数据点业务命令,不嵌套在 `sendTransparentData` 的 `0x05` 内,也不是 `GizDeviceTransparentData` 的 `0x06` 载荷。
4
+
5
+ **设备是否支持、是否查询、是否展示,由应用层判断。** SDK 不检查型号或版本、不自动查询或轮询、不启动升级、不缓存上次任务结果。原有 `startUpgrade`、透传接口和事件仍可使用。
6
+
7
+ ## 接入示例
8
+
9
+ ```ts
10
+ import GizwitsMiniSDK, {
11
+ OTAStatusType,
12
+ OTAStatusState,
13
+ OTAStatusReason,
14
+ } from 'mini_program_gizwits_sdk';
15
+ import type { IDevice, OTAStatusEvent } from 'mini_program_gizwits_sdk';
16
+
17
+ // sdk 已初始化,device 已通过现有 subscribe 接口完成订阅。
18
+ // supportsOTAStatus 来自应用自己的产品配置 / 能力信息。
19
+ async function enterOTAPage(sdk: GizwitsMiniSDK, device: IDevice, supportsOTAStatus: boolean) {
20
+ if (!supportsOTAStatus) return () => {};
21
+
22
+ const sdid = 0; // 本机;代理子设备时使用中控 device + 子设备 SDID
23
+ const otaType = OTAStatusType.MCU;
24
+ const stop = sdk.onOTAStatus((event: OTAStatusEvent) => {
25
+ if (event.device.mac !== device.mac || event.device.productKey !== device.productKey
26
+ || event.sdid !== sdid || event.otaType !== otaType) return;
27
+
28
+ // null 表示无可展示的进度,不能当作 0% 或 255%。
29
+ console.log(event.progress, OTAStatusState[event.state]);
30
+ if (event.state === OTAStatusState.FAILED || event.state === OTAStatusState.UNAVAILABLE) {
31
+ console.log(OTAStatusReason[event.reason]);
32
+ }
33
+ // IDLE 仅表示当前无任务;应用应通过现有版本接口确认升级结果。
34
+ });
35
+
36
+ const sent = await sdk.queryOTAStatus(device, { otaType, sdid });
37
+ if (!sent.success) console.warn('查询发送失败', sent.message);
38
+ // 页面退出时调用 stop()。发送成功后若无回调,由应用决定等待时长和提示方式。
39
+ return stop;
40
+ }
41
+ ```
42
+
43
+ 先监听,再查询。重新进入页面可查询一次,不需要应用持续轮询。也可使用通用事件接口:
44
+
45
+ ```ts
46
+ await sdk.addEventListener('GizDeviceOTAStatus', callback);
47
+ sdk.removeEventListener('GizDeviceOTAStatus', callback);
48
+ ```
49
+
50
+ `onOTAStatus(callback)` 返回取消监听函数。两种注册方式是同一个事件,无需重复注册;监听范围为 SDK 收到的所有设备,应用按外层设备、`sdid`、`otaType` 筛选。没有监听时不启用 OTA 事件分流。
51
+
52
+ ## 查询接口
53
+
54
+ `queryOTAStatus(device, { otaType, sdid? }): Promise<ISDKResult<void>>`
55
+
56
+ | 参数 | 说明 |
57
+ | --- | --- |
58
+ | `device` | 已订阅设备,至少包含 `mac`、`productKey`;SDK 使用当前路由 |
59
+ | `otaType` | `OTAStatusType.MODULE = 1`、`MCU = 2`、`VOICE = 3`,必填 |
60
+ | `sdid` | 默认 `0` 本机;子设备为 `1–0x7fffffff`;不支持 GroupID |
61
+
62
+ 返回值仅表示链路发送 / 云端请求结果,**不是 OTA 查询结果,也不是设备支持证明**。真正的状态通过 `onOTAStatus` 返回;传输层 `0x0094` ACK 不触发状态回调。无响应也不能直接推断空闲或升级失败。协议无任务 ID,SDK 不把某条快照绑定到某次查询 Promise。
63
+
64
+ 路由沿用 `writeRaw`:BLE 连接、LAN TCP、WAN;BLE 广播和无连接状态返回失败。LAN / BLE 封装完整 `0x0093` P0;WAN 沿用已有 WebSocket P0 发送方式,OpenAPI 回退发送 `Action + Payload`,查询不依赖产品数据点定义。WAN 上行兼容完整 P0 和 `Action + Payload` raw 数组,并保留原有 raw 通知。
65
+
66
+ 各设备必须在所选链路实现该扩展。当前固件协议规定 WiFi 本地 / 云端承载,SDK 的 BLE 编解码能力不代表所有 BLE 固件已支持;应用应依据产品能力选择。
67
+
68
+ ## 回调字段
69
+
70
+ | 字段 | 说明 |
71
+ | --- | --- |
72
+ | `device` | 外层设备;中控代理时为中控本身 |
73
+ | `version` | `1` |
74
+ | `sdid` | 本机 `0` 或子设备 ID;与云端 DID 字符串不同 |
75
+ | `otaType` | 被升级组件,见 `OTAStatusType`;不要复用旧 OTA 下载接口类型 |
76
+ | `state` | `OTAStatusState` |
77
+ | `progress` | 整体整数百分比,进行中 / 失败 `0–95`,成功 `100`;空闲 / 查询不可用为 `null` |
78
+ | `result` | `OTAStatusResult.NONE = 0`、`SUCCESS = 1`、`FAILURE = 2` |
79
+ | `reason` | `OTAStatusReason`,正常为 `NONE = 0` |
80
+
81
+ SDK 原样传递整体进度,不按阶段重新计算、不虚增、不跨任务强制递增。固件负责 MCU 两种模式及语音模组的进度计算。仅 `SUCCEEDED + SUCCESS + 100` 代表成功;任务结束后查询可能返回 `IDLE`,应用通过版本接口确认,不能把 `IDLE` 当作成功。
82
+
83
+ 设备负责普通进度变化至少 5 个百分点、最短间隔 5 秒、20 秒保活;状态变化、结束、查询响应可即时上报。SDK 不二次节流或去重,重复进度可能是保活。固件不能通信时,SDK 也不会合成保活或失败事件。
84
+
85
+ 解析器校验长度、版本、目标、枚举及状态 / 进度 / 结果 / 原因组合。未知版本、预留值、畸形报文、旧 `0x06` 透传和纯 ACK 不产生 OTA 状态回调。
86
+
87
+ ## 状态速查
88
+
89
+ | 值 | `OTAStatusState` | 含义 |
90
+ | --- | --- | --- |
91
+ | `00` | `IDLE` | 当前无任务 |
92
+ | `01` | `PREPARING` | 准备 / 预检查 |
93
+ | `02` | `DOWNLOADING` | 下载 / 接收固件 |
94
+ | `03` | `VERIFYING` | 校验中 |
95
+ | `04` | `VERIFIED` | 校验通过 |
96
+ | `05` | `INSTALLING` | 目标正在擦除 / 写入 / 应用固件 |
97
+ | `06` | `REBOOTING` | 等待重启 |
98
+ | `07` | `CONFIRMING` | 等待版本 / 启动确认,进度 95 |
99
+ | `08` | `SUCCEEDED` | 成功,进度 100 |
100
+ | `09` | `FAILED` | 升级失败,保留进度 |
101
+ | `0A` | `UNAVAILABLE` | 本次查询不可用,不代表 OTA 失败 |
102
+ | `0B` | `TRANSFERRING` | 完整缓存后向目标传输 |
103
+ | `0C` | `STREAMING` | MCU 边下边传 |
104
+
105
+ ## 原因速查
106
+
107
+ 以下数值均为十六进制,对应 `OTAStatusReason`。
108
+
109
+ | 值 | 枚举 | 含义 |
110
+ | --- | --- | --- |
111
+ | `0000` | `NONE` | 无异常 |
112
+ | `0001` | `UNKNOWN_ERROR` | 未分类失败 |
113
+ | `0002` | `INVALID_FIRMWARE_INFO` | 固件信息非法 |
114
+ | `0003` | `PRODUCT_MISMATCH` | 产品不匹配 |
115
+ | `0004` | `HARDWARE_MISMATCH` | 硬件不匹配 |
116
+ | `0005` | `VERSION_REJECTED` | 版本不允许升级 |
117
+ | `0006` | `INSUFFICIENT_STORAGE` | 存储不足 |
118
+ | `0007` | `POWER_NOT_READY` | 供电条件不满足 |
119
+ | `0008` | `DOWNLOAD_FAILED` | 下载失败 |
120
+ | `0009` | `DOWNLOAD_TIMEOUT` | 下载超时 |
121
+ | `000A` | `SIZE_MISMATCH` | 大小不匹配 |
122
+ | `000B` | `CHECKSUM_MISMATCH` | 校验和不匹配 |
123
+ | `000C` | `SIGNATURE_INVALID` | 签名无效 |
124
+ | `000D` | `IMAGE_PROCESS_FAILED` | 镜像处理失败 |
125
+ | `000E` | `FLASH_ERASE_FAILED` | 擦除失败 |
126
+ | `000F` | `FLASH_WRITE_FAILED` | 写入失败 |
127
+ | `0010` | `TARGET_COMMUNICATION_FAILED` | 与目标通信失败 |
128
+ | `0011` | `ACTIVATION_TIMEOUT` | 激活超时 |
129
+ | `0012` | `BOOT_CONFIRM_FAILED` | 启动确认失败 |
130
+ | `0013` | `ROLLED_BACK` | 已回滚 |
131
+ | `0014` | `CANCELLED` | 已取消 |
132
+ | `0015` | `INTERRUPTED` | 升级中断 |
133
+ | `0101` | `TARGET_NOT_FOUND` | 目标不存在 |
134
+ | `0102` | `OTA_TYPE_UNSUPPORTED` | 组件类型不支持 |
135
+ | `0103` | `TARGET_OFFLINE` | 目标离线 |
136
+ | `0104` | `QUERY_TIMEOUT` | 中控查询目标超时 |
137
+ | `0105` | `STATE_UNAVAILABLE` | 当前状态不可获取 |
138
+
139
+ 完整线协议见 [OTA 状态上报与查询](https://sdkdoc-protocol.iotsdk.com/protocol/datapoint/ota)。
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.7.2-gefeier",
3
+ "version": "3.7.2",
4
4
  "description": "mini_program_gizwits_sdk",
5
5
  "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": ["dist", "README.md", "global.d.ts", "docs"],
6
8
  "scripts": {
7
9
  "test:bssid": "mocha -r ts-node/register tests/bssid/*.spec.ts --timeout 5000",
8
10
  "test": "node_modules/mocha/bin/_mocha -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
9
11
  "testBle": "node_modules/mocha/bin/_mocha -r ts-node/register tests/utils/randomCode.spec.ts -file ./tests/setup-wx.js -timeout 60s",
10
- "build": "rm -rf ./dist && webpack",
12
+ "build": "rm -rf ./dist && tsc --emitDeclarationOnly && webpack",
13
+ "link:dev": "yarn link && webpack --watch --mode development --devtool source-map",
14
+ "test:ota-status": "mocha -r ts-node/register --file ./tests/setup-wx.js tests/protocol/otaStatus.spec.ts --timeout 5000",
15
+ "test:transparent": "mocha -r ts-node/register --file ./tests/setup-wx.js tests/protocol/transparentData.spec.ts tests/protocol/otaTransferLock.spec.ts --timeout 5000",
16
+ "pack:local": "npm run build && npm pack",
11
17
  "release": "npm run build && release-it",
12
18
  "cover": "istanbul cover node_modules/mocha/bin/_mocha -- -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
13
19
  "coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
@@ -36,7 +42,7 @@
36
42
  "mocha": "^7.1.1",
37
43
  "release-it": "^14.2.2",
38
44
  "sinon": "^9.2.4",
39
- "ts-loader": "^8.4.0",
45
+ "ts-loader": "^6.2.2",
40
46
  "ts-node": "^8.8.1",
41
47
  "typescript": "^4.9.5",
42
48
  "uglifyjs-webpack-plugin": "^2.2.0",
package/.istanbul.yml DELETED
@@ -1,4 +0,0 @@
1
- instrumentation:
2
- root: . # 执行的根目录
3
- extensions:
4
- - .ts # 检查覆盖率的文件扩张名
package/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - 10
4
- branches:
5
- only:
6
- - master
7
- install:
8
- - npm install
9
- script:
10
- - npm run test
11
- - npm run build
12
- after_success:
13
- - npm run coveralls
14
- deploy:
15
- provider: npm
16
- email: rbwang@gizwits.com
17
- api_key:
18
- secure: GrkNtVOo77beuB+ZyMWIeXQa2rYJtpstJYBX7aLQlg7Fb/yvlOywIARI+sW4RmvnrIOVYwVwhX24m9Jq2B/IU6ToiH5LNKeqLVeBaZmcYE2ribl3XkImzO6ZJLDEvMA7/cW8ZP6Pqm5rd1H5xHLYrwe6cwyp4S2LH8FF8scf3HVlDLlkpK+umMgep6nMgXSV0GVz0lrHfFEECvEY4UAuS/gZb9bPk8N8WMW8oqIZHP+yJ/floDopAAEJ+iCvl6SdykZjwmIQf0ZI/l6glgEUITGiai3CYkGcoyENm/itQC0y+wtZhjQmKyHI0zznwswnj33DE2kUla0BLu0P2mW78hlHEKwgdpvbZGlPnS94MTZ7qPkDtHwujJz7/oy54AiNR5LWYdUxLby7n495PKO+eJjYa/zuwjMRavLY86bZIsHTzHTjOVutD9IfsbyeAOSGeowuA3sw5n24R7CmG2oDCbGaQznXayWCcnZteJqLmFmY5B15v3QfcOM5dX/QqLUEZOy6l10bXXElnGqsWLs8Te2a6WeT5TmxqAKA+ljPMzcp7E2jIAiLny7EcRN7yxnTXVO8cVJ42MHlFX93TlFNJlWBi663dV2imb6xi2gK6m66OWgH7pfx32l8PhsAtv9mI43ADRWrRd7E5/jy1hgPbar6dDaDK4tR/gtunWh6KgQ=
19
- skip_cleanup: true
20
- on:
21
- branch: master
22
- tag: latest
23
- condition: "$TRAVIS_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+$"
@@ -1,19 +0,0 @@
1
- {
2
- // 使用 IntelliSense 了解相关属性。
3
- // 悬停以查看现有属性的描述。
4
- // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Mocha Tests",
11
- "url": "http://localhost:8080",
12
- "webRoot": "${workspaceFolder}",
13
- "skipFiles": [
14
- "<node_internals>/**"
15
- ],
16
- "program":"${workspaceFolder}/node_modules/mocha/bin/_mocha -r ts-node/register tests/bleConfig/sdk.ble.spec.ts -file ./tests/setup-wx.js -timeout 60s"
17
- }
18
- ]
19
- }
@@ -1,3 +0,0 @@
1
- {
2
- "mocha.enabled": true
3
- }