增加手动上传,修改新蓝牙不稳定问题
This commit is contained in:
parent
e3bee41bf9
commit
8717e992a6
|
@ -529,6 +529,7 @@
|
|||
document.getElementById('nextCowshed').setAttribute("class", 'btnc mui-btn-success flex');
|
||||
connectTimes = 0;
|
||||
text = '设备已连接';
|
||||
api.hideProgress();
|
||||
console.log('主机端连接成功')
|
||||
ble.setMtu({
|
||||
peripheralUUID: param.peripheralUUID,
|
||||
|
|
|
@ -186,6 +186,7 @@
|
|||
var _outerRadius = 215;
|
||||
var _innerRadius = 185;
|
||||
var feedName;
|
||||
var remark = '手动上传';
|
||||
var templateName;
|
||||
var templetType;
|
||||
var _pointerInnerRadius = 120;
|
||||
|
|
|
@ -122,16 +122,22 @@ function connect(param) {
|
|||
});
|
||||
ble.connect(param, function (ret, err) {
|
||||
if (ret.status) {
|
||||
wifiDom.innerHTML = '已连接';
|
||||
api.hideProgress();
|
||||
connetcedStatus = true
|
||||
// 缓存蓝牙设备uuid方便自动连接
|
||||
api.setPrefs({
|
||||
key: 'uuid',
|
||||
value: param.peripheralUUID
|
||||
});
|
||||
wifiDom.innerHTML = '已连接';
|
||||
if (connectTimes>0){
|
||||
addNotice(1,'#02a7f0',sbId + '主机端第'+connectTimes+'次重连成功');
|
||||
}else {
|
||||
addNotice(1,'#02a7f0',sbId + '主机端初始化连接成功');
|
||||
}
|
||||
connectTimes = 0;
|
||||
document.getElementById('text').innerHTML = '设备已连接';
|
||||
addNotice(1,'#02a7f0',sbId + '主机端连接成功'+uuid);
|
||||
|
||||
text = '设备已连接';
|
||||
console.log('主机端连接成功')
|
||||
ble.setMtu({
|
||||
|
@ -146,14 +152,17 @@ function connect(param) {
|
|||
}
|
||||
});
|
||||
}else {
|
||||
connetcedStatus = false
|
||||
connectTimes ++;
|
||||
console.log('主机端连接失败'+connectTimes+' '+uuid)
|
||||
if(connectTimes%50 === 0 || connectTimes === 1){
|
||||
addNotice(4,'red',sbId + '主机端连接失败'+connectTimes+'次 '+uuid);
|
||||
}
|
||||
wifiDom.innerHTML = '连接失败';
|
||||
api.hideProgress();
|
||||
connetcedStatus = false
|
||||
if (connectTimes > 0){
|
||||
if(connectTimes%10 === 0){
|
||||
addNotice(4,'red',sbId + '主机端第'+connectTimes+'次重连失败');
|
||||
}
|
||||
}else {
|
||||
addNotice(4,'red',sbId + '主机端连接失败,开始尝试重连');
|
||||
}
|
||||
connectTimes ++;
|
||||
setTimeout(function (){
|
||||
if (!connetcedStatus && uuid && feedStatus){
|
||||
console.log("连接失败!尝试重连" + uuid);
|
||||
|
@ -384,6 +393,7 @@ function discoverService(param) {
|
|||
if (weightDataFilter.dataBuffer.length === weightSize) {
|
||||
console.log("重量稳定", currTimeFn(new Date()));
|
||||
weightDataFilter.dataBuffer = []
|
||||
remark = '自动跳转'
|
||||
document.getElementById('submitData').click();
|
||||
}
|
||||
}else if(_feedNum > _planSum && (allowAuto || weightBeforefix === '1')){
|
||||
|
@ -393,6 +403,7 @@ function discoverService(param) {
|
|||
if (weightDataFilter.dataBuffer.length === weightSize) {
|
||||
console.log("重量稳定", currTimeFn(new Date()));
|
||||
weightDataFilter.dataBuffer = []
|
||||
remark = '自动跳转'
|
||||
document.getElementById('submitData').click();
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +462,7 @@ function setNotify(param, callback) {
|
|||
ble.setNotify(param, function (ret) {
|
||||
var value = ret.characteristic.value;
|
||||
// if (ret && value.indexOf('ff01') !== -1) {
|
||||
if (ret && value.substr(0,4) === 'ff01') {
|
||||
if (ret && value.startsWith("ff01") && value.length > 8){
|
||||
var wei = value.substr(8, value.length-8);
|
||||
// var wei = value.substr(12, 12);
|
||||
// wei = Math.round(Number(hex2a(wei)));
|
||||
|
|
|
@ -44,6 +44,7 @@ function submitData() {
|
|||
var param = {
|
||||
dateOf: dateOf,
|
||||
name: feedName,
|
||||
remark: remark,
|
||||
planWeight: Number(_planSum),
|
||||
rationCowAmount: feedList[feedIndex] ? feedList[feedIndex].cow : 0,
|
||||
batchRation: feedList[feedIndex].batchRation,
|
||||
|
@ -74,6 +75,7 @@ function submitData() {
|
|||
}, function (ret, err) {
|
||||
if (ret && ret.code == 200) {
|
||||
mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:3500,type:'div'});
|
||||
remark = '手动上传'
|
||||
beforeWeight = nowWeight;
|
||||
// document.getElementById('beforeWeight').innerHTML = '称实时/装料前:' + nowWeight + '/' + beforeWeight;
|
||||
feedIndex = feedIndex + 1;
|
||||
|
|
Loading…
Reference in New Issue