添加几个函数
This commit is contained in:
@ -338,11 +338,15 @@ import { deviceReName } from '../../api/common';
|
||||
// data.deviceId
|
||||
// data.serviceId
|
||||
// data.value
|
||||
//
|
||||
|
||||
},
|
||||
|
||||
proParam: function() {
|
||||
this.alert('提示', "敬请期待");
|
||||
|
||||
uni.showToast({
|
||||
title:'敬请期待'
|
||||
})
|
||||
},
|
||||
handRemark: function() {
|
||||
this.alert('提示', "敬请期待");
|
||||
@ -851,7 +855,7 @@ import { deviceReName } from '../../api/common';
|
||||
//给蓝牙设备发送信号更新亮度
|
||||
setTimeout(() => {
|
||||
this.sendBrightness();
|
||||
}, 100);
|
||||
}, 10);
|
||||
},
|
||||
sendBrightness: function() {
|
||||
const buffer = new ArrayBuffer(6);
|
||||
@ -873,7 +877,50 @@ import { deviceReName } from '../../api/common';
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
//获取当前设备状态
|
||||
GetDeviceStatu:function(){
|
||||
//数据头 命令码 数据 校验码
|
||||
//JQOC 0B 00 9C41
|
||||
|
||||
//硬件响应
|
||||
//数据头 命令码 主灯模式 副灯模式 亮度(%) 电量(%) 充电状态 校验码
|
||||
//JQOC 0B 01 01 64 85 01 9C41
|
||||
this.sendCmd('0x0B');
|
||||
},
|
||||
//设备重启
|
||||
DeviceReStart:function(){
|
||||
//数据头 命令码 数据 校验码
|
||||
//JQOC 0C 01 9C412
|
||||
this.sendCmd('0x0C');
|
||||
},
|
||||
//恢复出厂设置
|
||||
DeviceReSet:function(){
|
||||
//数据头 命令码 数据 校验码
|
||||
//JQOC 0D 01 9C412
|
||||
this.sendCmd('0x0D');
|
||||
},
|
||||
sendCmd:function(type,callback){
|
||||
//数据头 命令码 数据 校验码
|
||||
|
||||
const buffer = new ArrayBuffer(7);
|
||||
const dataView = new DataView(buffer);
|
||||
let data = '0x' + parseInt(this.formData.liangDu).toString(16);
|
||||
console.log("亮度:" + this.formData.liangDu + ',16进制:' + data);
|
||||
dataView.setUint8(0, 'JQOC'); // 帧头
|
||||
dataView.setUint8(1, type); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, '0x01'); // 包序号
|
||||
dataView.setUint8(3, '9C41'); // 数据长度
|
||||
|
||||
// 发送数据
|
||||
ble.LinkBlue(this.device.deviceId, () => {
|
||||
setTimeout(() => {
|
||||
ble.sendData(this.device.deviceId, buffer);
|
||||
}, 1000)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user