PINE64
bluetooth GATT questions - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PineTime (https://forum.pine64.org/forumdisplay.php?fid=134)
+--- Forum: Development Discussion on PineTime (https://forum.pine64.org/forumdisplay.php?fid=136)
+--- Thread: bluetooth GATT questions (/showthread.php?tid=14382)



bluetooth GATT questions - wilsonjw - 07-07-2021

Can someone help clear up my understanding of bluetooth services and attributes on Infinitime? I figured out how to set date and time using gatttool, but am confused as to why there are three different characteristics associated with the CurrentTime service, and how I could have found that out from the source code instead of trial and error with gatttool until I found something that looked like a time and date code.

In Infinitime/src/components/ble/CurrentTimeService.h, I can see that ctsId sets the UUID of the CurrentTime service to 0x1805. gatttool tells me this has three characteristics with handles 17, 18, and 19. Handle 19 has the date and time, and gatttool can set time on the watch with char-write-cmd. But what are handles 17 and 18 doing? And where in the source code are these characteristics defined?

Thanks,


RE: bluetooth GATT questions - danielt - 07-08-2021

I've not been involved in (or even read) the implementation in Infinitime but the spec for the current time service is here (https://www.bluetooth.com/specifications/specs/current-time-service-1-1/ ) and I note that two of the three specified characteristics are optional.


RE: bluetooth GATT questions - wilsonjw - 07-08-2021

Thank you, @danielt .

Following a link in the doc you mentioned, I found this list of UUIDs. That must make it easy for companion app (GadgetBridge, etc.) developers if everyone sticks to the standards when declaring their services. Sure enough:
  • UUID 1805 is the Current Time Service, which is defined in CurrentTimeService.h. 
  • UUID 2a2b (handle 19 that I referred to earlier) is the current time characteristic, which is also defined in CurrentTimeService.h
  • UUID 2800 (handle 17) is a service declaration (?), I found a definition for it in one of the nimble headers
  • UUID 2803 (handle 18) is a GATT characteristic declaration (?), I found that also in a nimble header.
So I guess InfiniTime has implemented only one of the three characteristics you mentioned (uuid 2a2b) and the other three are just part of the GATT protocol? I found a book chapter about GATT that I think will clear it up.