hfs-bluetooth-adapter
Version:
海富思科技对外提供的蓝牙设备LLSyncSDK
97 lines (96 loc) • 3.41 kB
TypeScript
export type blueToothDeviceInfoType = {
deviceId: string;
name: string;
RSSI: number;
advertisData: ArrayBuffer;
advertisServiceUUIDs: Array<string>;
localName: string;
serviceData: Object;
connectable: boolean;
bindDevice: () => Promise<controlPromiseType>;
disconnectDevice: () => Promise<string>;
controlDevice?: () => Promise<any>;
controlAction?: () => Promise<any>;
authenticateConnection?: () => Promise<any>;
unbindDevice: () => Promise<any>;
openLock: () => Promise<controlPromiseType>;
closeLock: () => Promise<controlPromiseType>;
addPwd: () => Promise<controlPromiseType>;
deletePwd: () => Promise<controlPromiseType>;
addFP: () => void;
deleteFP?: () => Promise<controlPromiseType>;
addRfCard: () => Promise<controlPromiseType>;
deleteRfCard?: () => Promise<controlPromiseType>;
lockReset: () => Promise<controlPromiseType>;
getAllPwd: () => Promise<controlPromiseType>;
getHistory: () => Promise<controlPromiseType>;
on: () => void;
};
export type searchDeviceOptionsType = {
onSearch: (devices: (WechatMiniprogram.BlueToothDevice & {
productId: string;
})[]) => void;
onError: (error: WechatMiniprogram.BluetoothError | {
errMsg: string;
}) => void;
};
export type wifiType = {
SSID: string;
password: string;
};
export declare enum WifiConfStepCode {
PROTOCOL_START = "PROTOCOL_START",//开始配网
PROTOCOL_SUCCESS = "PROTOCOL_SUCCESS",//设备联网成功,设备可以访问互联网
BLE_SEND_TOKEN_START = "BLE_SEND_TOKEN_START",//开始发送 token 到设备,用于连接云端
BUSINESS_QUERY_TOKEN_STATE_SUCCESS = "BUSINESS_QUERY_TOKEN_STATE_SUCCESS",//发送 token 到设备成功,设备开始连接云端
WIFI_CONF_SUCCESS = "WIFI_CONF_SUCCESS"
}
export declare enum WifiConfStepCodeError {
PROTOCOL_FAIL = "PROTOCOL_FAIL",//设备连接失败
BLE_SEND_TOKEN_ERROR = "BLE_SEND_TOKEN_ERROR",//发送 token 到设备失败
WIFI_CONF_FAIL = "WIFI_CONF_FAIL",//配网失败
BUSINESS_DEVICE_ERROR = "BUSINESS_DEVICE_ERROR",//收到设备响应的错误
BUSINESS_INVALID_RESPONSE = "BUSINESS_INVALID_RESPONSE",//收到非法的设备响应
BUSINESS_DEVICE_CONNECT_MQTT_FAIL = "BUSINESS_DEVICE_CONNECT_MQTT_FAIL",//设备连接 MQTT 服务失败
BUSINESS_DEVICE_CONNECT_WIFI_FAIL = "BUSINESS_DEVICE_CONNECT_WIFI_FAIL",//设备连接目标 Wi-Fi 失败
BUSINESS_QUERY_BIND_TOKEN_TIMEOUT = "BUSINESS_QUERY_BIND_TOKEN_TIMEOUT"
}
export type BleComboType = {
wifiConfToken: string;
targetWifiInfo: wifiType;
onProgress: (data: {
code: WifiConfStepCode;
msg: string;
}) => void;
onError: (data: {
code: WifiConfStepCodeError;
errMsg: string;
}) => void;
onComplete: (deviceInfo: {
productId: string;
deviceName: string;
}) => void;
};
export type controlPropertyType = {
deviceData: any;
};
export type controlActionType = {
actionData: {
actionId: string;
params: any;
};
};
export type controlPromiseType = {
msg: string;
result: number | {
pwdId: number;
name: string;
pwdtype: string;
start_effective_time?: number;
end_effective_time?: number;
open_lock_time?: number;
}[];
} | {
errMsg: string;
result: number;
};