Cordova BLE android应用连接到ESP32但不发送数据

时间:2018-08-23 16:13:53

标签: cordova bluetooth-lowenergy

我现在有几个小时的问题。我有一个正在运行的应用程序,它正在与ESP32连接,发送数据和从ESP32接收数据。 (当我还原到旧版应用后,它又可以工作了...)

我已经重构了代码(将功能拆分为单独的更具逻辑性的js文件)并更改了UUID。

我看到BLE在ESP端连接(以及在chrome调试中通过它运行时)

但是当我在BLE连接后发送这样的消息时:

var message = "test";
var data = stringToBytes(message);
ble.writeWithoutResponse("30:AE:A4:44:6F:96", "6e400001-b5a3-f393-e0a9-e50e24dcca9e", "6e400002-b5a3-f393-e0a9-e50e24dcca9e", data, app.logMsg, app.onSendError);

ESP端没有收到它,调试时我没有收到任何错误或chrome中的调试消息。

关于要看哪个区域或要尝试什么的任何提示或技巧?

谢谢!

编辑:

做了一些进一步的故障排除。这是ble.connect返回的成功数据:

{"name":"app","id":"30:AE:A4:44:6F:96","advertising":{},"rssi":-45,"services":["1801","1800","6e400001-b5a3-f393-e0a9-e50e24dcca9e"],"characteristics":[{"service":"1801","characteristic":"2a05","properties":["Indicate"]},{"service":"1800","characteristic":"2a00","properties":["Read"]},{"service":"1800","characteristic":"2a01","properties":["Read"]},{"service":"1800","characteristic":"2aa6","properties":["Read"]},{"service":"6e400001-b5a3-f393-e0a9-e50e24dcca9e","characteristic":"6e400002-b5a3-f393-e0a9-e50e24dcca9e","properties":["Read","Write"]},{"service":"6e400001-b5a3-f393-e0a9-e50e24dcca9e","characteristic":"6e400003-b5a3-f393-e0a9-e50e24dcca9e","properties":["Notify"],"descriptors":[{"uuid":"2902"}]}]}

但是随后日志立即显示:

ERROR: "Attempt to invoke virtual method 'java.util.List android.bluetooth.BluetoothGattService.getCharacteristics()' on a null object reference"

因此似乎调用了一个不存在的特征。

事实上,在我的代码中,我仍然在写一个不存在的特征:-( 更新了代码,它现在可以工作了:-)

0 个答案:

没有答案
相关问题