识别BLE信标服务(以启用通知,如果可用)

时间:2018-01-17 16:52:01

标签: service notifications bluetooth-lowenergy beacon

刚开始使用BLE Beacons并编写了一个小程序来定位信标并列出一些服务等。以下是我可以在console.log中打印的结果

BLE service: 
  Service handle: 43
  uuid: 00001800-0000-1000-8000-00805f9b34fb
    characteristic: 00002a00-0000-1000-8000-00805f9b34fb
    characteristic: 00002a01-0000-1000-8000-00805f9b34fb
    characteristic: 00002a02-0000-1000-8000-00805f9b34fb
    characteristic: 00002a03-0000-1000-8000-00805f9b34fb
    characteristic: 00002a04-0000-1000-8000-00805f9b34fb
BLE service: 
  Service handle: 44
  uuid: 00001801-0000-1000-8000-00805f9b34fb
    characteristic: 00002a05-0000-1000-8000-00805f9b34fb
      descriptor: 00002902-0000-1000-8000-00805f9b34fb
BLE service: 
  Service handle: 45
  uuid: 0000180a-0000-1000-8000-00805f9b34fb
    characteristic: 00002a25-0000-1000-8000-00805f9b34fb
    characteristic: 00002a26-0000-1000-8000-00805f9b34fb
    characteristic: 00002a29-0000-1000-8000-00805f9b34fb
BLE service: 
  Service handle: 46
  uuid: 0000c050-0000-1000-8000-00805f9b34fb
    characteristic: 0000c051-0000-1000-8000-00805f9b34fb
    characteristic: 0000c052-0000-1000-8000-00805f9b34fb
    characteristic: 0000c053-0000-1000-8000-00805f9b34fb
    characteristic: 0000c054-0000-1000-8000-00805f9b34fb
    characteristic: 0000c055-0000-1000-8000-00805f9b34fb
    characteristic: 0000c056-0000-1000-8000-00805f9b34fb
    characteristic: 0000c057-0000-1000-8000-00805f9b34fb
    characteristic: 0000c058-0000-1000-8000-00805f9b34fb
    characteristic: 0000c059-0000-1000-8000-00805f9b34fb
    characteristic: 0000c05a-0000-1000-8000-00805f9b34fb
      descriptor: 00002902-0000-1000-8000-00805f9b34fb
    characteristic: 0000c05b-0000-1000-8000-00805f9b34fb
    characteristic: 0000c05c-0000-1000-8000-00805f9b34fb
    characteristic: 0000c05d-0000-1000-8000-00805f9b34fb
BLE service: 
  Service handle: 47
  uuid: 0000c090-0000-1000-8000-00805f9b34fb
    characteristic: 0000c091-0000-1000-8000-00805f9b34fb
      descriptor: 00002902-0000-1000-8000-00805f9b34fb
    characteristic: 0000c092-0000-1000-8000-00805f9b34fb
    characteristic: 0000c093-0000-1000-8000-00805f9b34fb
    characteristic: 0000c094-0000-1000-8000-00805f9b34fb
    characteristic: 0000c095-0000-1000-8000-00805f9b34fb
BLE service: 
  Service handle: 48
  uuid: f000ffc0-0451-4000-b000-000000000000
    characteristic: f000ffc1-0451-4000-b000-000000000000
      descriptor: 00002902-0000-1000-8000-00805f9b34fb
      descriptor: 00002901-0000-1000-8000-00805f9b34fb
    characteristic: f000ffc2-0451-4000-b000-000000000000
      descriptor: 00002902-0000-1000-8000-00805f9b34fb
      descriptor: 00002901-0000-1000-8000-00805f9b34fb

这些信标基本上传输2个值 - 信标本身的温度和电压。在我阅读更多笔记时,我想知道是否有人可以指出我需要关注哪些UUID /特性,以便能够获得温度和电压读数?当我做更多的阅读和研究时,如果有经验的开发人员可以给出一些指示,我真的很感激?基本上我需要启用温度和电压服务通知。我可以从BLE库中找出如何启用通知但是如何定位/指向正确的服务/特性/描述符等?再次感谢

我有一个带有ble的Arduino板扫描并从信标中捕获一些数据

[ADV    22587] Packet received from 50:65:83:10:E6:3A
       PAYLOAD 30 bytes
               02-01-06-1A-FF-6A-00-0F-75-E9-D5-AD-15-DF-FB-48-01-52-4E-8A-4B-B9-3D-0F-00-1E-3B-9E-FF-2C
          RSSI -68 dBm
      ADV TYPE Connectable undirected
 MAN SPEC DATA 6A-00-0F-75-E9-D5-AD-15-DF-FB-48-01-52-4E-8A-4B-B9-3D-0F-00-1E-3B-9E-FF-2C

[SR     22618] Packet received from 50:65:83:10:E6:3A
       PAYLOAD 22 bytes
               12-09-69-57-45-45-43-41-52-45-20-54-65-6D-70-20-50-61-6C-02-0A-00
          RSSI -68 dBm
      ADV TYPE Connectable undirected
 COMPLETE NAME Temp mini Sensor
  TX PWR LEVEL 0

关于我应该如何从这里继续的任何指示?试图抓住它...只是那个难以捉摸的领导......我想我已经理解了发生了什么:)

1 个答案:

答案 0 :(得分:1)

蓝牙Gatt服务只允许您在蓝牙外设上读写特征。通常,外围设备的设计使得将某些模式写入某些特性可以控制外设的功能。

以您的问题为例,将一些模式写入某些特征可能会控制是否根据超过阈值或定期间隔向连接的蓝牙中心通知温度和/或电压的变化。

要理解的关键是配置蓝牙外设的方式都取决于其系统设计。这不是标准。您确实需要来自制造商的文档来告诉您如何执行此操作。如果没有这样的文档,您基本上是对蓝牙外设进行逆向工程。

更好地回答您的问题以确定此信标设备的制造商和型号可能会有所帮助。如果您在制造商的网站上没有看到任何文档,那么制造商可能会直接回答这个问题,或者反向设计该设备的其他人也会这样做。