mini_program_gizwits_sdk 3.6.4 → 3.6.5

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 (134) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
  3. package/yarn-error.log +6901 -0
  4. package/dist/src/GizLog.d.ts +0 -18
  5. package/dist/src/crc/calculators/crc16modbus.d.ts +0 -2
  6. package/dist/src/crc/calculators/crc32.d.ts +0 -2
  7. package/dist/src/crc/crc16modbus.d.ts +0 -7
  8. package/dist/src/crc/crc32.d.ts +0 -7
  9. package/dist/src/crc/create_buffer.d.ts +0 -3
  10. package/dist/src/crc/define_crc.d.ts +0 -7
  11. package/dist/src/crc/index.d.ts +0 -19
  12. package/dist/src/crc/types.d.ts +0 -11
  13. package/dist/src/errorCode.d.ts +0 -3
  14. package/dist/src/globalData.d.ts +0 -2
  15. package/dist/src/handler/EventListener.d.ts +0 -9
  16. package/dist/src/handler/ble.d.ts +0 -105
  17. package/dist/src/handler/lan.d.ts +0 -78
  18. package/dist/src/handler/socket.d.ts +0 -151
  19. package/dist/src/openApiRequest.d.ts +0 -3
  20. package/dist/src/productConfigFileManage.d.ts +0 -11
  21. package/dist/src/protocol/Bind.d.ts +0 -7
  22. package/dist/src/protocol/DeviceInfo.d.ts +0 -11
  23. package/dist/src/protocol/DiscoverUDP.d.ts +0 -17
  24. package/dist/src/protocol/GetDeviceStatus.d.ts +0 -5
  25. package/dist/src/protocol/Login.d.ts +0 -12
  26. package/dist/src/protocol/Ntp.d.ts +0 -5
  27. package/dist/src/protocol/OTA/AwaitNoti.d.ts +0 -7
  28. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +0 -10
  29. package/dist/src/protocol/OTA/OTAPackPackage.d.ts +0 -8
  30. package/dist/src/protocol/OTA/OtaComplete.d.ts +0 -8
  31. package/dist/src/protocol/OTA/PreOTA.d.ts +0 -11
  32. package/dist/src/protocol/OTA/ResetPosition.d.ts +0 -6
  33. package/dist/src/protocol/OffLineData.d.ts +0 -23
  34. package/dist/src/protocol/ProtocolBase.d.ts +0 -11
  35. package/dist/src/protocol/Reset.d.ts +0 -8
  36. package/dist/src/protocol/SetReset.d.ts +0 -7
  37. package/dist/src/protocol/WifiConfig.d.ts +0 -6
  38. package/dist/src/protocol/dataPoint.d.ts +0 -34
  39. package/dist/src/protocol/tool.d.ts +0 -14
  40. package/dist/src/randomCode.d.ts +0 -3
  41. package/dist/src/request.d.ts +0 -1
  42. package/dist/src/sdk.d.ts +0 -136
  43. package/dist/src/sentry.d.ts +0 -2
  44. package/dist/src/services/devices.d.ts +0 -47
  45. package/dist/src/services/login.d.ts +0 -4
  46. package/dist/src/services/monitor.d.ts +0 -12
  47. package/dist/src/services/ota.d.ts +0 -7
  48. package/dist/src/services/tool.d.ts +0 -4
  49. package/dist/src/services/uploadP0.d.ts +0 -14
  50. package/dist/src/sleep.d.ts +0 -2
  51. package/dist/src/types/index.d.ts +0 -361
  52. package/dist/src/utils.d.ts +0 -46
  53. package/dist/src/wechatApi.d.ts +0 -19
  54. package/dist/src/wifiConfig/ConfigBase.d.ts +0 -27
  55. package/dist/src/wifiConfig/ap.d.ts +0 -11
  56. package/dist/src/wifiConfig/ble.d.ts +0 -41
  57. package/dist/src/wifiConfig/nfc/disposeData.d.ts +0 -2
  58. package/dist/src/wifiConfig/nfc/formatData.d.ts +0 -3
  59. package/dist/src/wifiConfig/nfc/formatSSID.d.ts +0 -6
  60. package/dist/src/wifiConfig/nfc/index.d.ts +0 -22
  61. package/dist/src/wifiConfig/nfc/isIncludedCH.d.ts +0 -1
  62. package/dist/src/wifiConfig/nfc/nfcAConnect.d.ts +0 -6
  63. package/dist/src/wifiConfig/nfc/nfcATransceive.d.ts +0 -5
  64. package/dist/src/wifiConfig/nfc/ssIDToASC.d.ts +0 -1
  65. package/dist/src/wifiConfig/nfc/stringToGbk.d.ts +0 -1
  66. package/dist/src/wifiConfig/nfc/transceive.wx.d.ts +0 -2
  67. package/dist/src/wifiConfig/nfc/types.d.ts +0 -15
  68. package/index.ts +0 -8
  69. package/src/GizLog.ts +0 -51
  70. package/src/crc/calculators/crc16modbus.ts +0 -36
  71. package/src/crc/calculators/crc32.ts +0 -47
  72. package/src/crc/crc16modbus.ts +0 -3
  73. package/src/crc/crc32.ts +0 -4
  74. package/src/crc/create_buffer.ts +0 -7
  75. package/src/crc/define_crc.ts +0 -9
  76. package/src/crc/index.ts +0 -10
  77. package/src/crc/package.json +0 -3
  78. package/src/crc/types.ts +0 -10
  79. package/src/errorCode.ts +0 -83
  80. package/src/globalData.ts +0 -9
  81. package/src/handler/EventListener.ts +0 -44
  82. package/src/handler/ble.ts +0 -1369
  83. package/src/handler/lan.ts +0 -389
  84. package/src/handler/socket.ts +0 -686
  85. package/src/openApiRequest.ts +0 -50
  86. package/src/productConfigFileManage.ts +0 -72
  87. package/src/protocol/Bind.ts +0 -22
  88. package/src/protocol/DeviceInfo.ts +0 -37
  89. package/src/protocol/DiscoverUDP.ts +0 -80
  90. package/src/protocol/GetDeviceStatus.ts +0 -61
  91. package/src/protocol/Login.ts +0 -43
  92. package/src/protocol/Ntp.ts +0 -13
  93. package/src/protocol/OTA/AwaitNoti.ts +0 -14
  94. package/src/protocol/OTA/CheckCanOTA.ts +0 -23
  95. package/src/protocol/OTA/OTAPackPackage.ts +0 -37
  96. package/src/protocol/OTA/OtaComplete.ts +0 -17
  97. package/src/protocol/OTA/PreOTA.ts +0 -48
  98. package/src/protocol/OTA/ResetPosition.ts +0 -14
  99. package/src/protocol/OffLineData.ts +0 -81
  100. package/src/protocol/ProtocolBase.ts +0 -54
  101. package/src/protocol/Reset.ts +0 -16
  102. package/src/protocol/SetReset.ts +0 -13
  103. package/src/protocol/WifiConfig.ts +0 -42
  104. package/src/protocol/dataPoint.ts +0 -687
  105. package/src/protocol/tool.ts +0 -140
  106. package/src/randomCode.ts +0 -25
  107. package/src/request.ts +0 -22
  108. package/src/sdk.ts +0 -1536
  109. package/src/sentry.ts +0 -55
  110. package/src/services/devices.ts +0 -313
  111. package/src/services/login.ts +0 -11
  112. package/src/services/monitor.ts +0 -117
  113. package/src/services/ota.ts +0 -17
  114. package/src/services/tool.ts +0 -10
  115. package/src/services/uploadP0.ts +0 -57
  116. package/src/sleep.ts +0 -2
  117. package/src/types/index.ts +0 -456
  118. package/src/utils.ts +0 -449
  119. package/src/wechatApi.ts +0 -211
  120. package/src/wifiConfig/ConfigBase.ts +0 -235
  121. package/src/wifiConfig/ap.ts +0 -185
  122. package/src/wifiConfig/ble.ts +0 -460
  123. package/src/wifiConfig/nfc/disposeData.ts +0 -63
  124. package/src/wifiConfig/nfc/formatData.ts +0 -46
  125. package/src/wifiConfig/nfc/formatSSID.ts +0 -59
  126. package/src/wifiConfig/nfc/index.ts +0 -134
  127. package/src/wifiConfig/nfc/isIncludedCH.ts +0 -8
  128. package/src/wifiConfig/nfc/nfcAConnect.ts +0 -30
  129. package/src/wifiConfig/nfc/nfcATransceive.ts +0 -29
  130. package/src/wifiConfig/nfc/ssIDToASC.ts +0 -12
  131. package/src/wifiConfig/nfc/stringToGbk.ts +0 -51
  132. package/src/wifiConfig/nfc/transceive.wx.ts +0 -124
  133. package/src/wifiConfig/nfc/types.ts +0 -18
  134. package/src/wifiConfig/timeZoneName.json +0 -1
