ccollins476ad commented on issue #480: Allow GATT services to be registered 
after startup
   I may have misunderstood your comment initially.  Just to clarify: different 
packages can register their own services individually.  For example, the 
`net/nimble/host/services/` packages do this.  When `ble_gatts_start()` is 
called, all registered services become available.  The sequence might look 
something like this:
   * Package 1 registers services A, B, and C.
   * Package 2 registers service D.
   * App registers services E and F.
   * App calls `ble_gatts_start()`
   At the end of this sequence, all the services (A, B, C, D, E, and F) are 
supported and available to peers.
   This is how service registration has always worked in the nimble host.
   This PR allows the app to perform the above sequence a second time, with a 
different set of services.  The second sequence would look like this:
   * Call `ble_gatts_reset()`
   * Register services G and H.
   * Register services I and J.
   * Call `ble_gatts_start()`
   Now, services G, H, I, and J are available to peers.
   The point I'm trying to make is: not all services need to be registered at 
the same time in a single array.  I am not sure if you thought that was the 
   Anyway, when I first read your comment, I thought you were referring to the 
need to call `ble_gatts_start()` to make all the registered services available. 
 This is somewhat of a burden, because it prevents a package from registering 
additional services on the fly without cooperation from the application.  I did 
look at eliminating the need for the final call to `ble_gatts_start()`, and I 
think this would be quite difficult to achieve.  The main issue is that the 
host allocates one CCCD entry per connection per subscribable characteristic.  
For example, with 4 max connections and 5 subscribable characteristics, the 
host would allocate 20 entries (4*5).  To help keep memory usage to a minimum, 
the host does not allocate these entries until registration is complete.  The 
call to `ble_gatts_start()` is what tells the host that registration is 
   I probably should have explained the motivation for this PR.  The motivation 
is: blehostd needs to allow the user to register GATT services.  The user 
interfaces with blehostd via JSON messages sent over a unix domain socket.  By 
time the user is able to communicate with blehostd, blehostd has already 
initialized and started the nimble host.  To allow the user to register 
services, blehostd has to provide the ability to reset its GATT state and 
accept new service registration calls.
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

Reply via email to