This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Removing the Generic Attribute (0x1801) primary service if the Service Changed characteristic is not present

Setting the gatts_enable_params.service_changed to 0 when enabling softdevice removes (or rather doesn't add) the Service Changed characteristic. That's what I want. However it still leaves behind (adds) the Generic Attribute service which is now empty and left me wondering why it's there although I don't explicitly add it anywhere. Searching the forums yielded some results:


devzone.nordicsemi.com/.../ unanswered

devzone.nordicsemi.com/.../

Generic Attribute Service is mandatory to have, so you are not able to remove this.

however

devzone.nordicsemi.com/.../

so removing this will be possible, most likely in the next softdevice release.


The included links in those answers and additional google searches didn't provide any clear answers. Reading the BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 577 says thus:

7 DEFINED GENERIC ATTRIBUTE PROFILE SERVICE

All characteristics defined within this section shall be contained in a primary service with the service UUID set to «GATT Service» as defined in Section 3.1. Only one instance of the GATT service shall be exposed on a GATT server.

Table 7.1

Table 7.1 lists characteristics that may be present in the server and the characteristics that may be supported by the client.

C1: Mandatory if service definitions on the server can be added, changed or removed; otherwise optional

This is the only reference I can find to Generic Attribute [Profile] Service and anything mandatory. The way I'm reading this is that

  1. The Service Changed characteristic is only mandatory to be supported by any client
  2. The Service Changed characteristic is not mandatory on the server if the service definitions can't be changed
  3. Although the characteristic shall be contained in the [[GATT Service]], it says nothing about requiring the service if the characteristic is not present.

I admit that I'm not the smartest chip on the board and my specification-reading skills might not be up to par, so maybe I'm wrong. However I just want to understand if it really is mandatory to have the empty service and why. Especially since there are answers from Nordic employees to support either view.

  • Hi,

    Unfortunately all of the Nordic engineers that may have an answer to this seem to be on vacation at the moment (July is summer vacation season in Norway). I will follow up this one, but worst case we will have to wait until someone that knows returns from vacation.

    Regards, Terje

  • Alright that's good to hear, thanks Terje. :) Sorry for the trouble.

  • At the moment it seems to boil down to the following line in the Bluetooth Specification Version 4.2, Vol 3, Part G, 7 DEFINED GENERIC ATTRIBUTE PROFILE SERVICE: "Only one instance of the GATT service shall be exposed on a GATT server." (Our emphasis.) The use of the word "shall", if interpreted as in rfc2119, makes a strong case for one instance of the GATT service being mandatory. (Although the sentence is no doubt somewhat ambiguous.)

  • I parsed that sentence myself when making my initial question, however my take of that was "Only one ... shall" meaning that there shall not be multiple instances of the service. In my opinion BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part C] page 390 supports my interpretation, stating: "The GATT server shall contain the GAP service ..." and (!) "A device shall have only one instance of the GAP service". The latter part is also in the chapter you quoted (with different ordering), but the first part is not. Comparing [Vol 3, Part C] p390 and [Vol 3, Part G] p577, in addition to the SIG-specified profiles I referenced not having the GATT service, still leads me to stay strong in my belief that the empty service is not mandatory.

  • I think I agree. The word "only" at the start of the sentence leads me to think your interpretation is plausible. Remove that word and there is no question the service is mandatory. But the word is there.

    Anyway, I have no clear definite answer at this point in time, unfortunately. All I know for certain is that the SoftDevice will allways include the service even if it is empty. As stated earlier I will follow up the case, and add a request for enabling removal of the service if applicable.

Related