diff --git a/docs-vitepress/.vitepress/config.ts b/docs-vitepress/.vitepress/config.ts
index 149573d16a..32658d6260 100644
--- a/docs-vitepress/.vitepress/config.ts
+++ b/docs-vitepress/.vitepress/config.ts
@@ -602,6 +602,34 @@ const sidebar: ExtendedSidebar = {
},
],
},
+ {
+ text: '相机',
+ collapsed: true,
+ items: [
+ {
+ text: 'CameraContext',
+ link: '/api-proxy/media/camera/CameraContext',
+ items: [
+ {
+ text: 'CameraContext.setZoom',
+ link: '/api-proxy/media/camera/CameraContext/setZoom',
+ },
+ {
+ text: 'CameraContext.startRecord',
+ link: '/api-proxy/media/camera/CameraContext/startRecord',
+ },
+ {
+ text: 'CameraContext.stopRecord',
+ link: '/api-proxy/media/camera/CameraContext/stopRecord',
+ },
+ {
+ text: 'CameraContext.takePhoto',
+ link: '/api-proxy/media/camera/CameraContext/takePhoto',
+ },
+ ]
+ },
+ ],
+ }
],
},
{
@@ -687,6 +715,56 @@ const sidebar: ExtendedSidebar = {
},
],
},
+ {
+ text: '蓝牙-通用',
+ collapsed: true,
+ items: [
+ {
+ text: 'openBluetoothAdapter',
+ link: '/api-proxy/device/bluetooth/openBluetoothAdapter',
+ },
+ {
+ text: 'closeBluetoothAdapter',
+ link: '/api-proxy/device/bluetooth/closeBluetoothAdapter',
+ },
+ {
+ text: 'startBluetoothDevicesDiscovery',
+ link: '/api-proxy/device/bluetooth/startBluetoothDevicesDiscovery',
+ },
+ {
+ text: 'stopBluetoothDevicesDiscovery',
+ link: '/api-proxy/device/bluetooth/stopBluetoothDevicesDiscovery',
+ },
+ {
+ text: 'onBluetoothDeviceFound',
+ link: '/api-proxy/device/bluetooth/onBluetoothDeviceFound',
+ },
+ {
+ text: 'offBluetoothDeviceFound',
+ link: '/api-proxy/device/bluetooth/offBluetoothDeviceFound',
+ },
+ {
+ text: 'getConnectedBluetoothDevices',
+ link: '/api-proxy/device/bluetooth/getConnectedBluetoothDevices',
+ },
+ {
+ text: 'getBluetoothAdapterState',
+ link: '/api-proxy/device/bluetooth/getBluetoothAdapterState',
+ },
+ {
+ text: 'onBluetoothAdapterStateChange',
+ link: '/api-proxy/device/bluetooth/onBluetoothAdapterStateChange',
+ },
+ {
+ text: 'offBluetoothAdapterStateChange',
+ link: '/api-proxy/device/bluetooth/offBluetoothAdapterStateChange',
+ },
+ {
+ text: 'getBluetoothDevices',
+ link: '/api-proxy/device/bluetooth/getBluetoothDevices',
+ },
+ ]
+ },
{
text: '蓝牙-低功耗中心设备',
collapsed: true,
@@ -703,8 +781,78 @@ const sidebar: ExtendedSidebar = {
text: 'onBLEConnectionStateChange',
link: '/api-proxy/device/bluetooth-ble/onBLEConnectionStateChange',
},
+ {
+ text: 'offBLEConnectionStateChange',
+ link: '/api-proxy/device/bluetooth-ble/offBLEConnectionStateChange',
+ },
+ {
+ text: 'writeBLECharacteristicValue',
+ link: '/api-proxy/device/bluetooth-ble/writeBLECharacteristicValue',
+ },
+ {
+ text: 'readBLECharacteristicValue',
+ link: '/api-proxy/device/bluetooth-ble/readBLECharacteristicValue',
+ },
+ {
+ text: 'notifyBLECharacteristicValueChange',
+ link: '/api-proxy/device/bluetooth-ble/notifyBLECharacteristicValueChange',
+ },
+ {
+ text: 'onBLECharacteristicValueChange',
+ link: '/api-proxy/device/bluetooth-ble/onBLECharacteristicValueChange',
+ },
+ {
+ text: 'offBLECharacteristicValueChange',
+ link: '/api-proxy/device/bluetooth-ble/offBLECharacteristicValueChange',
+ },
+ {
+ text: 'setBLEMTU',
+ link: '/api-proxy/device/bluetooth-ble/setBLEMTU',
+ },
+ {
+ text: 'getBLEDeviceRSSI',
+ link: '/api-proxy/device/bluetooth-ble/getBLEDeviceRSSI',
+ },
+ {
+ text: 'getBLEDeviceServices',
+ link: '/api-proxy/device/bluetooth-ble/getBLEDeviceServices',
+ },
+ {
+ text: 'getBLEDeviceCharacteristics',
+ link: '/api-proxy/device/bluetooth-ble/getBLEDeviceCharacteristics',
+ },
],
},
+ {
+ text: 'Wi-Fi',
+ collapsed: true,
+ items: [
+ {
+ text: 'startWifi',
+ link: '/api-proxy/device/wifi/startWifi',
+ },
+ {
+ text: 'stopWifi',
+ link: '/api-proxy/device/wifi/stopWifi',
+ },
+ {
+ text: 'getWifiList',
+ link: '/api-proxy/device/wifi/getWifiList',
+ },
+ {
+ text: 'onGetWifiList',
+ link: '/api-proxy/device/wifi/onGetWifiList',
+ },
+ {
+ text: 'offGetWifiList',
+ link: '/api-proxy/device/wifi/offGetWifiList',
+ },
+ {
+ text: 'getConnectedWifi',
+ link: '/api-proxy/device/wifi/getConnectedWifi',
+ },
+ ]
+ },
{
text: '剪贴板',
collapsed: true,
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/closeBLEConnection.md b/docs-vitepress/api-proxy/device/bluetooth-ble/closeBLEConnection.md
index d72f9d55d7..cb5ef3c855 100644
--- a/docs-vitepress/api-proxy/device/bluetooth-ble/closeBLEConnection.md
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/closeBLEConnection.md
@@ -1,8 +1,8 @@
-mpx.closeBLEConnection(Object object)
+## mpx.closeBLEConnection(Object object)
断开与蓝牙低功耗设备的连接。
-支持情况: 微信、支付宝
+支持情况: 微信、支付宝、RN
[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.closeBLEConnection.html)
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/createBLEConnection.md b/docs-vitepress/api-proxy/device/bluetooth-ble/createBLEConnection.md
index d74beb504d..1bacaed4f8 100644
--- a/docs-vitepress/api-proxy/device/bluetooth-ble/createBLEConnection.md
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/createBLEConnection.md
@@ -1,10 +1,10 @@
-mpx.createBLEConnection(Object object)
+## mpx.createBLEConnection(Object object)
连接蓝牙低功耗设备。
若小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备,无需再次进行搜索操作。
-支持情况: 微信、支付宝
+支持情况: 微信、支付宝、RN
[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html)
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceCharacteristics.md b/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceCharacteristics.md
new file mode 100644
index 0000000000..5eaf8a8590
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceCharacteristics.md
@@ -0,0 +1,130 @@
+## mpx.getBLEDeviceCharacteristics(Object object)
+
+获取蓝牙低功耗设备某个服务中所有特征 (characteristic)。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceCharacteristics.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| deviceId | string | | 是 | 蓝牙设备 id。需要已经通过 wx.createBLEConnection 建立连接 |
+| serviceId | string | | 是 | 蓝牙服务 UUID。需要先调用 wx.getBLEDeviceServices 获取 |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)|
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | characteristics |
+ Array.<Object> |
+ 设备特征列表 |
+ ✓ |
+ ✓ |
+
+
+
+
+
+
+ | 结构属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | uuid |
+ string |
+ 蓝牙设备特征的 UUID |
+ ✓ |
+ ✓ |
+
+
+ | properties |
+ Object |
+ 该特征支持的操作类型 |
+ ✓ |
+ ✓ |
+
+
+
+
+
+
+ | 结构属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+ | read | boolean | 该特征是否支持 read 操作 | ✓ | ✓ |
+ | write | boolean | 该特征是否支持 write 操作 | ✓ | ✓ |
+ | notify | boolean | 该特征是否支持 notify 操作 | ✓ | ✓ |
+ | indicate | boolean | 该特征是否支持 indicate 操作 | ✓ | ✓ |
+ | writeNoResponse | boolean | 该特征是否支持无回复写操作 | ✓ | ✓ |
+ | writeDefault | boolean | 该特征是否支持有回复写操作 | ✓ | ✗ |
+
+
+ |
+
+
+
+ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.getBLEDeviceCharacteristics({
+ // 这里的 deviceId 需要已经通过 wx.createBLEConnection 与对应设备建立链接
+ deviceId,
+ // 这里的 serviceId 需要在 wx.getBLEDeviceServices 接口中获取
+ serviceId,
+ success (res) {
+ console.log('device getBLEDeviceCharacteristics:', res.characteristics)
+ }
+})
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceRSSI.md b/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceRSSI.md
new file mode 100644
index 0000000000..1e6c0ad646
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceRSSI.md
@@ -0,0 +1,26 @@
+## mpx.getBLEDeviceRSSI(Object object)
+
+获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| deviceId | string | | 是 | 蓝牙设备 id |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| RSSI | Number | 信号强度,单位 dBm |
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceServices.md b/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceServices.md
new file mode 100644
index 0000000000..63ead64889
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/getBLEDeviceServices.md
@@ -0,0 +1,78 @@
+## mpx.getBLEDeviceServices(Object object)
+
+获取蓝牙低功耗设备所有服务 (service)。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceServices.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| deviceId | string | | 是 | 蓝牙设备 id。需要已经通过 wx.createBLEConnection 建立连接 |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 说明 |
+
+
+
+
+ | services |
+ Array.<Object> |
+ 设备服务列表 |
+
+
+
+
+
+
+ | 结构属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+ | uuid | string | 蓝牙设备服务的 UUID | ✓ | ✓ |
+ | isPrimary | boolean | 该服务是否为主服务 | ✓ | ✗ |
+
+
+ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/notifyBLECharacteristicValueChange.md b/docs-vitepress/api-proxy/device/bluetooth-ble/notifyBLECharacteristicValueChange.md
new file mode 100644
index 0000000000..9df6b301b3
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/notifyBLECharacteristicValueChange.md
@@ -0,0 +1,61 @@
+## mpx.notifyBLECharacteristicValueChange(Object object)
+
+启用蓝牙低功耗设备特征值变化时的 notify 功能,订阅特征。注意:必须设备的特征支持 notify 或者 indicate 才可以成功调用。
+
+另外,必须先启用 `mpx.notifyBLECharacteristicValueChange` 才能监听到设备 characteristicValueChange 事件
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.notifyBLECharacteristicValueChange.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 | 最低版本 | 支付宝 | RN |
+| --- | --- | --- | --- | --- | --- | --- | --- |
+| deviceId | string | | 是 | 蓝牙设备 id | | **✓** | **✓** |
+| serviceId | string | | 是 | 蓝牙特征对应服务的 UUID | | **✓** | **✓** |
+| characteristicId | string | | 是 | 蓝牙特征的 UUID | | **✓** | **✓** |
+| state | boolean | | 是 | 是否启用 notify | | **✓** | **✓** |
+| type | string | indication | 否 | 设置特征订阅类型,有效值有 notification 和 indication | 2.4.0 | **✗** | **✗** |
+| success | function | | 否 | 接口调用成功的回调函数 | | **✓** | **✓** |
+| fail | function | | 否 | 接口调用失败的回调函数 | | **✓** | **✓** |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | **✓** | **✓** |
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.notifyBLECharacteristicValueChange({
+ state: true, // 启用 notify 功能
+ // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
+ deviceId,
+ // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
+ serviceId,
+ // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
+ characteristicId,
+ success (res) {
+ console.log('notifyBLECharacteristicValueChange success', res.errMsg)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/offBLECharacteristicValueChange.md b/docs-vitepress/api-proxy/device/bluetooth-ble/offBLECharacteristicValueChange.md
new file mode 100644
index 0000000000..e291176d13
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/offBLECharacteristicValueChange.md
@@ -0,0 +1,14 @@
+## mpx.offBLECharacteristicValueChange()
+
+移除蓝牙低功耗连接状态改变事件的监听函数
+
+
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html)
+
+### 示例代码 {#example-code}
+```js
+mpx.offBLECharacteristicValueChange()
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/offBLEConnectionStateChange.md b/docs-vitepress/api-proxy/device/bluetooth-ble/offBLEConnectionStateChange.md
new file mode 100644
index 0000000000..1f1ba6969f
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/offBLEConnectionStateChange.md
@@ -0,0 +1,21 @@
+## mpx.offBLEConnectionStateChange(function listener)
+
+移除蓝牙低功耗连接状态改变事件的监听函数
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html)
+
+### 参数 {#parameters}
+**function listener**
+
+onBLEConnectionStateChange 传入的监听函数。不传此参数则移除所有监听函数。
+
+### 示例代码 {#example-code}
+
+```js
+const listener = function (res) { console.log(res) }
+
+mpx.onBLEConnectionStateChange(listener)
+mpx.offBLEConnectionStateChange(listener)
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/onBLECharacteristicValueChange.md b/docs-vitepress/api-proxy/device/bluetooth-ble/onBLECharacteristicValueChange.md
new file mode 100644
index 0000000000..85ce3cf543
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/onBLECharacteristicValueChange.md
@@ -0,0 +1,42 @@
+## mpx.onBLECharacteristicValueChange(function listener)
+
+监听蓝牙低功耗设备的特征值变化事件。必须先调用 [mpx.notifyBLECharacteristicValueChange](/api-proxy/device/bluetooth-ble/onBLEConnectionStateChange.html) 接口才能接收到设备推送的 notification。
+
+支持情况: 微信、支付宝
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLECharacteristicValueChange.html)
+
+### 参数 {#parameters}
+**function listener**
+
+蓝牙低功耗设备的特征值变化事件监听函数(多次 `onBLECharacteristicValueChange` 注册时,后一次会覆盖前一次)。
+
+**参数**
+
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| deviceId | string | 蓝牙设备 id |
+| serviceId | string | 蓝牙特征对应服务的 UUID |
+| characteristicId | string | 蓝牙特征的 UUID |
+| value | ArrayBuffer | 特征最新的值 |
+
+### 示例代码 {#example-code}
+
+```js
+// ArrayBuffer转16进制字符串示例
+function ab2hex(buffer) {
+ let hexArr = Array.prototype.map.call(
+ new Uint8Array(buffer),
+ function(bit) {
+ return ('00' + bit.toString(16)).slice(-2)
+ }
+ )
+ return hexArr.join('');
+}
+mpx.onBLECharacteristicValueChange(function(res) {
+ console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`)
+ console.log(ab2hex(res.value))
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/onBLEConnectionStateChange.md b/docs-vitepress/api-proxy/device/bluetooth-ble/onBLEConnectionStateChange.md
index 4ca821ea2e..5874859a3e 100644
--- a/docs-vitepress/api-proxy/device/bluetooth-ble/onBLEConnectionStateChange.md
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/onBLEConnectionStateChange.md
@@ -1,8 +1,8 @@
-mpx.onBLEConnectionStateChange(function listener)
+## mpx.onBLEConnectionStateChange(function listener)
监听蓝牙低功耗连接状态改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等
-支持情况: 微信、支付宝
+支持情况: 微信、支付宝、RN
[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEConnectionStateChange.html)
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/readBLECharacteristicValue.md b/docs-vitepress/api-proxy/device/bluetooth-ble/readBLECharacteristicValue.md
new file mode 100644
index 0000000000..af45ad0c3a
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/readBLECharacteristicValue.md
@@ -0,0 +1,60 @@
+## mpx.readBLECharacteristicValue(Object object)
+
+读取蓝牙低功耗设备特征值的二进制数据。注意:必须设备的特征支持 read 才可以成功调用。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.readBLECharacteristicValue.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| deviceId | string | | 是 | 蓝牙设备 id |
+| serviceId | string | | 是 | 蓝牙特征对应服务的 UUID |
+| characteristicId | string | | 是 | 蓝牙特征的 UUID |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+// 必须在这里的回调才能获取
+mpx.onBLECharacteristicValueChange(function(characteristic) {
+ console.log('characteristic value comed:', characteristic)
+})
+
+mpx.readBLECharacteristicValue({
+ // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
+ deviceId,
+ // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
+ serviceId,
+ // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
+ characteristicId,
+ success (res) {
+ console.log('readBLECharacteristicValue:', res.errCode)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/setBLEMTU.md b/docs-vitepress/api-proxy/device/bluetooth-ble/setBLEMTU.md
new file mode 100644
index 0000000000..5071b949e5
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/setBLEMTU.md
@@ -0,0 +1,33 @@
+## mpx.setBLEMTU(Object object)
+
+协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU)。需在 wx.createBLEConnection 调用成功后调用。仅安卓系统 5.1 以上版本有效,iOS 因系统限制不支持。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| deviceId | string | | 是 | 蓝牙设备 id |
+| mtu | number | | 是 | 最大传输单元。设置范围为 (22,512) 区间内,单位 bytes |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| mtu | number | 最终协商的 MTU 值,与传入参数一致。安卓客户端 8.0.9 开始支持。 |
+
+### 错误 {#error}
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| mtu | number | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。 |
diff --git a/docs-vitepress/api-proxy/device/bluetooth-ble/writeBLECharacteristicValue.md b/docs-vitepress/api-proxy/device/bluetooth-ble/writeBLECharacteristicValue.md
new file mode 100644
index 0000000000..626a0a20be
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth-ble/writeBLECharacteristicValue.md
@@ -0,0 +1,147 @@
+## mpx.writeBLECharacteristicValue(Object object)
+
+向蓝牙低功耗设备特征值中写入二进制数据。注意:必须设备的特征支持 write 才可以成功调用。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html)
+
+### 参数 {#parameters}
+**Object object**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 默认值 |
+ 必填 |
+ 说明 |
+ 最低版本 |
+
+
+
+
+ | deviceId |
+ string |
+ |
+ 是 |
+ 蓝牙设备 id |
+ |
+
+
+ | serviceId |
+ string |
+ |
+ 是 |
+ 蓝牙特征对应服务的 UUID |
+ |
+
+
+ | characteristicId |
+ string |
+ |
+ 是 |
+ 蓝牙特征的 UUID |
+ |
+
+
+ | value |
+ ArrayBuffer |
+ |
+ 是 |
+ 蓝牙设备特征对应的二进制值 |
+ |
+
+
+ | writeType |
+ string |
+ |
+ 否 |
+ 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。(基础库 2.22.0 开始支持) |
+ |
+
+
+
+
+
+
+ | 合法值 |
+ 说明 |
+
+
+
+ | write | 强制回复写,不支持时报错 |
+ | writeNoResponse | 强制无回复写,不支持时报错 |
+
+
+ |
+
+
+ | success |
+ function |
+ |
+ 否 |
+ 接口调用成功的回调函数 |
+ |
+
+
+ | fail |
+ function |
+ |
+ 否 |
+ 接口调用失败的回调函数 |
+ |
+
+
+ | complete |
+ function |
+ |
+ 否 |
+ 接口调用结束的回调函数(调用成功、失败都会执行) |
+ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+// 向蓝牙设备发送一个0x00的16进制数据
+let buffer = new ArrayBuffer(1)
+let dataView = new DataView(buffer)
+dataView.setUint8(0, 0)
+
+mpx.writeBLECharacteristicValue({
+ // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
+ deviceId,
+ // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
+ serviceId,
+ // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
+ characteristicId,
+ // 这里的value是ArrayBuffer类型
+ value: buffer,
+ success (res) {
+ console.log('writeBLECharacteristicValue success', res.errMsg)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/closeBluetoothAdapter.md b/docs-vitepress/api-proxy/device/bluetooth/closeBluetoothAdapter.md
new file mode 100644
index 0000000000..c2a8eb6527
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/closeBluetoothAdapter.md
@@ -0,0 +1,86 @@
+## mpx.closeBluetoothAdapter(Object object)
+
+关闭蓝牙模块。调用该方法将断开所有已建立的连接并释放系统资源。建议在使用蓝牙流程后,与 wx.openBluetoothAdapter 成对调用。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.closeBluetoothAdapter.html)
+
+### 参数 {#parameters}
+**Object object**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 默认值 |
+ 必填 |
+ 说明 |
+ 最低版本 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | success |
+ function |
+ |
+ 否 |
+ 接口调用成功的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | fail |
+ function |
+ |
+ 否 |
+ 接口调用失败的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | complete |
+ function |
+ |
+ 否 |
+ 接口调用结束的回调函数(调用成功、失败都会执行) |
+ |
+ ✓ |
+ ✓ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.closeBluetoothAdapter({
+ success (res) {
+ console.log(res)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/getBluetoothAdapterState.md b/docs-vitepress/api-proxy/device/bluetooth/getBluetoothAdapterState.md
new file mode 100644
index 0000000000..2326b69156
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/getBluetoothAdapterState.md
@@ -0,0 +1,56 @@
+## mpx.getBluetoothAdapterState(Object object)
+
+获取本机蓝牙适配器状态。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothAdapterState.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| discovering | boolean | 是否正在搜索设备 |
+| available | boolean | 蓝牙适配器是否可用 |
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.getConnectedBluetoothDevices({
+ services: ['FEE7'],
+ success (res) {
+ console.log(res)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/getBluetoothDevices.md b/docs-vitepress/api-proxy/device/bluetooth/getBluetoothDevices.md
new file mode 100644
index 0000000000..293d8ea0d9
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/getBluetoothDevices.md
@@ -0,0 +1,109 @@
+## mpx.getBluetoothDevices(Object object)
+
+获取在蓝牙模块生效期间所有搜索到的蓝牙设备。包括已经和本机处于连接状态的设备。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothDevices.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | devices |
+ Array.<Object> |
+ 搜索到的设备列表 |
+ ✓ |
+ ✓ |
+
+
+
+
+
+
+ | 结构属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+ | name | string | 蓝牙设备名称,某些设备可能没有 | ✓ | ✓ |
+ | deviceId | string | 蓝牙设备 id | ✓ | ✓ |
+ | RSSI | number | 当前蓝牙设备的信号强度,单位 dBm | ✓ | ✓ |
+ | advertisData | ArrayBuffer | 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 | ✓ | ✓ |
+ | advertisServiceUUIDs | Array.<string> | 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 | ✗ | ✓ |
+ | localName | string | 当前蓝牙设备的广播数据段中的 LocalName 数据段 | ✓ | ✓ |
+ | serviceData | Object | 当前蓝牙设备的广播数据段中的 ServiceData 数据段 | ✗ | ✓ |
+ | connectable | boolean | 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) | ✗ | ✓ |
+
+
+ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+// ArrayBuffer转16进度字符串示例
+function ab2hex(buffer) {
+ var hexArr = Array.prototype.map.call(
+ new Uint8Array(buffer),
+ function(bit) {
+ return ('00' + bit.toString(16)).slice(-2)
+ }
+ )
+ return hexArr.join('');
+}
+mpx.getBluetoothDevices({
+ success: function (res) {
+ console.log(res)
+ if (res.devices[0]) {
+ console.log(ab2hex(res.devices[0].advertisData))
+ }
+ }
+})
+
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/getConnectedBluetoothDevices.md b/docs-vitepress/api-proxy/device/bluetooth/getConnectedBluetoothDevices.md
new file mode 100644
index 0000000000..d353da4f92
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/getConnectedBluetoothDevices.md
@@ -0,0 +1,85 @@
+## mpx.getConnectedBluetoothDevices(Object object)
+
+根据主服务 UUID 获取已连接的蓝牙设备。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getConnectedBluetoothDevices.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| services | Array.<string> | | 是 | 蓝牙设备主服务的 UUID 列表(支持 16/32/128 位 UUID) |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 说明 |
+
+
+
+
+ | devices |
+ Array.<Object> |
+ 搜索到的设备列表 |
+
+
+
+
+
+
+ | 结构属性 |
+ 类型 |
+ 说明 |
+
+
+
+ | name | string | 蓝牙设备名称,某些设备可能没有 |
+ | deviceId | string | 用于区分设备的 id |
+
+
+ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.getConnectedBluetoothDevices({
+ services: ['FEE7'],
+ success (res) {
+ console.log(res)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/offBluetoothAdapterStateChange.md b/docs-vitepress/api-proxy/device/bluetooth/offBluetoothAdapterStateChange.md
new file mode 100644
index 0000000000..ac97c681a9
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/offBluetoothAdapterStateChange.md
@@ -0,0 +1,26 @@
+## mpx.offBluetoothAdapterStateChange(function listener)
+
+移除蓝牙适配器状态变化事件的监听函数(传入 `listener` 时移除指定监听,不传时移除全部监听)。
+
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothAdapterStateChange.html)
+
+> 说明:当前实测 `onBluetoothAdapterStateChange` 可多次注册监听,支持按传入的 `listener` 单独移除;不传参数时会移除全部监听。
+
+
+### 示例代码 {#example-code}
+```js
+const listener1 = (res) => console.log('listener1', res)
+const listener2 = (res) => console.log('listener2', res)
+
+mpx.onBluetoothAdapterStateChange(listener1)
+mpx.onBluetoothAdapterStateChange(listener2)
+
+// 单独移除 listener1,listener2 仍会继续触发
+mpx.offBluetoothAdapterStateChange(listener1)
+
+// 不传参数,移除全部监听
+mpx.offBluetoothAdapterStateChange()
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/bluetooth/offBluetoothDeviceFound.md b/docs-vitepress/api-proxy/device/bluetooth/offBluetoothDeviceFound.md
new file mode 100644
index 0000000000..115289c72e
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/offBluetoothDeviceFound.md
@@ -0,0 +1,13 @@
+## mpx.offBluetoothDeviceFound(function listener)
+
+移除搜索到新设备的事件的全部监听函数
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothDeviceFound.html)
+
+
+### 示例代码 {#example-code}
+```js
+mpx.offBluetoothDeviceFound()
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/bluetooth/onBluetoothAdapterStateChange.md b/docs-vitepress/api-proxy/device/bluetooth/onBluetoothAdapterStateChange.md
new file mode 100644
index 0000000000..fe048171e4
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/onBluetoothAdapterStateChange.md
@@ -0,0 +1,28 @@
+## mpx.onBluetoothAdapterStateChange(function listener)
+
+监听蓝牙适配器状态变化事件
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothAdapterStateChange.html)
+
+### 参数 {#parameters}
+
+**function listener**
+
+蓝牙适配器状态变化事件的监听函数
+
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| available | boolean | 蓝牙适配器是否可用 |
+| discovering | boolean | 蓝牙适配器是否处于搜索状态 |
+
+
+### 示例代码 {#example-code}
+```js
+mpx.onBluetoothAdapterStateChange(function (res) {
+ console.log('adapterState changed, now is', res)
+})
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/bluetooth/onBluetoothDeviceFound.md b/docs-vitepress/api-proxy/device/bluetooth/onBluetoothDeviceFound.md
new file mode 100644
index 0000000000..202954484d
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/onBluetoothDeviceFound.md
@@ -0,0 +1,80 @@
+## mpx.onBluetoothDeviceFound(function listener)
+
+监听搜索到新设备的事件
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html)
+
+### 参数 {#parameters}
+
+**function listener**
+
+搜索到新设备的事件监听函数(多次 `onBluetoothDeviceFound` 注册时,后一次会覆盖前一次)。
+
+**Object res**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | devices |
+ Array.<Object> |
+ 新搜索到的设备列表 |
+ ✓ |
+ ✓ |
+
+
+
+
+
+
+ | 结构属性 |
+ 类型 |
+ 说明 |
+ 支付宝 |
+ RN |
+
+
+
+ | name | string | 蓝牙设备名称,某些设备可能没有 | ✓ | ✓ |
+ | deviceId | string | 蓝牙设备 id | ✓ | ✓ |
+ | RSSI | number | 当前蓝牙设备的信号强度,单位 dBm | ✓ | ✓ |
+ | advertisData | ArrayBuffer | 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 | ✓ | ✓ |
+ | advertisServiceUUIDs | Array.<string> | 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 | ✗ | ✓ |
+ | localName | string | 当前蓝牙设备的广播数据段中的 LocalName 数据段 | ✓ | ✓ |
+ | serviceData | Object | 当前蓝牙设备的广播数据段中的 ServiceData 数据段 | ✓ | ✓ |
+ | connectable | boolean | 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) | ✗ | ✓ |
+
+
+ |
+
+
+
+
+### 示例代码 {#example-code}
+```js
+function ab2hex(buffer) {
+ var hexArr = Array.prototype.map.call(
+ new Uint8Array(buffer),
+ function(bit) {
+ return ('00' + bit.toString(16)).slice(-2)
+ }
+ )
+ return hexArr.join('');
+}
+mpx.onBluetoothDeviceFound(function(res) {
+ var devices = res.devices;
+ console.log('new device list has founded')
+ console.dir(devices)
+ console.log(ab2hex(devices[0].advertisData))
+})
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/bluetooth/openBluetoothAdapter.md b/docs-vitepress/api-proxy/device/bluetooth/openBluetoothAdapter.md
new file mode 100644
index 0000000000..93eaf69053
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/openBluetoothAdapter.md
@@ -0,0 +1,112 @@
+## mpx.openBluetoothAdapter(Object object)
+
+初始化蓝牙模块。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html)
+
+### 参数 {#parameters}
+**Object object**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 默认值 |
+ 必填 |
+ 说明 |
+ 最低版本 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | mode |
+ string |
+ central |
+ 否 |
+ 蓝牙模式,可作为主/从设备,仅 iOS 需要。 |
+ 2.10.0 |
+ ✗ |
+ ✗ |
+
+
+
+
+
+
+ | 合法值 |
+ 说明 |
+
+
+
+ | central | 主机模式 |
+ | peripheral | 从机(外围设备)模式 |
+
+
+ |
+
+
+ | success |
+ function |
+ |
+ 否 |
+ 接口调用成功的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | fail |
+ function |
+ |
+ 否 |
+ 接口调用失败的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | complete |
+ function |
+ |
+ 否 |
+ 接口调用结束的回调函数(调用成功、失败都会执行) |
+ |
+ ✓ |
+ ✓ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.openBluetoothAdapter({
+ success (res) {
+ console.log(res)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/startBluetoothDevicesDiscovery.md b/docs-vitepress/api-proxy/device/bluetooth/startBluetoothDevicesDiscovery.md
new file mode 100644
index 0000000000..1a0d07eaa4
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/startBluetoothDevicesDiscovery.md
@@ -0,0 +1,146 @@
+## mpx.startBluetoothDevicesDiscovery(Object object)
+
+开始搜寻附近的蓝牙外围设备。
+
+此操作比较耗费系统资源,请在搜索到需要的设备后及时调用 [wx.stopBluetoothDevicesDiscovery](/api-proxy/device/bluetooth/stopBluetoothDevicesDiscovery.md) 停止搜索。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.startBluetoothDevicesDiscovery.html)
+
+### 参数 {#parameters}
+**Object object**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 默认值 |
+ 必填 |
+ 说明 |
+ 最低版本 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | services |
+ Array.<string> |
+ |
+ 否 |
+ 要搜索的蓝牙设备主服务的 UUID 列表(支持 16/32/128 位 UUID)。某些蓝牙设备会广播自己的主 service 的 UUID。如果设置此参数,则只搜索广播包有对应 UUID 的主服务的蓝牙设备。建议通过该参数过滤掉周边不需要处理的其他蓝牙设备。 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | allowDuplicatesKey |
+ boolean |
+ false |
+ 否 |
+ 是否允许重复上报同一设备。如果允许重复上报,则 wx.onBlueToothDeviceFound 方法会多次上报同一设备,但是 RSSI 值会有不同。 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | interval |
+ number |
+ 0 |
+ 否 |
+ 上报设备的间隔,单位 ms。0 表示找到新设备立即上报,其他数值根据传入的间隔上报。 |
+ |
+ ✓ |
+ ✗ |
+
+
+ | powerLevel |
+ string |
+ medium |
+ 否 |
+ 扫描模式,越高扫描越快,也越耗电。仅安卓微信客户端 7.0.12 及以上支持。 |
+ |
+ ✗ |
+ ✗ |
+
+
+
+
+
+
+ | 合法值 |
+ 说明 |
+
+
+
+ | low | 低 |
+ | medium | 中 |
+ | high | 高 |
+
+
+ |
+
+
+ | success |
+ function |
+ |
+ 否 |
+ 接口调用成功的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | fail |
+ function |
+ |
+ 否 |
+ 接口调用失败的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | complete |
+ function |
+ |
+ 否 |
+ 接口调用结束的回调函数(调用成功、失败都会执行) |
+ |
+ ✓ |
+ ✓ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.startBluetoothDevicesDiscovery({
+ services: ['FEE7'],
+ success (res) {
+ console.log(res)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/bluetooth/stopBluetoothDevicesDiscovery.md b/docs-vitepress/api-proxy/device/bluetooth/stopBluetoothDevicesDiscovery.md
new file mode 100644
index 0000000000..713c09918b
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/bluetooth/stopBluetoothDevicesDiscovery.md
@@ -0,0 +1,86 @@
+## mpx.stopBluetoothDevicesDiscovery(Object object)
+
+停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.stopBluetoothDevicesDiscovery.html)
+
+### 参数 {#parameters}
+**Object object**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 默认值 |
+ 必填 |
+ 说明 |
+ 最低版本 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | success |
+ function |
+ |
+ 否 |
+ 接口调用成功的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | fail |
+ function |
+ |
+ 否 |
+ 接口调用失败的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | complete |
+ function |
+ |
+ 否 |
+ 接口调用结束的回调函数(调用成功、失败都会执行) |
+ |
+ ✓ |
+ ✓ |
+
+
+
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | **✗** | **✓** |
+| -1 | already connect | 已连接 | **✗** | **✗** |
+| 10000 | not init | 未初始化蓝牙适配器 | **✓** | **✓** |
+| 10001 | not available | 当前蓝牙适配器不可用 | **✓** | **✗** |
+| 10002 | no device | 没有找到指定设备 | **✓** | **✗** |
+| 10003 | connection fail | 连接失败 | **✓** | **✗** |
+| 10004 | no service | 没有找到指定服务 | **✓** | **✗** |
+| 10005 | no characteristic | 没有找到指定特征 | **✓** | **✗** |
+| 10006 | no connection | 当前连接已断开 | **✓** | **✗** |
+| 10007 | property not support | 当前特征不支持此操作 | **✓** | **✗** |
+| 10008 | system error | 其余所有系统上报的异常 | **✓** | **✗** |
+| 10009 | system not support | Android 系统特有,系统版本低于 4.3 不支持 BLE | **✓** | **✗** |
+| 10012 | operate time out | 连接超时 | **✓** | **✗** |
+| 10013 | invalid_data | 连接 deviceId 为空或者是格式不正确 | **✓** | **✗** |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.stopBluetoothDevicesDiscovery({
+ success (res) {
+ console.log(res)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/wifi/getConnectedWifi.md b/docs-vitepress/api-proxy/device/wifi/getConnectedWifi.md
new file mode 100644
index 0000000000..b616cacd5e
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/wifi/getConnectedWifi.md
@@ -0,0 +1,47 @@
+## mpx.getConnectedWifi(Object object)
+
+获取已连接中的 Wi-Fi 信息。
+
+支持情况: 微信、支付宝、RN(仅支持android)
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getConnectedWifi.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 | 最低版本 | 支付宝 | RN |
+| --- | --- | --- | --- | --- | --- | --- | --- |
+| partialInfo | boolean | false | 否 | 是否需要返回部分 Wi-Fi 信息 | 2.22.0 | ✗ | ✓ |
+| success | function | | 否 | 接口调用成功的回调函数 | | ✓ | ✓ |
+| fail | function | | 否 | 接口调用失败的回调函数 | | ✓ | ✓ |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)| | ✓ | ✓ |
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| wifi | [WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html) | Wi-Fi 信息 |
+
+**提示:** WifiInfo 中的 `secure` 字段在 RN 平台不支持。
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | ✓ | ✓ |
+| 12000 | not init | 未先调用 startWifi 接口 | ✓ | ✓ |
+| 12001 | system not support | 当前系统不支持相关能力 | ✓ | ✓ |
+| 12002 | password error Wi-Fi | 密码错误 | ✓ | ✗ |
+| 12003 | connection timeout | 连接超时, 仅 Android 支持 | ✓ | ✗ |
+| 12004 | duplicate request | 重复连接 Wi-Fi | ✓ | ✗ |
+| 12005 | wifi not turned on | Android 特有,未打开 Wi-Fi 开关 | ✓ | ✓ |
+| 12006 | gps not turned on | Android 特有,未打开 GPS 定位开关 | ✓ | ✗ |
+| 12007 | user denied | 用户拒绝授权链接 Wi-Fi | ✓ | ✗ |
+| 12008 | invalid SSID | 无效 SSID | ✓ | ✗ |
+| 12009 | system config err | 系统运营商配置拒绝连接 Wi-Fi | ✓ | ✗ |
+| 12010 | system internal error | 系统其他错误,需要在 errmsg 打印具体的错误原因 | ✓ | ✗ |
+| 12011 | weapp in background | 应用在后台无法配置 Wi-Fi | ✓ | ✗ |
+| 12013 | wifi config may be expired | 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 | ✓ | ✗ |
+| 12014 | invalid WEP / WPA password | iOS 特有,无效的 WEP / WPA 密码 | ✓ | ✗ |
diff --git a/docs-vitepress/api-proxy/device/wifi/getWifiList.md b/docs-vitepress/api-proxy/device/wifi/getWifiList.md
new file mode 100644
index 0000000000..8dab397d9d
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/wifi/getWifiList.md
@@ -0,0 +1,36 @@
+## mpx.getWifiList(Object object)
+
+请求获取 Wi-Fi 列表。
+
+支持情况: 微信、支付宝、RN(仅支持android)
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getWifiList.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)|
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | ✓ | ✓ |
+| 12000 | not init | 未先调用 startWifi 接口 | ✓ | ✓ |
+| 12001 | system not support | 当前系统不支持相关能力 | ✓ | ✓ |
+| 12002 | password error Wi-Fi | 密码错误 | ✓ | ✗ |
+| 12003 | connection timeout | 连接超时, 仅 Android 支持 | ✓ | ✗ |
+| 12004 | duplicate request | 重复连接 Wi-Fi | ✓ | ✗ |
+| 12005 | wifi not turned on | Android 特有,未打开 Wi-Fi 开关 | ✓ | ✓ |
+| 12006 | gps not turned on | Android 特有,未打开 GPS 定位开关 | ✓ | ✗ |
+| 12007 | user denied | 用户拒绝授权链接 Wi-Fi | ✓ | ✗ |
+| 12008 | invalid SSID | 无效 SSID | ✓ | ✗ |
+| 12009 | system config err | 系统运营商配置拒绝连接 Wi-Fi | ✓ | ✗ |
+| 12010 | system internal error | 系统其他错误,需要在 errmsg 打印具体的错误原因 | ✓ | ✗ |
+| 12011 | weapp in background | 应用在后台无法配置 Wi-Fi | ✓ | ✗ |
+| 12013 | wifi config may be expired | 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 | ✓ | ✗ |
+| 12014 | invalid WEP / WPA password | iOS 特有,无效的 WEP / WPA 密码 | ✓ | ✗ |
diff --git a/docs-vitepress/api-proxy/device/wifi/offGetWifiList.md b/docs-vitepress/api-proxy/device/wifi/offGetWifiList.md
new file mode 100644
index 0000000000..c3b3adf636
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/wifi/offGetWifiList.md
@@ -0,0 +1,23 @@
+## mpx.offGetWifiList(function listener)
+
+移除获取到 Wi-Fi 列表数据事件的监听函数
+
+支持情况: 微信、支付宝、RN(仅支持android)
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offGetWifiList.html)
+
+### 参数 {#parameters}
+
+**function listener**
+
+移除当前生效的监听函数(当前实现仅保留最后一次 `onGetWifiList` 注册的函数,不支持无参移除全部监听)。
+
+> 说明:以上为当前实测行为,与微信文档中“可按传入函数移除,或无参移除全部监听”的描述不一致。
+
+### 示例代码 {#example-code}
+```js
+const listener = function (res) { console.log(res) }
+
+mpx.onGetWifiList(listener)
+mpx.offGetWifiList(listener) // 传入当前生效的监听函数
+```
\ No newline at end of file
diff --git a/docs-vitepress/api-proxy/device/wifi/onGetWifiList.md b/docs-vitepress/api-proxy/device/wifi/onGetWifiList.md
new file mode 100644
index 0000000000..2217c85faf
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/wifi/onGetWifiList.md
@@ -0,0 +1,21 @@
+## mpx.onGetWifiList(function listener)
+
+监听获取到 Wi-Fi 列表数据事件
+
+支持情况: 微信、支付宝、RN(仅支持android)
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html)
+
+### 参数 {#parameters}
+
+**function listener**
+
+获取到 Wi-Fi 列表数据事件的监听函数(当前实现多次 `onGetWifiList` 注册会覆盖前一次,仅保留最后一次)。
+
+> 说明:以上为当前实测行为,与微信文档中“可同时注册多个监听函数”的常见理解不一致。
+
+**Object res**
+
+| 属性 | 类型 | 说明 |
+| --- | --- | --- |
+| wifiList | Array.<[WifiInfo](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/WifiInfo.html)> | Wi-Fi 列表数据 |
diff --git a/docs-vitepress/api-proxy/device/wifi/startWifi.md b/docs-vitepress/api-proxy/device/wifi/startWifi.md
new file mode 100644
index 0000000000..ed0c114151
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/wifi/startWifi.md
@@ -0,0 +1,46 @@
+## mpx.startWifi(Object object)
+
+初始化 Wi-Fi 模块。
+
+支持情况: 微信、支付宝、RN(仅支持android)
+
+[参考文档](http://localhost:5173/api-proxy/device/wifi/startWifi.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)|
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | ✓ | ✓ |
+| 12000 | not init | 未先调用 startWifi 接口 | ✓ | ✓ |
+| 12001 | system not support | 当前系统不支持相关能力 | ✓ | ✓ |
+| 12002 | password error Wi-Fi | 密码错误 | ✓ | ✗ |
+| 12003 | connection timeout | 连接超时, 仅 Android 支持 | ✓ | ✗ |
+| 12004 | duplicate request | 重复连接 Wi-Fi | ✓ | ✗ |
+| 12005 | wifi not turned on | Android 特有,未打开 Wi-Fi 开关 | ✓ | ✓ |
+| 12006 | gps not turned on | Android 特有,未打开 GPS 定位开关 | ✓ | ✗ |
+| 12007 | user denied | 用户拒绝授权链接 Wi-Fi | ✓ | ✗ |
+| 12008 | invalid SSID | 无效 SSID | ✓ | ✗ |
+| 12009 | system config err | 系统运营商配置拒绝连接 Wi-Fi | ✓ | ✗ |
+| 12010 | system internal error | 系统其他错误,需要在 errmsg 打印具体的错误原因 | ✓ | ✗ |
+| 12011 | weapp in background | 应用在后台无法配置 Wi-Fi | ✓ | ✗ |
+| 12013 | wifi config may be expired | 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 | ✓ | ✗ |
+| 12014 | invalid WEP / WPA password | iOS 特有,无效的 WEP / WPA 密码 | ✓ | ✗ |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.startWifi({
+ success (res) {
+ console.log(res.errMsg)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/device/wifi/stopWifi.md b/docs-vitepress/api-proxy/device/wifi/stopWifi.md
new file mode 100644
index 0000000000..371daebb5b
--- /dev/null
+++ b/docs-vitepress/api-proxy/device/wifi/stopWifi.md
@@ -0,0 +1,46 @@
+## mpx.stopWifi(Object object)
+
+关闭 Wi-Fi 模块。
+
+支持情况: 微信、支付宝、RN(仅支持android)
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.stopWifi.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)|
+
+### 错误 {#error}
+
+| 错误码 | 错误信息 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| 0 | ok | 正常 | ✓ | ✓ |
+| 12000 | not init | 未先调用 startWifi 接口 | ✓ | ✓ |
+| 12001 | system not support | 当前系统不支持相关能力 | ✓ | ✓ |
+| 12002 | password error Wi-Fi | 密码错误 | ✓ | ✗ |
+| 12003 | connection timeout | 连接超时, 仅 Android 支持 | ✓ | ✗ |
+| 12004 | duplicate request | 重复连接 Wi-Fi | ✓ | ✗ |
+| 12005 | wifi not turned on | Android 特有,未打开 Wi-Fi 开关 | ✓ | ✓ |
+| 12006 | gps not turned on | Android 特有,未打开 GPS 定位开关 | ✓ | ✗ |
+| 12007 | user denied | 用户拒绝授权链接 Wi-Fi | ✓ | ✗ |
+| 12008 | invalid SSID | 无效 SSID | ✓ | ✗ |
+| 12009 | system config err | 系统运营商配置拒绝连接 Wi-Fi | ✓ | ✗ |
+| 12010 | system internal error | 系统其他错误,需要在 errmsg 打印具体的错误原因 | ✓ | ✗ |
+| 12011 | weapp in background | 应用在后台无法配置 Wi-Fi | ✓ | ✗ |
+| 12013 | wifi config may be expired | 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 | ✓ | ✗ |
+| 12014 | invalid WEP / WPA password | iOS 特有,无效的 WEP / WPA 密码 | ✓ | ✗ |
+
+### 示例代码 {#example-code}
+
+```js
+mpx.stopWifi({
+ success (res) {
+ console.log(res.errMsg)
+ }
+})
+```
diff --git a/docs-vitepress/api-proxy/media/camera/CameraContext/index.md b/docs-vitepress/api-proxy/media/camera/CameraContext/index.md
new file mode 100644
index 0000000000..6ebf948a5d
--- /dev/null
+++ b/docs-vitepress/api-proxy/media/camera/CameraContext/index.md
@@ -0,0 +1,10 @@
+## CameraContext
+
+CameraContext 实例,可通过 `wx.createCameraContext` 获取。
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.html)
+
+说明:
+
diff --git a/docs-vitepress/api-proxy/media/camera/CameraContext/setZoom.md b/docs-vitepress/api-proxy/media/camera/CameraContext/setZoom.md
new file mode 100644
index 0000000000..08dbd7d22e
--- /dev/null
+++ b/docs-vitepress/api-proxy/media/camera/CameraContext/setZoom.md
@@ -0,0 +1,25 @@
+## CameraContext.setZoom(Object object)
+
+设置缩放级别
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.setZoom.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 |
+| --- | --- | --- | --- | --- |
+| zoom | number | | 是 | 缩放级别,范围[1, maxZoom]。zoom 可取小数,精确到小数后一位。maxZoom 可在 bindinitdone 返回值中获取。|
+| success | function | | 否 | 接口调用成功的回调函数 |
+| fail | function | | 否 | 接口调用失败的回调函数 |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)|
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| zoom | number | 实际设置的缩放级别。由于系统限制,某些机型可能无法设置成指定值,会改用最接近的可设值。| ✓ | ✗ |
diff --git a/docs-vitepress/api-proxy/media/camera/CameraContext/startRecord.md b/docs-vitepress/api-proxy/media/camera/CameraContext/startRecord.md
new file mode 100644
index 0000000000..3914fc6b7a
--- /dev/null
+++ b/docs-vitepress/api-proxy/media/camera/CameraContext/startRecord.md
@@ -0,0 +1,28 @@
+## CameraContext.startRecord(Object object)
+
+开始录像
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.startRecord.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 | 最低版本 | 支付宝 | RN |
+| --- | --- | --- | --- | --- | --- | --- | --- |
+| timeoutCallback | function | | 否 | 超过录制时长上限时会结束录像并触发此回调,录像异常退出时也会触发此回调 | | ✓ | ✓ |
+| timeout | number | 30 | 否 | 录制时长上限,单位为秒,最长不能超过 5 分钟 | 2.22.0 | ✓ | ✓ |
+| selfieMirror | boolean | true | 否 | 是否开启镜像 | 2.22.0 | ✗ | ✗ |
+| success | function | | 否 | 接口调用成功的回调函数 | | ✓ | ✓ |
+| fail | function | | 否 | 接口调用失败的回调函数 | | ✓ | ✓ |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)| | ✓ | ✓ |
+
+### object.timeoutCallback 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| tempThumbPath | string | 封面图片文件的临时路径 (本地路径) | ✓ | ✗ |
+| tempVideoPath | string | 视频的文件的临时路径 (本地路径) | ✓ | ✗ |
diff --git a/docs-vitepress/api-proxy/media/camera/CameraContext/stopRecord.md b/docs-vitepress/api-proxy/media/camera/CameraContext/stopRecord.md
new file mode 100644
index 0000000000..dc2b32cac3
--- /dev/null
+++ b/docs-vitepress/api-proxy/media/camera/CameraContext/stopRecord.md
@@ -0,0 +1,26 @@
+## CameraContext.stopRecord(Object object)
+
+开始录像
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.stopRecord.html)
+
+### 参数 {#parameters}
+**Object object**
+
+| 属性 | 类型 | 默认值 | 必填 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- | --- | --- |
+| compressed | boolean | false | 否 | 启动视频压缩,压缩效果同chooseVideo | ✗ | ✗ |
+| success | function | | 否 | 接口调用成功的回调函数 | ✓ | ✓ |
+| fail | function | | 否 | 接口调用失败的回调函数 | ✓ | ✓ |
+| complete | function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行)| ✓ | ✓ |
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 | 支付宝 | RN |
+| --- | --- | --- | --- | --- |
+| tempThumbPath | string | 封面图片文件的临时路径 (本地路径) | ✓ | ✗ |
+| tempVideoPath | string | 视频的文件的临时路径 (本地路径) | ✓ | ✓ |
diff --git a/docs-vitepress/api-proxy/media/camera/CameraContext/takePhoto.md b/docs-vitepress/api-proxy/media/camera/CameraContext/takePhoto.md
new file mode 100644
index 0000000000..b6043a7d72
--- /dev/null
+++ b/docs-vitepress/api-proxy/media/camera/CameraContext/takePhoto.md
@@ -0,0 +1,126 @@
+## CameraContext.takePhoto(Object object)
+
+开始录像
+
+支持情况: 微信、支付宝、RN
+
+[参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/CameraContext.takePhoto.html)
+
+### 参数 {#parameters}
+**Object object**
+
+
+
+
+ | 属性 |
+ 类型 |
+ 默认值 |
+ 必填 |
+ 说明 |
+ 最低版本 |
+ 支付宝 |
+ RN |
+
+
+
+
+ | quality |
+ string |
+ normal |
+ 否 |
+
+ 成像质量
+ 合法值
+
+
+
+ | 值 |
+ 说明 |
+
+
+
+
+ | high |
+ 高质量 |
+
+
+ | normal |
+ 普通质量 |
+
+
+ | low |
+ 低质量 |
+
+
+ | original |
+ 原图 |
+
+
+
+ |
+ |
+ ✓ |
+ ✓ |
+
+
+ | selfieMirror |
+ boolean |
+ true |
+ 否 |
+ 是否开启镜像 |
+ 2.22.0 |
+ ✗ |
+ ✗ |
+
+
+ | captureMetadata |
+ boolean |
+ false |
+ 否 |
+ 是否返回照片的拍摄信息 |
+ 3.15.0 |
+ ✗ |
+ ✗ |
+
+
+ | success |
+ function |
+ |
+ 否 |
+ 接口调用成功的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | fail |
+ function |
+ |
+ 否 |
+ 接口调用失败的回调函数 |
+ |
+ ✓ |
+ ✓ |
+
+
+ | complete |
+ function |
+ |
+ 否 |
+ 接口调用结束的回调函数(调用成功、失败都会执行) |
+ |
+ ✓ |
+ ✓ |
+
+
+
+
+
+### object.success 回调函数
+**参数**
+**Object res**
+
+| 属性 | 类型 | 说明 | 最低版本 | 支付宝 | RN |
+| --- | --- | --- | --- | --- | --- |
+| tempImagePath | string | 照片文件的临时路径 (本地路径),安卓是jpg图片格式,ios是png | | ✓ | ✓ |
+| metadata | Object | 照片的拍摄信息,仅当传入的 captureMetadata 属性值为 true 时返回该字段 | 3.15.0 | ✗ | ✗ |
diff --git a/docs-vitepress/guide/rn/application-api.md b/docs-vitepress/guide/rn/application-api.md
index 384e0d9d6c..01651cd0a1 100644
--- a/docs-vitepress/guide/rn/application-api.md
+++ b/docs-vitepress/guide/rn/application-api.md
@@ -139,7 +139,10 @@ externals: {
'react-native-safe-area-context': 'react-native-safe-area-context',
'react-native-reanimated': 'react-native-reanimated',
'react-native-get-location': 'react-native-get-location',
- 'react-native-haptic-feedback': 'react-native-haptic-feedback'
+ 'react-native-haptic-feedback': 'react-native-haptic-feedback',
+ 'react-native-ble-manager': 'react-native-ble-manager',
+ 'react-native-wifi-reborn': 'react-native-wifi-reborn',
+ 'react-native-vision-camera': 'react-native-vision-camera'
}
```
@@ -156,6 +159,9 @@ externals: {
| **设备信息** | `getSystemInfo`、`getDeviceInfo` | `react-native-device-info` |
| **安全区域** | `getWindowInfo`、`getLaunchOptionsSync` | `react-native-safe-area-context` |
| **震动反馈** | `vibrateShort`、`vibrateLong` | `react-native-haptic-feedback` |
+| **wifi** | `startWifi`、`stopWifi`、`getWifiList`、`onGetWifiList`、`offGetWifiList`、`getConnectedWifi` | `react-native-wifi-reborn` |
+| **蓝牙** | `openBluetoothAdapter`、`closeBluetoothAdapter`、`startBluetoothDevicesDiscovery`、`stopBluetoothDevicesDiscovery`、`onBluetoothDeviceFound`、`offBluetoothDeviceFound`、`getConnectedBluetoothDevices`、`getBluetoothAdapterState`、`onBluetoothAdapterStateChange`、`offBluetoothAdapterStateChange`、`getBluetoothDevices`、`writeBLECharacteristicValue`、`readBLECharacteristicValue`、`notifyBLECharacteristicValueChange`、`onBLECharacteristicValueChange`、`offBLECharacteristicValueChange`、`setBLEMTU`、`getBLEDeviceRSSI`、`getBLEDeviceServices`、`getBLEDeviceCharacteristics`、`createBLEConnection`、`closeBLEConnection`、`onBLEConnectionStateChange`、`offBLEConnectionStateChange` | `react-native-ble-manager` |
+| **相机** | `CameraContext` | `react-native-vision-camera` |
**按需安装示例:**
@@ -169,6 +175,9 @@ npm install react-native-get-location
# 示例:使用网络状态监听 {#example-network-status}
npm install @react-native-community/netinfo
+# 示例:使用相机组件实例api
+npm install react-native-vision-camera
+
# iOS 项目需要执行(有原生依赖时) {#ios-native-dependency}
cd ios && pod install
```
@@ -220,6 +229,54 @@ module.exports = {
> ⚠️ **注意:** 确保 Mpx 项目和容器中的 `react-native-reanimated` 版本一致
+**react-native-ble-manager**
+
+在`android/app/src/main/AndroidManifest.xml`文件中添加
+```xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ...
+```
+
### 跨平台 API 使用限制 {#cross-platform-api-limit}
### selectComponent/selectAllComponents
在 RN 环境下使用 `selectComponent` 或 `selectAllComponents` 时,必须在目标节点上标记 wx:ref。选择器支持范围有限,仅支持以下方式
@@ -499,3 +556,116 @@ mpx.config.rnConfig.getBottomVirtualHeight = () => {
return Math.max(initialWindowMetrics?.insets?.bottom || 0 , (screenDimensions.height - windowDimensions.height - ReactNative.StatusBar.currentHeight) || 0, 0)
}
```
+
+### 请求客户端蓝牙权限授权
+
+#### mpx.config.rnConfig.bluetoothPermission
+
+```ts
+() => Promise
+```
+
+框架内部已内置默认的蓝牙权限校验逻辑。该配置项作为开放扩展点,供业务在端内已有权限体系时接管校验流程(例如先走容器统一授权)。
+
+- 调用时机:`openBluetoothAdapter` 内部初始化蓝牙前调用。
+- 返回值:
+ - `true`:继续执行蓝牙初始化。
+ - `false` 或 Promise reject:中断流程,并回调 `openBluetoothAdapter:fail no permission`。
+
+默认行为(未自定义 `bluetoothPermission` 时):
+
+- Android 23 ~ 30:申请 `ACCESS_FINE_LOCATION`
+- Android 31+:申请 `BLUETOOTH_SCAN`、`BLUETOOTH_CONNECT`
+- 其他平台:默认返回 `true`
+
+```javascript
+import mpx from '@mpxjs/core'
+
+mpx.config.rnConfig.bluetoothPermission = async () => {
+ return new Promise((resolve, reject) => {
+ NativeBridge.bluetoothPermission().then((result) => {
+ if (result?.granted) {
+ resolve(true)
+ } else {
+ reject(new Error('no permission'))
+ }
+ }).catch((err) => {
+ reject(err || new Error('permission check fail'))
+ })
+ })
+}
+```
+
+> 说明:如业务需要走客户端自定义授权逻辑,可配置 `mpx.config.rnConfig.bluetoothPermission`;配置后将优先使用该逻辑,不再走框架内基于 `PermissionsAndroid` 的默认授权流程,未配置时则使用默认流程。
+
+### 请求客户端wifi权限授权
+
+#### mpx.config.rnConfig.wifiPermission
+
+```ts
+() => Promise
+```
+
+框架内部已内置默认的 Wi-Fi 权限校验逻辑。该配置项作为开放扩展点,供业务在端内已有权限体系时接管校验流程(例如先走容器统一授权)。
+
+- 调用时机:`startWifi` 内部执行前调用(仅 Android,iOS 不支持 `startWifi`)。
+- 默认行为(未自定义 `wifiPermission` 时):通过 `PermissionsAndroid` 申请 `ACCESS_FINE_LOCATION`。
+- 配置后行为:优先使用业务自定义逻辑,不再走框架默认 `PermissionsAndroid` 授权流程。
+- 判定规则:当前实现按 Promise 状态判断,`resolve` 视为通过,`reject` 视为失败。
+- 失败处理:`wifiPermission` Promise `reject` 时,`startWifi` 返回失败,`errCode` 为 `12001`。
+
+```javascript
+import mpx from '@mpxjs/core'
+
+mpx.config.rnConfig.wifiPermission = async () => {
+ return new Promise((resolve, reject) => {
+ NativeBridge.wifiPermission().then((result) => {
+ if (result?.granted) {
+ resolve(true)
+ } else {
+ reject(new Error('no permission'))
+ }
+ }).catch((err) => {
+ reject(err || new Error('permission check fail'))
+ })
+ })
+}
+```
+
+> 说明:如业务需要走客户端自定义授权逻辑,可配置 `mpx.config.rnConfig.wifiPermission`;配置后将优先使用该逻辑,未配置时则使用框架内基于 `PermissionsAndroid` 的默认授权流程。
+
+### 请求客户端相机权限授权
+
+#### mpx.config.rnConfig.cameraPermission
+
+```ts
+() => Promise
+```
+
+框架支持通过该配置项接入业务侧(客户端)自定义相机授权逻辑。
+
+- 调用时机:`camera` 组件挂载时执行权限检查。
+- 默认行为(未配置时):默认视为有权限。
+- 配置后行为:执行自定义 `cameraPermission`,仅当返回值严格等于 `true` 时渲染相机。
+- 无权限表现:返回非 `true` 或 Promise reject 时,相机不渲染。
+
+```javascript
+import mpx from '@mpxjs/core'
+
+mpx.config.rnConfig.cameraPermission = async () => {
+ return new Promise((resolve, reject) => {
+ NativeBridge.cameraPermission().then((result) => {
+ if (result?.granted) {
+ resolve(true)
+ } else {
+ reject(new Error('no permission'))
+ }
+ }).catch((err) => {
+ reject(err || new Error('permission check fail'))
+ })
+ })
+}
+```
+
+> 说明:如业务需要走客户端自定义授权逻辑,可配置 `mpx.config.rnConfig.cameraPermission`;配置后将优先使用该逻辑,未配置时按默认行为直接渲染相机。
+
diff --git a/docs-vitepress/guide/rn/component.md b/docs-vitepress/guide/rn/component.md
index 09fa29a0e3..676cff0d8f 100644
--- a/docs-vitepress/guide/rn/component.md
+++ b/docs-vitepress/guide/rn/component.md
@@ -7,7 +7,7 @@
- #### 基础组件
**容器组件**:[view](#view) · [scroll-view](#scroll-view) · [swiper](#swiper) · [swiper-item](#swiper-item) · [movable-area](#movable-area) · [movable-view](#movable-view) · [root-portal](#root-portal) · [sticky-section](#sticky-section) · [sticky-header](#sticky-header) · [cover-view](#cover-view)
-**媒体组件**:[image](#image) · [video](#video) · [canvas](#canvas)
+**媒体组件**:[image](#image) · [video](#video) · [canvas](#canvas) · [camera](#camera)
**表单组件**:[input](#input) · [textarea](#textarea) · [button](#button) · [checkbox](#checkbox) · [checkbox-group](#checkbox-group) · [radio](#radio) · [radio-group](#radio-group) · [switch](#switch) · [picker](#picker) · [picker-view](#picker-view) · [picker-view-column](#picker-view-column) · [form](#form) · [label](#label)
@@ -749,6 +749,36 @@ API
视图容器。
功能同 image 组件
+### camera
+
+相机组件。
+
+属性
+
+| 属性名 | 类型 | 默认值 | 说明 |
+| ----------------------- | ------- | ------------- | ---------------------------------------------------------- |
+| mode | string | `normal` | 相机模式,可选值:`normal`(拍照/录制)、`scanCode`(扫码) |
+| device-position | string | `back` | 摄像头朝向,可选值:`front`、`back` |
+| resolution | string | `medium` | 拍照分辨率,可选值:`low`、`medium`、`high` |
+| frame-size | string | `medium` | 录制分辨率,可选值:`small`、`medium`、`large` |
+| flash | string | `auto` | 闪光灯模式,可选值:`auto`、`on`、`off` |
+
+事件
+
+| 事件名 | 说明 |
+| ----------------| ------------------ |
+| bindinitdone | 相机初始化完成触发,`event.detail = { maxZoom }` |
+| bindstop | 相机停止预览时触发 |
+| bindscancode | 扫码结果回调(仅 `scanCode` 模式),`event.detail = { result, type, scanArea }` |
+| binderror | 相机异常回调 |
+
+> [!tip] 注意
+>
+> - 一个页面仅支持插入一个 `camera` 组件。
+> - `scanCode` 模式下不支持 `takePhoto/startRecord/stopRecord`。
+> - 可通过 `mpx.config.rnConfig.cameraPermission` 配置自定义相机权限校验;返回 `true` 才会渲染相机。
+
+
## 自定义组件 {#custom-component}
@@ -824,4 +854,4 @@ Mpx 完全支持自定义组件功能,组件创建、属性配置、生命周
}
})
-```
\ No newline at end of file
+```
diff --git a/packages/api-proxy/src/platform/api/device/wifi/index.ios.js b/packages/api-proxy/src/platform/api/device/wifi/index.ios.js
index a503aecfec..ce826c081e 100644
--- a/packages/api-proxy/src/platform/api/device/wifi/index.ios.js
+++ b/packages/api-proxy/src/platform/api/device/wifi/index.ios.js
@@ -2,7 +2,7 @@ import { PermissionsAndroid } from 'react-native'
import { noop, type } from '@mpxjs/utils'
import mpx from '@mpxjs/core'
let startWifiReady = false
-const wifiListListeners = []
+let wifiListListener = null
async function requestWifiPermission () {
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
@@ -78,7 +78,7 @@ function stopWifi (options = {}) {
return
}
startWifiReady = false
- wifiListListeners.length = 0
+ wifiListListener = null
const result = {
errMsg: 'stopWifi:success'
}
@@ -115,11 +115,9 @@ function getWifiList (options = {}) {
signalStrength: 100 + (item.level || 0)
}
})
- wifiListListeners.forEach(callback => {
- if (type(callback) === 'Function') {
- callback({ wifiList })
- }
- })
+ if (type(wifiListListener) === 'Function') {
+ wifiListListener({ wifiList })
+ }
const result = {
errMsg: 'getWifiList:success',
errno: 0,
@@ -137,20 +135,16 @@ function getWifiList (options = {}) {
}
function onGetWifiList (callback) {
- if (!startWifiReady && wifiListListeners.indexOf(callback) > -1) {
- return
+ if (callback && type(callback) === 'Function') {
+ wifiListListener = callback
}
- wifiListListeners.push(callback)
}
-function offGetWifiList (callback) {
+function offGetWifiList () {
if (!startWifiReady) {
return
}
- const index = wifiListListeners.indexOf(callback)
- if (index > -1) {
- wifiListListeners.splice(index, 1)
- }
+ wifiListListener = null
}
function getConnectedWifi (options = {}) {