diff --git a/docs/ED713-ble.pdf b/docs/ED713-ble.pdf new file mode 100644 index 0000000..baaaa16 Binary files /dev/null and b/docs/ED713-ble.pdf differ diff --git a/docs/ED719-ble.docx b/docs/ED719-ble.docx new file mode 100644 index 0000000..f9de8c3 Binary files /dev/null and b/docs/ED719-ble.docx differ diff --git a/hooks/useBluetoothDiscovery.js b/hooks/useBluetoothDiscovery.js index 8f45686..d3f0918 100644 --- a/hooks/useBluetoothDiscovery.js +++ b/hooks/useBluetoothDiscovery.js @@ -692,6 +692,20 @@ export function createBluetoothDiscovery(options = {}) { return result } + /** + * MAC固定规则鉴权:密钥=MAC(去分隔符)+0000。 + */ + async function authorizeDeviceByMac(options = {}) { + if (!currentDeviceId) { + throw new Error('请先连接设备后再鉴权') + } + + const result = await controller.auth.ensureAuthorizedByMac(options) + lastAuthResult = result + onAuthChange(result) + return result + } + /** * 标准连接流程:连接 -> 发现 -> 订阅 -> 鉴权。 */ @@ -721,6 +735,14 @@ export function createBluetoothDiscovery(options = {}) { return result } + /** + * WiFi配置专用流程:连接 -> 发现 -> 订阅 -> 按 MAC+0000 完成鉴权。 + */ + async function prepareWifiConfig(deviceId, options = {}) { + await connectDevice(deviceId) + return authorizeDeviceByMac(options) + } + async function readDeviceInfo() { const info = await controller.auth.readDeviceInfo() lastDeviceInfo = info @@ -806,7 +828,9 @@ export function createBluetoothDiscovery(options = {}) { // 连接与协议流程能力。 connectDevice, authorizeDevice, + authorizeDeviceByMac, standardConnectFlow, + prepareWifiConfig, disconnectDevice, // 协议业务能力。 diff --git a/pages/device/config.vue b/pages/device/config.vue index e544407..ab9b455 100644 --- a/pages/device/config.vue +++ b/pages/device/config.vue @@ -31,19 +31,106 @@ {{ device.deviceId }} - 网络配置 + + {{ wifiPreparing ? '鉴权中' : '网络配置' }} + 参数配置 服务器配置 + + + + + 设备网络设置 + × + + + + 设备 + {{ selectedDeviceName }} + + + + *WiFi名称 + + + {{ fetchingCurrentWifi ? '获取中...' : '一键获取当前连接WiFi' }} + + + + + *WiFi密码 + + + + + 一键导入上次 WiFi 配置 + + + + {{ wifiSending ? '发送中...' : '发送' }} + + +