mini_program_gizwits_sdk 3.0.2-beta → 3.0.7

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 (53) hide show
  1. package/dist/index.js +3 -20
  2. package/dist/src/errorCode.d.ts +5 -0
  3. package/dist/src/globalData.d.ts +2 -0
  4. package/dist/src/openApiRequest.d.ts +9 -0
  5. package/dist/src/productConfigFileManage.d.ts +12 -0
  6. package/dist/src/protocol/Bind.d.ts +7 -0
  7. package/dist/src/protocol/DataPoint.d.ts +52 -0
  8. package/dist/src/protocol/GetDeviceStatus.d.ts +5 -0
  9. package/dist/src/protocol/Login.d.ts +12 -0
  10. package/dist/src/protocol/ProtocolBase.d.ts +11 -0
  11. package/dist/src/protocol/WifiConfig.d.ts +6 -0
  12. package/dist/src/protocol/tool.d.ts +9 -0
  13. package/dist/src/randomCode.d.ts +7 -0
  14. package/dist/src/request.d.ts +1 -0
  15. package/dist/src/services/devices.d.ts +53 -0
  16. package/dist/src/services/login.d.ts +8 -0
  17. package/dist/src/services/tool.d.ts +4 -0
  18. package/dist/src/sleep.d.ts +2 -0
  19. package/dist/src/socket.d.ts +107 -0
  20. package/dist/src/utils.d.ts +29 -0
  21. package/dist/src/wechatApi.d.ts +33 -0
  22. package/dist/src/wifiConfig/ConfigBase.d.ts +26 -0
  23. package/dist/src/wifiConfig/ap.d.ts +21 -0
  24. package/dist/src/wifiConfig/ble.d.ts +40 -0
  25. package/global.d.ts +28 -0
  26. package/index.ts +7 -0
  27. package/package.json +6 -3
  28. package/src/ble.ts +566 -0
  29. package/src/errorCode.ts +60 -0
  30. package/src/global.d.ts +42 -0
  31. package/src/globalData.ts +9 -0
  32. package/src/openApiRequest.ts +103 -0
  33. package/src/productConfigFileManage.ts +44 -0
  34. package/src/protocol/Bind.ts +22 -0
  35. package/src/protocol/GetDeviceStatus.ts +61 -0
  36. package/src/protocol/Login.ts +43 -0
  37. package/src/protocol/ProtocolBase.ts +53 -0
  38. package/src/protocol/WifiConfig.ts +41 -0
  39. package/src/protocol/dataPoint.ts +663 -0
  40. package/src/protocol/tool.ts +91 -0
  41. package/src/randomCode.ts +36 -0
  42. package/src/request.ts +22 -0
  43. package/src/sdk.ts +811 -0
  44. package/src/services/devices.ts +210 -0
  45. package/src/services/login.ts +15 -0
  46. package/src/services/tool.ts +10 -0
  47. package/src/sleep.ts +2 -0
  48. package/src/socket.ts +449 -0
  49. package/src/utils.ts +215 -0
  50. package/src/wechatApi.ts +179 -0
  51. package/src/wifiConfig/ConfigBase.ts +183 -0
  52. package/src/wifiConfig/ap.ts +193 -0
  53. package/src/wifiConfig/ble.ts +417 -0
