diff --git a/src/pages.json b/src/pages.json
index b37718a..08b6cc9 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -33,6 +33,20 @@
"navigationStyle": "custom"
}
},
+ {
+ "path": "pages/mixer/setting",
+ "style": {
+ "navigationBarTitleText": "搅拌器设置",
+ "navigationStyle": "custom"
+ }
+ },
+ {
+ "path": "pages/mixer/control",
+ "style": {
+ "navigationBarTitleText": "搅拌器控制",
+ "navigationStyle": "custom"
+ }
+ },
{
"path": "pages/register",
"style": {
diff --git a/src/pages/bluetooth/bluetooth.vue b/src/pages/bluetooth/bluetooth.vue
index 6b235df..12e20b2 100644
--- a/src/pages/bluetooth/bluetooth.vue
+++ b/src/pages/bluetooth/bluetooth.vue
@@ -507,6 +507,37 @@ const tryAutoReconnectLastDevice = async () => {
connectedDeviceId.value = targetDevice.deviceId
connectedDevice.value = targetDevice
+ // 设置蓝牙 MTU 为 500 (主要针对 Android)
+ // #ifdef APP-PLUS || MP-WEIXIN
+ if (uni.getSystemInfoSync().platform === 'android') {
+ try {
+ await new Promise((resolve, reject) => {
+ uni.setBLEMTU({
+ deviceId: targetDevice.deviceId,
+ mtu: 500,
+ success: (mtuRes) => {
+ console.log('MTU 设置成功, 实际MTU:', mtuRes.mtu || 500)
+ uni.showToast({
+ title: `MTU: ${mtuRes.mtu || 500}`,
+ icon: 'none',
+ duration: 2000
+ })
+ resolve(mtuRes)
+ },
+ fail: (mtuErr) => {
+ console.error('MTU 设置失败:', mtuErr)
+ resolve(null)
+ }
+ })
+ })
+ // 等待MTU协商稳定
+ await new Promise(resolve => setTimeout(resolve, 500))
+ } catch (e) {
+ console.error('MTU 设置异常:', e)
+ }
+ }
+ // #endif
+
// 停止搜索
uni.stopBluetoothDevicesDiscovery()
@@ -751,6 +782,34 @@ const doConnect = (device) => {
timeout: 10000, // 10 seconds timeout
success: async (res) => {
console.log('Connection successful', res)
+
+ // 设置蓝牙 MTU 为 500 (主要针对 Android)
+ // #ifdef APP-PLUS || MP-WEIXIN
+ if (uni.getSystemInfoSync().platform === 'android') {
+ try {
+ await new Promise((resolve, reject) => {
+ uni.setBLEMTU({
+ deviceId: device.deviceId,
+ mtu: 500,
+ success: (mtuRes) => {
+ console.log('MTU 设置成功, 实际MTU:', mtuRes.mtu || 500)
+ resolve(mtuRes)
+ },
+ fail: (mtuErr) => {
+ console.error('MTU 设置失败:', mtuErr)
+ // MTU设置失败不阻塞后续流程
+ resolve(null)
+ }
+ })
+ })
+ // 等待MTU协商稳定
+ await new Promise(resolve => setTimeout(resolve, 500))
+ } catch (e) {
+ console.error('MTU 设置异常:', e)
+ }
+ }
+ // #endif
+
connectingDeviceId.value = ''
connectedDeviceId.value = device.deviceId
connectedDevice.value = device
@@ -900,14 +959,11 @@ const getBLEDeviceServices = async (deviceId) => {
let notifyCharacteristicId = '' // 通用可监听特征值
let mainServiceId = '' // 主服务ID
- // 🔧 收集所有协议特征值的128位UUID(用于mixer.vue)
+ // 🔧 收集新协议1.2的特征值UUID
const protocolCharacteristics = {
- status: '', // 0xFF01 - 电机状态
- speed: '', // 0xFF02 - 电机速度
- direction: '', // 0xFF03 - 运行方向
- timer: '', // 0xFF04 - 定时设置
- remaining: '', // 0xFF05 - 剩余时间
- allProps: '' // 0xFF06 - 所有属性
+ setting: '', // 0xFF01 - 设置参数
+ status: '', // 0xFF02 - 运行状态
+ control: '' // 0xFF03 - 控制指令
}
// 查找协议规定的服务ID (0x00FF)
@@ -935,25 +991,16 @@ const getBLEDeviceServices = async (deviceId) => {
serviceChars.forEach(characteristic => {
const charUUID = characteristic.uuid.toUpperCase()
- // 🔧 识别协议规定的特征值(通过包含匹配128位UUID)
+ // 🔧 识别新协议1.2的特征值
if (charUUID.includes('FF01') || charUUID.includes('0XFF01')) {
- protocolCharacteristics.status = characteristic.uuid
- console.log('✅ 找到电机状态特征值(0xFF01):', characteristic.uuid)
+ protocolCharacteristics.setting = characteristic.uuid
+ console.log('✅ 找到设置参数特征值(0xFF01):', characteristic.uuid)
} else if (charUUID.includes('FF02') || charUUID.includes('0XFF02')) {
- protocolCharacteristics.speed = characteristic.uuid
- console.log('✅ 找到电机速度特征值(0xFF02):', characteristic.uuid)
+ protocolCharacteristics.status = characteristic.uuid
+ console.log('✅ 找到运行状态特征值(0xFF02):', characteristic.uuid)
} else if (charUUID.includes('FF03') || charUUID.includes('0XFF03')) {
- protocolCharacteristics.direction = characteristic.uuid
- console.log('✅ 找到运行方向特征值(0xFF03):', characteristic.uuid)
- } else if (charUUID.includes('FF04') || charUUID.includes('0XFF04')) {
- protocolCharacteristics.timer = characteristic.uuid
- console.log('✅ 找到定时设置特征值(0xFF04):', characteristic.uuid)
- } else if (charUUID.includes('FF05') || charUUID.includes('0XFF05')) {
- protocolCharacteristics.remaining = characteristic.uuid
- console.log('✅ 找到剩余时间特征值(0xFF05):', characteristic.uuid)
- } else if (charUUID.includes('FF06') || charUUID.includes('0XFF06')) {
- protocolCharacteristics.allProps = characteristic.uuid
- console.log('✅ 找到所有属性特征值(0xFF06):', characteristic.uuid)
+ protocolCharacteristics.control = characteristic.uuid
+ console.log('✅ 找到控制指令特征值(0xFF03):', characteristic.uuid)
}
// 查找通用可写特征值(优先选择 write)
@@ -989,28 +1036,22 @@ const getBLEDeviceServices = async (deviceId) => {
totalCharacteristicsCount.value = totalCount
console.log(`总共 ${totalCount} 个特征值`)
- // 🔧 打印所有协议特征值
- console.log('📋 协议特征值UUID汇总:')
- console.log(' 0xFF01 (状态):', protocolCharacteristics.status || '未找到')
- console.log(' 0xFF02 (速度):', protocolCharacteristics.speed || '未找到')
- console.log(' 0xFF03 (方向):', protocolCharacteristics.direction || '未找到')
- console.log(' 0xFF04 (定时):', protocolCharacteristics.timer || '未找到')
- console.log(' 0xFF05 (剩余):', protocolCharacteristics.remaining || '未找到')
- console.log(' 0xFF06 (全部):', protocolCharacteristics.allProps || '未找到')
+ // 🔧 打印新协议1.2特征值
+ console.log('📋 协议1.2特征值UUID汇总:')
+ console.log(' 0xFF01 (设置参数):', protocolCharacteristics.setting || '未找到')
+ console.log(' 0xFF02 (运行状态):', protocolCharacteristics.status || '未找到')
+ console.log(' 0xFF03 (控制指令):', protocolCharacteristics.control || '未找到')
}
- // 返回蓝牙信息(用于跳转),包含所有协议特征值
+ // 返回蓝牙信息(用于跳转),包含新协议1.2特征值
return {
serviceId: mainServiceId,
characteristicId: writeCharacteristicId,
notifyCharacteristicId: notifyCharacteristicId,
- // 🔧 添加所有协议特征值的128位UUID
+ // 新协议1.2的特征值UUID
+ settingCharId: protocolCharacteristics.setting,
statusCharId: protocolCharacteristics.status,
- speedCharId: protocolCharacteristics.speed,
- directionCharId: protocolCharacteristics.direction,
- timerCharId: protocolCharacteristics.timer,
- remainingCharId: protocolCharacteristics.remaining,
- allPropsCharId: protocolCharacteristics.allProps
+ controlCharId: protocolCharacteristics.control
}
} catch (err) {
console.error('获取服务列表失败', err)
@@ -1054,24 +1095,15 @@ const buildMixerPageUrl = (device, bleInfo) => {
params.notifyCharacteristicId = bleInfo.notifyCharacteristicId
}
- // 🔧 添加所有协议特征值的128位UUID
+ // 新协议1.2的特征值UUID
+ if (bleInfo && bleInfo.settingCharId) {
+ params.settingCharId = bleInfo.settingCharId
+ }
if (bleInfo && bleInfo.statusCharId) {
params.statusCharId = bleInfo.statusCharId
}
- if (bleInfo && bleInfo.speedCharId) {
- params.speedCharId = bleInfo.speedCharId
- }
- if (bleInfo && bleInfo.directionCharId) {
- params.directionCharId = bleInfo.directionCharId
- }
- if (bleInfo && bleInfo.timerCharId) {
- params.timerCharId = bleInfo.timerCharId
- }
- if (bleInfo && bleInfo.remainingCharId) {
- params.remainingCharId = bleInfo.remainingCharId
- }
- if (bleInfo && bleInfo.allPropsCharId) {
- params.allPropsCharId = bleInfo.allPropsCharId
+ if (bleInfo && bleInfo.controlCharId) {
+ params.controlCharId = bleInfo.controlCharId
}
console.log('🔗 跳转参数:', params)
@@ -1081,7 +1113,7 @@ const buildMixerPageUrl = (device, bleInfo) => {
.map(key => `${key}=${params[key]}`)
.join('&')
- return `/pages/mixer/mixer?${queryString}`
+ return `/pages/mixer/setting?${queryString}`
}
// 启用特征值变化监听
@@ -1128,13 +1160,6 @@ const onBLECharacteristicValueChange = () => {
// 添加到历史记录(包含UUID)
addToHistory('receive', displayData, hexString, res.characteristicId)
-
- // 显示接收到的数据
- uni.showToast({
- title: `Received Data: ${displayData.slice(0, 20)}${displayData.length > 20 ? '...' : ''}`,
- icon: 'none',
- duration: 2000
- })
})
}
diff --git a/src/pages/mixer/control.vue b/src/pages/mixer/control.vue
new file mode 100644
index 0000000..b09ab7a
--- /dev/null
+++ b/src/pages/mixer/control.vue
@@ -0,0 +1,870 @@
+
+
+
+
+
+
+
+
+
+ {{ deviceName || 'Six-Channel Mixer' }}
+
+
+
+
+ {{ connected ? 'Connected' : 'Disconnected' }}
+
+
+
+
+
+
+
+
+
+ No enabled channels
+ Please enable channels in Setting page first
+
+
+
+
+
+
+
+
+
+
+
+
+ ⚡
+ Fast
+ ✓
+
+
+ 🐢
+ Slow
+ ✓
+
+
+ ⏸
+ Still
+ ✓
+
+
+
+ Remaining
+ {{ formatTime(channel.remainingTime) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Start
+
+
+
+ Pause
+
+
+
+
+
+ Resume
+
+
+
+ Exit
+
+
+
+
+
+
+
+
+
+ Setting
+
+
+
+ Start
+
+
+
+
+
+
+
+
diff --git a/src/pages/mixer/setting.vue b/src/pages/mixer/setting.vue
new file mode 100644
index 0000000..3049c3e
--- /dev/null
+++ b/src/pages/mixer/setting.vue
@@ -0,0 +1,568 @@
+
+
+
+
+
+
+
+
+
+ {{ deviceName || 'Six-Channel Mixer' }}
+
+
+
+
+ {{ connected ? 'Connected' : 'Disconnected' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ⚡
+ Fast Mode
+
+
+
+ Speed
+ updateFastSpeed(channel.id, e.detail.value)"
+ :disabled="!channel.enabled"
+ >
+ {{ channel.fastSpeed }} RPM
+
+
+
+ Time
+ updateFastTime(channel.id, e.detail.value)"
+ :disabled="!channel.enabled"
+ >
+ {{ channel.fastTime }} s
+
+
+
+
+
+
+
+
+ 🐢
+ Slow Mode
+
+
+
+ Speed
+ updateSlowSpeed(channel.id, e.detail.value)"
+ :disabled="!channel.enabled"
+ >
+ {{ channel.slowSpeed }} RPM
+
+
+
+ Time
+ updateSlowTime(channel.id, e.detail.value)"
+ :disabled="!channel.enabled"
+ >
+ {{ channel.slowTime }} min
+
+
+
+
+
+
+
+
+ ⏸
+ Still Mode
+
+
+
+ Speed
+ 0 RPM
+
+
+ Time
+ updateStillTime(channel.id, e.detail.value)"
+ :disabled="!channel.enabled"
+ >
+ {{ channel.stillTime }} min
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Setting
+
+
+
+ Start
+
+
+
+
+
+
+
+
diff --git a/src/pages/mixer/蓝牙电机协议1.2.xlsx b/src/pages/mixer/蓝牙电机协议1.2.xlsx
new file mode 100644
index 0000000..470bbb3
Binary files /dev/null and b/src/pages/mixer/蓝牙电机协议1.2.xlsx differ