Reading from a Notify Characteristic (Ionic - Bluetooth)

点点圈 提交于 2019-12-25 08:59:54

问题


I am trying to connect to a glucose sensor using the default bluetooth profile 0x1808. I have already connected to the device, discovered all services and characteristics but I can not read the Glucose Measurement 0x2A18

{
  "service":"1808",
  "characteristic":"2a18",
  "properties":["Notify"],
  "descriptors":[{
    "uuid":"2902"
  }]
},
{
  "service":"1808",
  "characteristic":"2a34",
  "properties":["Notify"],
  "descriptors":[{
    "uuid":"2902"
  }]
},
{
  "service":"1808",
  "characteristic":"2a51",
  "properties":["Read"]
},
{
  "service":"1808",
  "characteristic":"2a52",
  "properties":["Write","Indicate"],
  "descriptors":[{
    "uuid":"2902"
  }]
}

Can anyone help me how to read the value of 0x2a18? Do I have to write anything to 0x2a52 (Record Access Control Point) to gain access?

I am new to Bluetooth Connection. Thank you in advance.


回答1:


In the Glucose Service (https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.glucose.xml) there is 3 mandatory characteristics. One of them is Glucose Measurement where you get glucose reading notifications. In order to get notifications you have to request for them using Record Access Control Point characteristic. It allows you to get all glucose readings, only the latest, only the first, delete saved readings from the device etc.

For example,

  • Enable notifications on Glucose Measurement characteristic.
  • Enable indications on Record Access Control Point characteristic.
  • Send f.e. 0x0101 = Report stored records | All records

You should get N notifications on Glucose Measurement char. followed by an indication on RACP char. with value: 0x06000101 = Response for "Report stored records" | success. N may be 0 if no readings are saved on the glucose device.

Read the GLS documentation: https://www.bluetooth.org/en-us/specification/adopted-specifications -> GLS -> PDF for more information about Glucose Service and Record Access Control Point format.




回答2:


The characteristic you are trying to 'read' is most probably NOT readable, but can be delivered through a 'Notification' or an 'Indication' callback method. You'd better check first if this Characteristic is 'Notifiable' and/or 'Indicatable' and then, set up the required callback events in your code: - write the DescriptorValue as being 'notifiable' and/or 'indicatable' - register a callback event for this characteristic.



来源:https://stackoverflow.com/questions/45029498/reading-from-a-notify-characteristic-ionic-bluetooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!