2

Looking at various GATT-based profiles, it seems that services are always exposed in the GATT server rather than the GATT client. For instance, the Time Profile (TIP) has the server exposing the Current Time Service (CTS). So, if a phone is to update a heart rate monitor with the current time using TIP, the phone will be the server whereas the monitor will be the client. But, being a heart rate monitor, the Heart Rate Profile expects the monitor to be a GATT server.

So, for a monitor that takes the current time from a phone, should it be a GATT client or server? Should it be set as a client whilst time syncing with the phone and set as a server otherwise? Should a custom profile be implemented such that the CTS is exposed in the client instead?

Thanks

John M.
  • 2,642
  • 7
  • 26
  • 55

1 Answers1

4

Generic Attribute Profile (GATT) defines how server and client communicate with each other using Attribute Protocol for the purpose of transporting data. Client and server roles are determined when a procedure is initiated and released when the procedure is ended. Hence, a device can act in both roles at the same time.

I would suggest you to read Bluetooth Spec. In Part G 2.2 it explains the roles and configurations.

Client—This is the device that initiates commands and requests towards the server and can receive responses, indications and notifications sent by the server. Server—This is the device that accepts incoming commands and requests from the client and sends responses, indications and notifications to a client.

Back to your question:

The Time profile enables the device to get the date, time, time zone, and DST information and control the functions related the time.

In your case, the monitor will be the GATT client when it takes the time from a phone. However, it can be a server at the same time for another procedure (operation, request etc.) with the phone.

In short, client and server roles are not fixed to the devices. When your phone exposes the current time, it will be server. Similarly, when it gets the current time from the monitor, it will be client. no need to customize the profile. If you want your phone to get the current time from a device and expose it to another device, just implement the same profile for client and server roles to your phone.

EDIT:
According to TIP profile spec, to get the current time information, the GATT Read Characteristic Value sub-procedure shall be used with the handle of the Current Time Characteristic. Monitor as a client will read the Current Time Characteristic from the GATT Table of the server (in this case it is the phone). As soon as the monitor retrieves the value from phone, it can update its Current Time Characteristic Value, and expose it to its environment in three ways:

  1. Notifying it to its subscribed clients (BLE notifications). If you do it in this way, you will customize the Bluetooth TIP profile since this procedure is not defined there (I had a quick look to the document and didn't see it).
  2. Broadcasting it in the advertisement packet (Doesn't require BLE connection)
  3. Another BLE device connects to the monitor and reads the Current Time Characteristic value. This is the recommended way if you want to use Bluetooth SIG defined TIP profile as a server.
ulusoyca
  • 841
  • 9
  • 18
  • I see. So do you mean that when the monitor needs to time-sync with the phone, it should become a GATT client - even when it may already be a GATT server? Thus, during that period, it'd be both a GATT client and a GATT server at the same time. When time-sync completes, it falls back down to being a GATT server - is that correct? – John M. Dec 19 '15 at 10:21
  • The monitor should be a GATT server for the Heart Rate Profile though. Does that mean it'd have to switch from being a client to being a server after syncing completes? – John M. Dec 20 '15 at 12:22
  • What do you mean by switching? I mean how do you switch between the roles? – ulusoyca Dec 20 '15 at 15:38
  • That's in fact my concern. In that case, do you mean that the monitor shall be both a GATT client and a GATT server simultaneously throughout the lifetime? If that's the case, would there be potential mayhem for running a device as both a client and a server? – John M. Dec 20 '15 at 15:44
  • It is possible, and usually quite normal, for devices to be both in server and client role. You can avoid asking very elementary questions like these, by just reading up on the correct specifications. The questions you are asking are one of the first subjects that are being discussed when talking about GATT and GATT clients and servers. – Zimano Dec 21 '15 at 10:25