@@ -1,140 +0,0 @@
1
- // 检查头部 和可变长度字段,返回index
2
- const checkHeader = (data) => {
3
- let pointer = 0;
4
- if (data[0] !== 0 || data[1] !== 0 || data[2] !== 0 || data[3] !== 3) {
5
- // 数据不合法
6
- return false;
7
- }
8
- pointer = 4;
9
- return pointer;
10
- };
11
-
12
- // 从2进制,转换成10进制数组
13
- export const completeBlock = (cmd: string) => {
14
- // 补0到8的倍数
15
- const newCmd = fillString(cmd, Math.ceil(cmd.length / 8) * 8);
16
- const data: number[] = [];
17
- for (let i = 0; i < newCmd.length; i += 8) {
18
- data.push(parseInt(newCmd.substring(i, i + 8), 2));
19
- }
20
- return data;
21
- };
22
-
23
- const getProtocolLen = (data) => {
24
- /**
25
- * 插入len
26
- * 计算方法,从第一位开始往下算,直到找到一个字节的最高位不为1
27
- */
28
- let lengthIndex = 0;
29
- for (; lengthIndex < data.length; lengthIndex++) {
30
- if (fillString(data[lengthIndex].toString(2), 8)[0] !== '1') {
31
- // 此时 lengthIndex 就是长度
32
- break;
33
- }
34
- }
35
- return lengthIndex + 1;
36
- }
37
- // 十进制数组转16进制字符串并补充
38
- function arrayToString(arr: number[]) {
39
- let string = '';
40
- arr.map((item) => {
41
- string += fillString(item.toString(16), 2);
42
- return null;
43
- });
44
- return string;
45
- }
46
-
47
- export function arrayToASCII(arr: number[]) {
48
- let string = '';
49
- arr.map((item) => {
50
- string += String.fromCharCode(item)
51
- return null;
52
- });
53
- return string;
54
- }
55
-
56
- const fillString = (string: string, num: number, foot: boolean = false) => {
57
- const len = num - string.length;
58
- const paddingString = new Array(len).fill(0).join('');
59
- if (foot) {
60
- // 后面加
61
- string += paddingString;
62
- } else {
63
- string = paddingString + string;
64
- }
65
- return string;
66
- };
67
-
68
- const bytesToInt = (data: number[]) => {
69
- let result = 0;
70
- for (let i = 0; i < data.length; i++) {
71
- result = (result << 8) | data[i];
72
- }
73
- return result;
74
- }
75
-
76
- const bytesToHexString = (data: number[]) => {
77
- return Array.from(data, byte => ('0' + byte.toString(16)).slice(-2)).join('');
78
- }
79
- const string2Bytes = (str: string) => {
80
- const bytes: number[] = [];
81
- for(let i = 0; i<str.length; i++) {
82
- bytes.push(str.charCodeAt(i))
83
- }
84
- return bytes;
85
- }
86
-
87
- const hexStrint2byte = (str: string) => {
88
- // 如果长度不是偶数,需要补0
89
- if (str.length % 2 !== 0) {
90
- str = `0${str}`;
91
- }
92
- const length = Math.ceil(str.length / 2);
93
- const bytes: number[] = [];
94
- for (let i = 0; i < length; i++) {
95
- const start = i * 2;
96
- const end = start + 2;
97
- const data = str.substring(start,end);
98
- bytes.push(parseInt(data, 16))
99
- }
100
- return bytes
101
- }
102
-
103
- const formatCode = (str) => {
104
- const code = encodeURI(str);
105
- if (code.indexOf('%') !== -1 && str !== '%') {
106
- // utf8
107
- return code
108
- .split('%')
109
- .filter((item) => item !== '')
110
- .map((item) => parseInt(item, 16));
111
- }
112
- return [code.charCodeAt(0)];
113
- };
114
-
115
- const formatCodesFromStr = (str: string) => {
116
- const len = [0, 0];
117
- let codes: number[] = [];
118
- for (let i = 0; i < str.length; i++) {
119
- const code = formatCode(str[i]);
120
- len[1] += code.length;
121
- codes = codes.concat(code);
122
- }
123
- return [codes, len];
124
- };
125
-
126
- const arrayToUint8 = (config: number[]) => {
127
- const buffer = new ArrayBuffer(config.length);
128
- const uint8Array = new Uint8Array(buffer);
129
- for (let i = 0; i < buffer.byteLength; i++) {
130
- uint8Array[i] = config[i];
131
- }
132
- return uint8Array;
133
- }
134
-
135
-
136
- export { checkHeader, getProtocolLen, arrayToString, fillString,
137
- string2Bytes, hexStrint2byte, formatCodesFromStr,
138
- formatCode, arrayToUint8, bytesToInt,
139
- bytesToHexString
140
- };
package/src/randomCode.ts DELETED
@@ -1,25 +0,0 @@
1
- import {MD5, AES, enc, pad, mode} from 'crypto-js';
2
- import { IGetRandomCode, IGetRandomCodes } from './types';
3
-
4
- const getRandomCodes = ({ SSID, password, pks }: IGetRandomCodes): string[] => {
5
- const randomCodes: string[] = [];
6
- pks.map(item => {
7
- const code = getRandomCode({
8
- SSID,
9
- password,
10
- pk: item
11
- });
12
- randomCodes.push(code);
13
- })
14
- return randomCodes;
15
- }
16
-
17
- const getRandomCode = ({ SSID, password, pk }: IGetRandomCode): string => {
18
- let aesKey:any = MD5(SSID + password).toString();
19
- aesKey = enc.Hex.parse(aesKey)
20
- let encryptedHexStr = enc.Utf8.parse(pk);
21
- let encrypted = AES.encrypt(encryptedHexStr, aesKey, { iv: aesKey,mode: mode.ECB, padding: pad.ZeroPadding });
22
- return MD5(encrypted.ciphertext).toString();
23
- }
24
-
25
- export default getRandomCodes;
package/src/request.ts DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Requests a URL, returning a promise.
3
- *
4
- * @param {string} url The URL we want to request
5
- * @param {object} [options] The options we want to pass to "fetch"
6
- * @return {object} An object containing either "data" or "err"
7
- */
8
-
9
-
10
- export default function request<T>(url: string, options: any) {
11
- return new Promise<T>((res, rej) => {
12
- wx.request({
13
- url, timeout: 3000, ...options,
14
- success: (data: T) => {
15
- res(data)
16
- },
17
- fail: (err: any) => {
18
- rej(err);
19
- },
20
- });
21
- });
22
- }