Commit 49cc78c0 by 姜雷

修改设备交互问题

parent 8fcc8624
...@@ -223,10 +223,10 @@ class Connect extends Component { ...@@ -223,10 +223,10 @@ class Connect extends Component {
index++ index++
) { ) {
let str = msgObj.data.substring(index * 20, (index + 1) * 20); let str = msgObj.data.substring(index * 20, (index + 1) * 20);
this.sendMessageToDevice(str); currentThis && currentThis.sendMessageToDevice(str);
} }
} else { } else {
this.sendMessageToDevice(msgObj.data); currentThis && currentThis.sendMessageToDevice(msgObj.data);
} }
} else if (msgObj.type === 0) { } else if (msgObj.type === 0) {
if (msgObj.contorlCode === ContorlCode.using) { if (msgObj.contorlCode === ContorlCode.using) {
...@@ -402,9 +402,9 @@ class Connect extends Component { ...@@ -402,9 +402,9 @@ class Connect extends Component {
Taro.onBluetoothAdapterStateChange(res => { Taro.onBluetoothAdapterStateChange(res => {
console.log('adapterState changed, now is', res); console.log('adapterState changed, now is', res);
if (res.available) { if (res.available) {
this.setState({ // this.setState({
bluetoothState: true, // bluetoothState: true,
}); // });
} }
}); });
}); });
...@@ -639,7 +639,15 @@ class Connect extends Component { ...@@ -639,7 +639,15 @@ class Connect extends Component {
serviceId: deviceInfo.serviceId, serviceId: deviceInfo.serviceId,
characteristicId: deviceInfo.writeId, characteristicId: deviceInfo.writeId,
value: str2ab(msg), 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 { ...@@ -694,7 +702,7 @@ class Connect extends Component {
} }
openNotify({ notifyId, writeId, readId }) { openNotify({ notifyId, writeId, readId }) {
console.log(notifyId, writeId, readId); console.log('===============', notifyId, writeId, readId);
this.setState(({ deviceInfo }: PageState) => ({ this.setState(({ deviceInfo }: PageState) => ({
deviceInfo: { deviceInfo: {
...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