import Vnmf from '../../index' declare module '../../index' { namespace stopBluetoothDevicesDiscovery { interface Promised extends VnmfGeneral.CallbackResult { /** Success:ok,Error:Details */ errMsg: string } interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.BluetoothError) => void } } namespace startBluetoothDevicesDiscovery { interface Promised extends VnmfGeneral.CallbackResult { /** Success:ok,Error:Details */ errMsg: string } interface Option { /** Allow duplicate reporting of the same device。If you're allowed to repeat it,,then Vnmf.onBlueToothDeviceFound The method will be reported to the same device several times.,But... RSSI It's worth different.。 */ allowDuplicatesKey?: boolean /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interval between reporting devices。0 Signal to report as soon new equipment is found.,Other values are reported according to the interval of entry。 */ interval?: number /** Bluetooth Device Master to Search service It's... it's... uuid List。Some bluetooth devices will broadcast their own masters. service It's... it's... uuid。If this parameter is set,The search package is the same. uuid Bluetooth Device for Major Services。It is recommended that other bluetooth devices in the perimeter do not need to be treated filtered mainly through this parameter。 */ services?: string[] /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.BluetoothError) => void } } namespace openBluetoothAdapter { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.BluetoothError) => void } /** object.fail Returned by the callback function state Parameters(Only iOS) */ interface state { /** Unknown */ 0 /** Reseting */ 1 /** Not supported */ 2 /** Unauthorized */ 3 /** Unopened */ 4 } } namespace onBluetoothDeviceFound { /** The echo function for the event which a new device was found */ type Callback = ( result: CallbackResult, ) => void interface CallbackResult { /** Cannot initialise Evolution's mail component. */ devices: CallbackResultBlueToothDevice[] } /** Newly Searched Devices */ interface CallbackResultBlueToothDevice { /** Signal strength of the current Bluetooth device */ RSSI: number /** From the broadcast data of current Bluetooth device ManufacturerData Data segment。 */ advertisData: ArrayBuffer /** From the broadcast data of current Bluetooth device ServiceUUIDs Data segment */ advertisServiceUUIDs: string[] /** Used to distinguish equipment id */ deviceId: string /** From the broadcast data of current Bluetooth device LocalName Data segment */ localName: string /** Bluetooth Device Name,Some equipment may not be available. */ name: string /** From the broadcast data of current Bluetooth device ServiceData Data segment */ serviceData: VnmfGeneral.IAnyObject } } namespace onBluetoothAdapterStateChange { /** An echo function for bluetooth adaptor state change events */ type Callback = ( result: CallbackResult, ) => void interface CallbackResult { /** Is the bluetooth adaptor available? */ available: boolean /** Is the bluetooth adaptor in search status? */ discovering: boolean } } namespace makeBluetoothPair { interface Option { /** Bluetooth equipment id */ deviceId: string /** pin Code,Base64 Format */ pin: string /** Timeout,Units ms * @default 20000 */ timeout?: string /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.CallbackResult) => void } } namespace isBluetoothDevicePaired { interface Option { /** Bluetooth equipment id */ deviceId: string /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.CallbackResult) => void } } namespace getConnectedBluetoothDevices { interface Option { /** Bluetooth Device Master service It's... it's... uuid List */ services: string[] /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interface calls a successful echo function */ success?: (result: SuccessCallbackResult) => void } interface SuccessCallbackResult extends VnmfGeneral.CallbackResult { /** Cannot initialise Evolution's mail component. */ devices: BluetoothDeviceInfo[] /** Success:ok,Error:Details */ errMsg: string } /** _Other Organiser */ interface BluetoothDeviceInfo { /** Used to distinguish equipment id */ deviceId: string /** Bluetooth Device Name,Some equipment may not be available. */ name: string } } namespace getBluetoothDevices { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interface calls a successful echo function */ success?: (res: SuccessCallbackResult) => void } interface SuccessCallbackResult extends VnmfGeneral.CallbackResult { /** uuid The corresponding list of connected devices */ devices: SuccessCallbackResultBlueToothDevice[] /** Success:ok,Error:Details */ errMsg: string } /** uuid The corresponding list of connected devices */ interface SuccessCallbackResultBlueToothDevice extends VnmfGeneral.CallbackResult { /** Signal strength of the current Bluetooth device */ RSSI: number /** From the broadcast data of current Bluetooth device ManufacturerData Data segment。 */ advertisData: ArrayBuffer /** From the broadcast data of current Bluetooth device ServiceUUIDs Data segment */ advertisServiceUUIDs: string[] /** Used to distinguish equipment id */ deviceId: string /** From the broadcast data of current Bluetooth device LocalName Data segment */ localName: string /** Bluetooth Device Name,Some equipment may not be available. */ name: string /** From the broadcast data of current Bluetooth device ServiceData Data segment */ serviceData: VnmfGeneral.IAnyObject } } namespace getBluetoothAdapterState { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interface calls a successful echo function */ success?: (result: SuccessCallbackResult) => void } interface SuccessCallbackResult extends VnmfGeneral.CallbackResult { /** Is the bluetooth adaptor available? */ available: boolean /** Could not close temporary folder: %s */ discovering: boolean /** Success:ok,Error:Details */ errMsg: string } } namespace closeBluetoothAdapter { interface Option { /** Interface call to the end of echo function(Call successfully、Any failure will be enforced.) */ complete?: (res: VnmfGeneral.BluetoothError) => void /** Interface call failed echo function */ fail?: (res: VnmfGeneral.BluetoothError) => void /** Interface calls a successful echo function */ success?: (res: VnmfGeneral.BluetoothError) => void } } interface VnmfStatic { /** Stop searching for nearby bluetooth peripherals.。If you've found the bluetooth equipment you need, don't have to continue searching.,It is recommended that the interface be called to stop Bluetooth search.。 * @supported weapp * @example * ```tsx * Vnmf.stopBluetoothDevicesDiscovery({ * success: function (res) { * console.log(res) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.stopBluetoothDevicesDiscovery.html */ stopBluetoothDevicesDiscovery( option?: stopBluetoothDevicesDiscovery.Option, ): Promise /** Start searching for nearby bluetooth peripherals.。**This operation is more resource-intensive than the system.,Please call after searching and connecting to the device Vnmf.stopBluetoothDevicesDiscovery Method to stop searching。** * @supported weapp * @example * ```tsx * // Take, for example, the Bluetooth Smart Lantern of CVP platform.,Main Services UUID Yes. FEE7。Enter this parameter,Search only for main services UUID Yes. FEE7 Equipment in %1 * Vnmf.startBluetoothDevicesDiscovery({ * services: ['FEE7'], * success: function (res) { * console.log(res) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.startBluetoothDevicesDiscovery.html */ startBluetoothDevicesDiscovery( option: startBluetoothDevicesDiscovery.Option, ): Promise /** Initial Bluetooth Module * * **Attention.** * - Other Bluetooth Related API It has to be. Vnmf.openBluetoothAdapter Use after calling。Otherwise... API Returns error(errCode=10000)。 * - If the user bluetooth switch is not turned on or if cell does support function,Call Vnmf.openBluetoothAdapter Listen to changes in the bluetooth status of cell phone.,You can also call all the bluetooth modules.API。 * @supported weapp * @example * ```tsx * Vnmf.openBluetoothAdapter({ * success: function (res) { * console.log(res) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html */ openBluetoothAdapter(option?: openBluetoothAdapter.Option): Promise /** Listen to the event of finding a new device * * **Attention.** * - If you're here, Vnmf.onBluetoothDeviceFound Called back some equipment.,This device will be added to Vnmf.getBluetoothDevices The array that the interface captures。 * - Part of Andre's aircraft requires location clearance to search the device.,We need to see if we've got location access. * @supported weapp * @example * ```tsx * // ArrayBufferTurn.16Progress String Example * function ab2hex(buffer) { * var hexArr = Array.prototype.map.call( * new Uint8Array(buffer), * function(bit) { * return ('00' + bit.toString(16)).slice(-2) * } * ) * return hexArr.join(''); * } * Vnmf.onBluetoothDeviceFound(function (res) { * var devices = res.devices; * console.log('new device list has founded') * console.dir(devices) * console.log(ab2hex(devices[0].advertisData)) * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html */ onBluetoothDeviceFound( /** The echo function for the event which a new device was found */ callback: onBluetoothDeviceFound.Callback, ): void /** Listen to the bluetooth adaptor state change event * @supported weapp * @example * ```tsx * Vnmf.onBluetoothAdapterStateChange(function (res) { * console.log('adapterState changed, now is', res) * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothAdapterStateChange.html */ onBluetoothAdapterStateChange( /** An echo function for bluetooth adaptor state change events */ callback: onBluetoothAdapterStateChange.Callback, ): void /** Disable bugging of new devices * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothDeviceFound.html */ offBluetoothDeviceFound( /** The echo function for the event which a new device was found */ callback: onBluetoothDeviceFound.Callback, ): void /** Disable listening to bluetooth adaptor state change events * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothAdapterStateChange.html */ offBluetoothAdapterStateChange( /** An echo function for bluetooth adaptor state change events */ callback: onBluetoothAdapterStateChange.Callback, ): void /** Bluetooth Matching Interface,Andre only supported it. * * As a rule.(Required Assign pin It's a code or password.)The system will take over the pairing process.,Direct Call [Vnmf.createBLEConnection](/docs/apis/device/bluetooth-ble/createBLEConnection) It's fine.。The interface should be only if the developers do not want user to enter manually pin It'll be used if the code and real machine confirm that it can work properly.。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.makeBluetoothPair.html */ makeBluetoothPair(option: makeBluetoothPair.Option): Promise /** Query Bluetooth Device Matching,Andre only supported it. * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.isBluetoothDevicePaired.html */ isBluetoothDevicePaired(option: isBluetoothDevicePaired.Option): boolean /** According to uuid Retrieve connected devices。 * @supported weapp * @example * ```tsx * Vnmf.getConnectedBluetoothDevices({ * success: function (res) { * console.log(res) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getConnectedBluetoothDevices.html */ getConnectedBluetoothDevices( option: getConnectedBluetoothDevices.Option, ): Promise /** Acquisition of all Bluetooth devices found during the operation module。Including equipment already connected to the machine。 * * **Attention.** * - The list of devices acquired by this interface is as**All bluetooth devices found during the operation of Bluetooth module**,If not called in time after the end of Bluetooth module process Vnmf.closeBluetoothAdapter Release of resources,There will be bluetooth devices that call the interface and return to previous usage process.,Maybe the device is no longer with user.,Unable to connect。 * - The bluetooth device was searched.,System-backed name Fields are usually in radio packages LocalName Name of the device in field,And if you're connected to the Bluetooth device,,System-backed name Fields will be replaced with bluetooth devices. `GattName`。If you need to dynamically change the name of device and display it,Suggested `localName` Fields。 * @supported weapp * @example * ```tsx * // ArrayBufferTurn.16Progress String Example * function ab2hex(buffer) { * var hexArr = Array.prototype.map.call( * new Uint8Array(buffer), * function(bit) { * return ('00' + bit.toString(16)).slice(-2) * } * ) * return hexArr.join(''); * } * Vnmf.getBluetoothDevices({ * success: function (res) { * console.log(res) * if (res.devices[0]) { * console.log(ab2hex(res.devices[0].advertisData)) * } * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothDevices.html */ getBluetoothDevices(option?: getBluetoothDevices.Option): Promise /** Get the current bluetooth adaptor state。 * @supported weapp * @example * ```tsx * Vnmf.getBluetoothAdapterState({ * success: function (res) { * console.log(res) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothAdapterState.html */ getBluetoothAdapterState( option?: getBluetoothAdapterState.Option, ): Promise /** Close Bluetooth Module。Call this method will disconnect all established connections and release system resources。Recommended after Bluetooth process,and Vnmf.openBluetoothAdapter Call in pairs。 * @supported weapp * @example * ```tsx * Vnmf.closeBluetoothAdapter({ * success: function (res) { * console.log(res) * } * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.closeBluetoothAdapter.html */ closeBluetoothAdapter(option?: closeBluetoothAdapter.Option): Promise } }