@@ -0,0 +1,5 @@
1
+ interface IErrorCode {
2
+ [key: string]: IError;
3
+ }
4
+ declare const errorCode: IErrorCode;
5
+ export default errorCode;
@@ -0,0 +1,2 @@
1
+ export declare function setGlobalData(key: any, value: any): void;
2
+ export declare function getGlobalData(key: any): any;
@@ -0,0 +1,9 @@
1
+ export interface IServiceResult<T> {
2
+ success: boolean;
3
+ data?: T;
4
+ err?: IError;
5
+ }
6
+ declare const openApiRequest: <T>(url: string, options: any, needToken?: boolean) => Promise<IServiceResult<T>>;
7
+ declare const siteApiRequest: <T>(url: string, options: any) => Promise<IServiceResult<T>>;
8
+ export { siteApiRequest };
9
+ export default openApiRequest;
@@ -0,0 +1,12 @@
1
+ import { IDataPointConfig } from './protocol/DataPoint';
2
+ interface IData {
3
+ [key: string]: IDataPointConfig;
4
+ }
5
+ declare class ProductConfigFileManage {
6
+ data: IData;
7
+ key: string;
8
+ init: () => Promise<void>;
9
+ getConfigFile: (pk: string) => Promise<IDataPointConfig>;
10
+ }
11
+ declare const productConfigFileManage: ProductConfigFileManage;
12
+ export default productConfigFileManage;
@@ -0,0 +1,7 @@
1
+ import ProtocolBase from "./ProtocolBase";
2
+ declare class Bind extends ProtocolBase {
3
+ passcode: string;
4
+ constructor(data: number[]);
5
+ static pack: () => number[];
6
+ }
7
+ export default Bind;
@@ -0,0 +1,52 @@
1
+ export interface IDataPointConfig {
2
+ name: string;
3
+ protocolType: 'var_len' | 'standard';
4
+ entities: IDataPointEntitie[];
5
+ }
6
+ interface IDataPointEntitie {
7
+ display_name: string;
8
+ attrs: IDataPointAttr[];
9
+ }
10
+ interface IDataPointPosition {
11
+ byte_offset: number;
12
+ unit: 'bit' | 'byte';
13
+ len: number;
14
+ bit_offset: number;
15
+ }
16
+ declare type TDataType = 'bool' | 'uint8' | 'uint16' | 'uint32' | 'binary' | 'enum' | 'number';
17
+ interface IUnitSpec {
18
+ addition: number;
19
+ max: number;
20
+ ratio: number;
21
+ min: number;
22
+ }
23
+ declare type TDataOptionType = 'status_writable' | 'status_readonly' | 'alert' | 'fault' | 'ALL';
24
+ export interface IDataPointAttr {
25
+ display_name: string;
26
+ uint_spec: IUnitSpec;
27
+ name: string;
28
+ data_type: TDataType;
29
+ position: IDataPointPosition;
30
+ type: TDataOptionType;
31
+ id: number;
32
+ enum: string[];
33
+ desc: string;
34
+ }
35
+ interface IRawData {
36
+ header: string;
37
+ len: string;
38
+ flag: string;
39
+ cmd: string;
40
+ sn: string;
41
+ action: string;
42
+ payload: string;
43
+ }
44
+ declare type messageType = 'APP2DEV' | 'DEV2APP' | 'UNKNOW';
45
+ declare const unpack: (data: number[], pk: string) => Promise<{
46
+ kvData: {};
47
+ rawData: IRawData;
48
+ message: string;
49
+ messageType: messageType;
50
+ }>;
51
+ declare const pack: (data: object, pk: string) => Promise<number[]>;
52
+ export { pack, unpack };
@@ -0,0 +1,5 @@
1
+ import ProtocolBase from "./ProtocolBase";
2
+ declare class GetDeviceStatus extends ProtocolBase {
3
+ static pack: (productKey: string, gwDid?: string, attrNames?: string[]) => Promise<number[]>;
4
+ }
5
+ export default GetDeviceStatus;
@@ -0,0 +1,12 @@
1
+ import ProtocolBase from "./ProtocolBase";
2
+ interface IPackParame {
3
+ passcode: string;
4
+ }
5
+ declare class Login extends ProtocolBase {
6
+ result: boolean;
7
+ didLength: number;
8
+ did: string;
9
+ constructor(data: number[]);
10
+ static pack: ({ passcode }: IPackParame) => number[];
11
+ }
12
+ export default Login;
@@ -0,0 +1,11 @@
1
+ declare class ProtocolBase {
2
+ header: string;
3
+ len: number;
4
+ flag: number[];
5
+ cmd: string;
6
+ content: number[];
7
+ constructor(data?: number[]);
8
+ decodeLen: (arr: any) => number;
9
+ formatP0: (data: any) => void;
10
+ }
11
+ export default ProtocolBase;
@@ -0,0 +1,6 @@
1
+ import ProtocolBase from "./ProtocolBase";
2
+ declare class WifiConfig extends ProtocolBase {
3
+ constructor(data: number[]);
4
+ static pack: (ssid: string, password: string) => Uint8Array;
5
+ }
6
+ export default WifiConfig;
@@ -0,0 +1,9 @@
1
+ declare const checkHeader: (data: any) => number | false;
2
+ declare const getProtocolLen: (data: any) => number;
3
+ declare function arrayToString(arr: number[]): string;
4
+ declare const fillString: (string: string, num: number, foot?: boolean) => string;
5
+ declare const string2Bytes: (str: string) => number[];
6
+ declare const hexStrint2byte: (str: string) => number[];
7
+ declare const formatCode: (str: any) => number[];
8
+ declare const formatCodesFromStr: (str: string) => number[][];
9
+ export { checkHeader, getProtocolLen, arrayToString, fillString, string2Bytes, hexStrint2byte, formatCodesFromStr, formatCode };
@@ -0,0 +1,7 @@
1
+ interface IGetRandomCodes {
2
+ SSID: string;
3
+ password: string;
4
+ pks: string[];
5
+ }
6
+ declare const getRandomCodes: ({ SSID, password, pks }: IGetRandomCodes) => string[];
7
+ export default getRandomCodes;
@@ -0,0 +1 @@
1
+ export default function request<T>(url: string, options: any): Promise<T>;
@@ -0,0 +1,53 @@
1
+ import { IServiceResult } from '../openApiRequest';
2
+ import { IRandomCodesResult } from '../sdk';
3
+ export interface IOpenApiDevice {
4
+ product_key: string;
5
+ did: string;
6
+ mac: string;
7
+ passcode: string;
8
+ is_online: boolean;
9
+ host: string;
10
+ port: string;
11
+ port_s: string;
12
+ ws_port: number;
13
+ wss_port: number;
14
+ dev_alias: string;
15
+ remark: string;
16
+ type: 'normal' | 'center_control' | 'sub_dev';
17
+ }
18
+ export declare const getBindingList: () => Promise<IServiceResult<IDevice[]>>;
19
+ export interface IBindMacParams {
20
+ mac: string;
21
+ productKey: string;
22
+ productSecret: string;
23
+ alias?: string;
24
+ beOwner?: boolean;
25
+ }
26
+ export declare function bindMac({ mac, productKey, productSecret, alias, beOwner, }: IBindMacParams): Promise<IServiceResult<IOpenApiDevice>>;
27
+ export interface IUnbindReturn {
28
+ failed: string[];
29
+ success: string[];
30
+ }
31
+ export declare function unbindDevice({ devices, }: {
32
+ devices: IDevice[];
33
+ }): Promise<IServiceResult<IUnbindReturn>>;
34
+ interface ICheckDeviceRegisterParams {
35
+ SSID: string;
36
+ password: string;
37
+ productKeys: string[];
38
+ }
39
+ export declare function checkDeviceRegister({ SSID, password, productKeys, }: ICheckDeviceRegisterParams): Promise<IServiceResult<IRandomCodesResult[]>>;
40
+ interface ISafeRegisterParams {
41
+ productKey: string;
42
+ productSecret: string;
43
+ mac: string;
44
+ passcode: string;
45
+ gwDid?: string;
46
+ isReset: boolean;
47
+ }
48
+ export interface ISafeRegisterReturn {
49
+ successDevices: IDevice[];
50
+ failedDevices: IDevice[];
51
+ }
52
+ export declare function safeRegister({ productKey, productSecret, mac, passcode, gwDid, isReset, }: ISafeRegisterParams): Promise<IServiceResult<ISafeRegisterReturn>>;
53
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface ILoginRes {
2
+ expire_at: number;
3
+ token: string;
4
+ uid: string;
5
+ }
6
+ export declare function AnonymousLogin({ uid }: {
7
+ uid: string;
8
+ }): Promise<import("../openApiRequest").IServiceResult<ILoginRes>>;
@@ -0,0 +1,4 @@
1
+ export declare const psKeySign: (productSecret: string) => {
2
+ Signature: string;
3
+ timestamp: number;
4
+ };
@@ -0,0 +1,2 @@
1
+ declare const sleep: (time: number) => Promise<void>;
2
+ export default sleep;
@@ -0,0 +1,107 @@
1
+ interface IRespError {
2
+ err?: IError;
3
+ }
4
+ interface ICommonProps {
5
+ appID: string;
6
+ token: string;
7
+ uid: string;
8
+ }
9
+ interface IGWSProps extends ICommonProps {
10
+ limitSocketNum?: boolean;
11
+ }
12
+ export default class GizwitsWS {
13
+ appID: string;
14
+ token: string;
15
+ uid: string;
16
+ _maxSocketNum: number;
17
+ _bindingDevices: {
18
+ [did: string]: IDevice;
19
+ } | null;
20
+ _connections: {
21
+ [wsInfo: string]: Connection;
22
+ };
23
+ _onDeviceStatusChanged?: IOnDeviceStatusChanged;
24
+ constructor({ appID, token, uid, limitSocketNum, }: IGWSProps);
25
+ init(): Promise<IError>;
26
+ _getDevice: (did: string) => IDevice | IError;
27
+ _getConnect: (device: IDevice) => Connection;
28
+ _getDeviceAndConnect: (did: string) => IError | [IDevice, Connection];
29
+ connectDevice: (device: IDevice) => {
30
+ success: boolean;
31
+ errorCode: IError;
32
+ } | {
33
+ success: boolean;
34
+ errorCode?: undefined;
35
+ };
36
+ connect: (did: string) => IError;
37
+ send: (did: string, raw: Uint8Array[]) => IError | Promise<WechatMiniprogram.GeneralCallbackResult>;
38
+ writeData: (device: IDevice, attrs: ICommonObj) => {
39
+ success: boolean;
40
+ };
41
+ write: (did: string, attrs: ICommonObj) => IError | Promise<WechatMiniprogram.GeneralCallbackResult>;
42
+ readStatus: (device: IDevice, names?: string[]) => {
43
+ success: boolean;
44
+ };
45
+ read: (did: string, names?: string[]) => IError | Promise<WechatMiniprogram.GeneralCallbackResult>;
46
+ close: () => void;
47
+ subscribeDeviceStatus: (cb: IOnDeviceStatusChanged) => void;
48
+ _handleDeviceStatusChanged: IOnDeviceStatusChanged;
49
+ _getBindingList: (limit?: number, skip?: number, cacheList?: IDevice[]) => Promise<IDevice[] | IRespError>;
50
+ _getWebsocketConnInfo: (device: any) => "wss://wxstage.gizwits.com" | "wss://wxm2m.gizwits.com";
51
+ }
52
+ interface IConnectProps extends ICommonProps {
53
+ wsInfo: string;
54
+ onDeviceStatusChanged?: IOnDeviceStatusChanged;
55
+ }
56
+ export declare class Connection {
57
+ ready: boolean;
58
+ appID: string;
59
+ token: string;
60
+ uid: string;
61
+ commType: string;
62
+ _heartbeatInterval: number;
63
+ _keepaliveTime: number;
64
+ _loginIntveral: number;
65
+ autoSubscribe: boolean;
66
+ _wsUrl: string;
67
+ _websocket: WechatMiniprogram.SocketTask | null;
68
+ _heartbeatTimerId?: any;
69
+ _loginFailedTimes: number;
70
+ _subDids: Set<string>;
71
+ _socketRespHandleMap: {
72
+ [cmd: string]: (resp?: any) => void;
73
+ };
74
+ _onDeviceStatusChanged?: IOnDeviceStatusChanged;
75
+ constructor({ appID, token, uid, wsInfo, onDeviceStatusChanged, }: IConnectProps);
76
+ _addSubDid: (did: any) => void;
77
+ _connectWS: () => void;
78
+ _subDevices: (dids: string[]) => void;
79
+ _send: (data: object, forced?: boolean) => Promise<WechatMiniprogram.GeneralCallbackResult>;
80
+ close: () => void;
81
+ handleClose: (res: {
82
+ code: number;
83
+ reason: string;
84
+ }) => void;
85
+ handleOpen: () => void;
86
+ handleMessage: ({ data }: {
87
+ data: string | ArrayBuffer;
88
+ }) => void;
89
+ handleError: (err: {
90
+ errMsg: string;
91
+ }) => void;
92
+ _login: () => void;
93
+ _tryLoginAgain: () => void;
94
+ _startPing: () => void;
95
+ _stopPing: () => void;
96
+ pongResp: () => void;
97
+ _loginResp: (data: any) => void;
98
+ _subscribeResp: (data: any) => void;
99
+ _onlineResp: (data: {
100
+ did: string;
101
+ online: boolean;
102
+ }) => void;
103
+ _rawChangedResp: (data: IDeviceRawStatusChangedProps) => void;
104
+ _statusChangedResp: (data: IDeviceStatusChangedProps) => void;
105
+ _invalidMsgResp: (data: any) => void;
106
+ }
107
+ export {};
@@ -0,0 +1,29 @@
1
+ import { IProductInfo } from './sdk';
2
+ export declare function ab2hex(buffer: ArrayBuffer): any;
3
+ export declare function compareWXSDKVersion(v1: string, v2: string): 0 | 1 | -1;
4
+ export declare const isError: (err: unknown) => err is IError;
5
+ export declare const wrapErrorInfo: (errorMessage: string) => {
6
+ errorCode: string;
7
+ errorMessage: string;
8
+ };
9
+ export declare const unionBy: <T>(array: T[], key: string) => T[];
10
+ interface IWXDevicesResult {
11
+ success: true;
12
+ bleDevices: WechatMiniprogram.BlueToothDevice[];
13
+ }
14
+ export declare function isWXDevicesResult(res: unknown): res is IWXDevicesResult;
15
+ export declare function str2Buf(arr: string): ArrayBuffer;
16
+ export declare const numberArray2Uint8Array: (numArr: number[]) => Uint8Array;
17
+ export declare const advertisData2PkAndMac: (advertisData: ArrayBuffer, pks: string[]) => {
18
+ productKey: any;
19
+ mac: any;
20
+ };
21
+ export declare const isSameDevice: (deviceA: IDevice, deviceB: IDevice) => boolean;
22
+ export declare const merageBleLocalDevices: (mainDevice: IDevice[], localDevice: IDevice[]) => IDevice[];
23
+ export declare const merageLanLocalDevices: (mainDevice: IDevice[], localDevice: IDevice[]) => IDevice[];
24
+ export declare const BTDevice2GDevice: (BTDevice: WechatMiniprogram.BlueToothDevice, pks: string[]) => IDevice;
25
+ export declare const getFirstConnectType: (device: IDevice, type?: TConnectType) => TConnectType;
26
+ export declare const getProductInfoThroughPK: (pk: string, productInfos: IProductInfo[]) => IProductInfo;
27
+ export declare const mergeObject: (obj1: any, obj2: any) => any;
28
+ export declare function hex2ab(str: any): Uint8Array;
29
+ export {};
@@ -0,0 +1,33 @@
1
+ interface IBluetoothAdapterStateResult {
2
+ discovering: boolean;
3
+ available: boolean;
4
+ }
5
+ interface IWechatResult {
6
+ errMsg: string;
7
+ errCode: number;
8
+ }
9
+ export declare function openBluetoothAdapter(): Promise<IWechatResult>;
10
+ export declare function closeBluetoothAdapter(): Promise<IWechatResult>;
11
+ export declare function getBluetoothAdapterState(): Promise<IBluetoothAdapterStateResult>;
12
+ export declare function startBluetoothDevicesDiscovery(): Promise<IWechatResult>;
13
+ export declare function getBluetoothDevices(): Promise<WechatMiniprogram.BlueToothDevice[]>;
14
+ export declare function createBLEConnection(deviceId: string, timeout: number): Promise<IWechatResult>;
15
+ interface IBLEService {
16
+ uuid: string;
17
+ isPrimary: boolean;
18
+ }
19
+ export declare function getBLEDeviceServices(deviceId: string): Promise<IBLEService[]>;
20
+ interface IBLECharacteristic {
21
+ uuid: string;
22
+ properties: {
23
+ read: boolean;
24
+ write: boolean;
25
+ notify: boolean;
26
+ indicate: boolean;
27
+ };
28
+ }
29
+ export declare function getBLEDeviceCharacteristics(deviceId: string, serviceId: string): Promise<IBLECharacteristic[]>;
30
+ export declare function notifyBLECharacteristicValueChange(deviceId: string, serviceId: string, characteristicId: string, state?: boolean): Promise<IWechatResult>;
31
+ export declare function writeBLECharacteristicValue(deviceId: string, serviceId: string, characteristicId: string, value: ArrayBuffer): Promise<IWechatResult>;
32
+ export declare function unpackWriteBLECharacteristicValue(deviceId: string, serviceId: string, characteristicId: string, value: ArrayBuffer): Promise<IWechatResult>;
33
+ export {};
@@ -0,0 +1,26 @@
1
+ import { IRandomCodesResult, IResult } from "../sdk";
2
+ interface IRejectCallback {
3
+ (result: IResult<unknown>): void;
4
+ }
5
+ declare class ConfigBase {
6
+ ssid: string;
7
+ password: string;
8
+ specialProductKeys: string[];
9
+ disableSearchDevice: boolean;
10
+ specialProductKeySecrets: string[];
11
+ private timeoutHandler;
12
+ private setDeviceOnboardingDeployRej?;
13
+ constructor(ssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[]);
14
+ cleanTimeout: () => void;
15
+ stopDeviceOnboardingDeploy: () => void;
16
+ hasTimeoutHandler: (cb?: IRejectCallback) => boolean;
17
+ handleTimeout: () => void;
18
+ protected searchDevice: ({ ssid, password }: {
19
+ ssid: string;
20
+ password: string;
21
+ }) => Promise<IResult<IRandomCodesResult[]>>;
22
+ initDeviceOnboardingDeploy: (_res: any, rej: any) => void;
23
+ protected startTimeoutTimer: (timeout: number) => void;
24
+ protected bindDevices: (devices: IDevice[]) => Promise<IResult<IDevice[]>>;
25
+ }
26
+ export default ConfigBase;
@@ -0,0 +1,21 @@
1
+ import { IRandomCodesResult, IResult } from "../sdk";
2
+ import ConfigBase from "./ConfigBase";
3
+ interface configDeviceParams {
4
+ ssid: string;
5
+ password: string;
6
+ softAPSSIDPrefix: string;
7
+ }
8
+ interface ISetDeviceOnboardingDeployProps {
9
+ timeout: number;
10
+ isBind: boolean;
11
+ softAPSSIDPrefix: string;
12
+ }
13
+ declare class ApConfig extends ConfigBase {
14
+ disableSendUDP: boolean;
15
+ private sendMessageInterval;
16
+ private UDPSocketHandler;
17
+ destroy: () => void;
18
+ configDevice: ({ ssid, password, softAPSSIDPrefix }: configDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
19
+ setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
20
+ }
21
+ export default ApConfig;
@@ -0,0 +1,40 @@
1
+ import { IRandomCodesResult, IResult } from "../sdk";
2
+ import ConfigBase from "./ConfigBase";
3
+ interface IArgs {
4
+ bleDeviceId: string;
5
+ arrayBuffer: ArrayBuffer;
6
+ serviceUUIDSuffix?: string;
7
+ characteristicUUIDSuffix?: string;
8
+ }
9
+ export declare function sendBLEConfigCmd({ bleDeviceId, arrayBuffer, serviceUUIDSuffix, characteristicUUIDSuffix, }: IArgs): Promise<boolean | void>;
10
+ interface configBLEDeviceParams {
11
+ ssid: string;
12
+ password: string;
13
+ softAPSSIDPrefix?: string;
14
+ timeout: number;
15
+ }
16
+ interface ISetDeviceOnboardingDeployProps {
17
+ timeout: number;
18
+ isBind: boolean;
19
+ softAPSSIDPrefix: string;
20
+ }
21
+ declare class BLEConfig extends ConfigBase {
22
+ destroy: () => void;
23
+ isValidBleDevice: (bleDevice: WechatMiniprogram.BlueToothDevice, softAPSSIDPrefix?: string) => boolean;
24
+ enableBluetoothDevicesDescovery: () => Promise<{
25
+ success: false;
26
+ err: IError;
27
+ } | {
28
+ success: true;
29
+ }>;
30
+ enableAndGetBluetoothDevices: (softAPSSIDPrefix?: string) => Promise<{
31
+ success: false;
32
+ err: IError;
33
+ } | {
34
+ success: true;
35
+ bleDevices?: WechatMiniprogram.BlueToothDevice[];
36
+ }>;
37
+ setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
38
+ configBLEDevice: ({ ssid, password, softAPSSIDPrefix, }: configBLEDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
39
+ }
40
+ export default BLEConfig;
package/global.d.ts ADDED
@@ -0,0 +1,28 @@
1
+
2
+
3
+ declare namespace md5 {
4
+ function hex(data: any): any;
5
+ }
6
+
7
+ declare function md5(data: any): any;
8
+
9
+ type TUtf8 = {
10
+ toBytes: (data: any) => any
11
+ }
12
+
13
+ type TUtils = {
14
+ utf8: TUtf8;
15
+ }
16
+
17
+ interface ecb {
18
+ new(data: any): any;
19
+ }
20
+
21
+ type TModeOfOperation = {
22
+ ecb: ecb;
23
+ }
24
+
25
+ declare namespace aesjs {
26
+ const utils: TUtils;
27
+ const ModeOfOperation: TModeOfOperation;
28
+ }
package/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import 'miniprogram-api-typings';
2
+ import gizwitsSdk from './src/sdk';
3
+ import errorCode from './src/errorCode';
4
+ import { BleHandle } from './src/ble';
5
+
6
+ export { errorCode, BleHandle };
7
+ export default gizwitsSdk;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.0.2-beta",
4
- "description": "兼容微信蓝牙权限变更",
3
+ "version": "3.0.7",
4
+ "description": "兼容模组重置,蓝牙卡死的情况",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "test": "node_modules/mocha/bin/_mocha -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
8
8
  "testMy": "node_modules/mocha/bin/_mocha -r ts-node/register tests/utils/productConfigFileManage.spec.ts -file ./tests/setup-wx.js -timeout 60s",
9
9
  "testBle": "node_modules/mocha/bin/_mocha -r ts-node/register tests/bleConfig/sdk.ble.spec.ts -file ./tests/setup-wx.js -timeout 60s",
10
- "build": "webpack",
10
+ "build": "rm -r ./dist && webpack",
11
+ "release": "npm run build && release-it",
11
12
  "cover": "istanbul cover node_modules/mocha/bin/_mocha -- -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
12
13
  "coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
13
14
  },
@@ -37,6 +38,8 @@
37
38
  "typescript": "^3.8.3",
38
39
  "uglifyjs-webpack-plugin": "^2.2.0",
39
40
  "webpack": "^4.42.1",
41
+ "@release-it/conventional-changelog": "^2.0.0",
42
+ "release-it": "^14.2.2",
40
43
  "webpack-bundle-analyzer": "^4.5.0",
41
44
  "webpack-cli": "^3.3.11"
42
45
  },