马小力
马小力
  • 发布:2019-06-06 11:54
  • 更新:2019-09-20 14:17
  • 阅读:1524

hello-uni-app-master工程蓝牙读取特征值数据 value数据null

分类:uni-app

**步骤:
1、初始化蓝牙模块→ 搜索蓝牙设备→ 选择设备→连接蓝牙设备→选择设备服务→获取服务的特征值(见附件1559792686468.jpg)

2、通过扫描设备扫描二维码,监听到返回结果: {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}}**

操作视频地址:



操作过程中输出Log:

初始化蓝牙成功:openBluetoothAdapter:ok at pages\API\bluetooth\bluetooth.vue:212
11:44:42.563 {"errMsg":"openBluetoothAdapter:ok"} at pages\API\bluetooth\bluetooth.vue:213
11:44:42.584 ---> at pages\API\bluetooth\bluetooth.vue:307
11:44:42.603 {"discovering":false,"available":true,"errMsg":"getBluetoothAdapterState:ok"} at pages\API\bluetooth\bluetooth.vue:310
11:44:46.086 开始搜索蓝牙设备:startBluetoothDevicesDiscovery:ok at pages\API\bluetooth\bluetooth.vue:235
11:44:48.210 开始监听寻找到新设备的事件 at pages\API\bluetooth\bluetooth.vue:279
11:44:48.230 获取蓝牙设备成功:getBluetoothDevices:ok at pages\API\bluetooth\bluetooth.vue:291
11:44:48.470 开始监听寻找到新设备的事件 at pages\API\bluetooth\bluetooth.vue:279
11:44:48.500 获取蓝牙设备成功:getBluetoothDevices:ok at pages\API\bluetooth\bluetooth.vue:291
11:44:49.331 开始监听寻找到新设备的事件 at pages\API\bluetooth\bluetooth.vue:279
11:44:49.363 获取蓝牙设备成功:getBluetoothDevices:ok at pages\API\bluetooth\bluetooth.vue:291
11:44:53.896 [Object] {"errMsg":"createBLEConnection:ok"} at pages\API\bluetooth\bluetooth.vue:335
11:44:53.929 连接蓝牙成功:createBLEConnection:ok at pages\API\bluetooth\bluetooth.vue:336
11:44:53.951 蓝牙连接状态 --------------------------> at pages\API\bluetooth\bluetooth.vue:462
11:44:53.965 {"deviceId":"AA:A8:AC:15:20:63","connected":true} at pages\API\bluetooth\bluetooth.vue:463
11:44:53.980 停止搜索蓝牙设备:stopBluetoothDevicesDiscovery:ok at pages\API\bluetooth\bluetooth.vue:256
11:44:56.973 获取所有服务的 uuid:AA:A8:AC:15:20:63 at pages\API\bluetooth\bluetooth.vue:394
11:44:57.010 [{"uuid":"00001800-0000-1000-8000-00805F9B34FB","isPrimary":true},{"uuid":"00001801-0000-1000-8000-00805F9B34FB","isPrimary":true},{"uuid":"00001804-0000-1000-8000-00805F9B34FB","isPrimary":true},{"uuid":"0000180F-0000-1000-8000-00805F9B34FB","isPrimary":true},{"uuid":"0000180A-0000-1000-8000-00805F9B34FB","isPrimary":true},{"uuid":"0000FEEA-0000-1000-8000-00805F9B34FB","isPrimary":true}] at pages\API\bluetooth\bluetooth.vue:400
11:44:57.032 获取设备服务成功:getBLEDeviceServices:ok at pages\API\bluetooth\bluetooth.vue:401
11:44:59.177 AA:A8:AC:15:20:63 at pages\API\bluetooth\bluetooth.vue:428
11:44:59.215 0000FEEA-0000-1000-8000-00805F9B34FB at pages\API\bluetooth\bluetooth.vue:429
11:44:59.236 {"characteristics":[{"uuid":"00002AA1-0000-1000-8000-00805F9B34FB","properties":{"read":true,"write":false,"notify":true,"indicate":true}},{"uuid":"0000FEC9-0000-1000-8000-00805F9B34FB","properties":{"read":true,"write":false,"notify":false,"indicate":false}},{"uuid":"00002AA2-0000-1000-8000-00805F9B34FB","properties":{"read":false,"write":true,"notify":false,"indicate":false}}],"errMsg":"getBLEDeviceCharacteristics:ok"} at pages\API\bluetooth\bluetooth.vue:436
11:44:59.238 获取特征值成功:getBLEDeviceCharacteristics:ok at pages\API\bluetooth\bluetooth.vue:437
11:45:15.797 AA:A8:AC:15:20:63 at pages\API\bluetooth\bluetooth.vue:491
11:45:15.841 0000FEEA-0000-1000-8000-00805F9B34FB at pages\API\bluetooth\bluetooth.vue:492
11:45:15.842 00002AA1-0000-1000-8000-00805F9B34FB at pages\API\bluetooth\bluetooth.vue:493
11:45:15.876 读取设备数据值成功 at pages\API\bluetooth\bluetooth.vue:502
11:45:15.898 {"errMsg":"readBLECharacteristicValue:ok"} at pages\API\bluetooth\bluetooth.vue:503
11:45:15.899 AA:A8:AC:15:20:63 at pages\API\bluetooth\bluetooth.vue:534
11:45:15.919 0000FEEA-0000-1000-8000-00805F9B34FB at pages\API\bluetooth\bluetooth.vue:535
11:45:15.940 00002AA1-0000-1000-8000-00805F9B34FB at pages\API\bluetooth\bluetooth.vue:536
11:45:15.957 [Boolean] true at pages\API\bluetooth\bluetooth.vue:537
11:45:15.977 notifyBLECharacteristicValueChange success:notifyBLECharacteristicValueChange:ok at pages\API\bluetooth\bluetooth.vue:547
11:45:15.997 {"errMsg":"notifyBLECharacteristicValueChange:ok"} at pages\API\bluetooth\bluetooth.vue:548
11:45:30.276 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:45:30.313 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:25.348 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:25.401 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:46.453 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:46.494 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:47.778 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:47.824 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:50.239 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:50.282 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:51.299 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:51.350 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:52.481 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:52.537 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522
11:46:53.644 监听低功耗蓝牙设备的特征值变化事件成功 at pages\API\bluetooth\bluetooth.vue:521
11:46:53.703 {"deviceId":"AA:A8:AC:15:20:63","serviceId":"0000FEEA-0000-1000-8000-00805F9B34FB","characteristicId":"00002AA1-0000-1000-8000-00805F9B34FB","value":{}} at pages\API\bluetooth\bluetooth.vue:522

2019-06-06 11:54 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

你好 找到原因了嘛 我和你出现了一样的问题

1***@qq.com

1***@qq.com - 代码英雄

你能够收到设备端过来的数据了吗?

1***@qq.com

1***@qq.com

可以了

1***@qq.com

1***@qq.com - 代码英雄

嗯,坚定了信心后,我也搞定了, 谢谢!

  • 许香香

    求问你怎么搞定的!

    2020-05-25 11:26

  • bug喵

    回复 许香香: 请问搞定了吗,求大佬解答

    2021-12-22 09:42

  • 5***@qq.com

    ??、怎么搞定的

    2022-12-05 13:30

该问题目前已经被锁定, 无法添加新回复