Commit 49cc78c0 by 姜雷

修改设备交互问题

parent 8fcc8624
......@@ -223,10 +223,10 @@ class Connect extends Component {
index++
) {
let str = msgObj.data.substring(index * 20, (index + 1) * 20);
this.sendMessageToDevice(str);
currentThis && currentThis.sendMessageToDevice(str);
}
} else {
this.sendMessageToDevice(msgObj.data);
currentThis && currentThis.sendMessageToDevice(msgObj.data);
}
} else if (msgObj.type === 0) {
if (msgObj.contorlCode === ContorlCode.using) {
......@@ -402,9 +402,9 @@ class Connect extends Component {
Taro.onBluetoothAdapterStateChange(res => {
console.log('adapterState changed, now is', res);
if (res.available) {
this.setState({
bluetoothState: true,
});
// this.setState({
// bluetoothState: true,
// });
}
});
});
......@@ -639,7 +639,15 @@ class Connect extends Component {
serviceId: deviceInfo.serviceId,
characteristicId: deviceInfo.writeId,
value: str2ab(msg),
})
.then(res => {
console.log('蓝牙发送结果', res);
})
.catch(err => {
console.log('蓝牙发送结果', err);
});
} else {
console.log('无蓝牙设备writeId');
}
}
......@@ -694,7 +702,7 @@ class Connect extends Component {
}
openNotify({ notifyId, writeId, readId }) {
console.log(notifyId, writeId, readId);
console.log('===============', notifyId, writeId, readId);
this.setState(({ deviceInfo }: PageState) => ({
deviceInfo: {
...deviceInfo,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment