Hi Cristoph,

On Fri, Dec 14, 2018 at 04:34:05PM +0100, Christoph Jabs wrote:
> Hello mynewt devs,
> 
> I have a question regarding the mynewt-NimBLE stack.
> 
> Whilst working my way through the code of the stack, trying to understand 
> the structure of it and how to use it, I came accross the functions defined 
> in nimble/host/include/host/ble_gatt.h for initiating GATT procedures. I 
> realized that the functions are all named ble_gatts or ble_gattc (and are 
> devided into two corresponding source files ble_gattc.c and ble_gatts.c) 
> and I assume this devides the functions in server or client side 
> functionality.

All correct.

> However, a four functions seem to break that system. These are the 
> functions for sending notifications or indications to connections. My 
> understanding is that the BLE peripheral (the GATT server) sends 
> notifications to the BLE central (the GATT client). This seems to match the 
> fact that the functions for notifying and indicating are being called in 
> ble_gatts_tx_notifications. Why then are the notification and indication 
> functions labeled gattc?
> 
> Feel free to correct me if i'm missing something or if I completely 
> misunderstand the things these functions do. From my perspective this seems 
> just a bit confusing.

I agree that it is confusing.  Notifications and indications are
peripheral-side (server) procedures, so it is reasonable to look in
`ble_gatts.c` for their corresponding functions.

However, ignoring the Bluetooth spec for a bit, these procedures are
logically client-side operations.  They are unsolicited, and in the case
of indications, the sender needs to listen for an acknowledgement.
These operations have a lot in common with central-initiated procedures,
and very little in common with the others.  As such, the code
implementing these procedures makes use of functions and data structures
that are private (`static`) to the `ble_gattc.c` file, and as a
consequence, these public functions must also go in this file.  And
since the functions are in this file, well... they are named with this
file's prefix :).

I'm not sure if this was the best approach.  It is too late to rename
the functions now (though I suppose we could add some `ble_gatts_...`
aliases).  At the time, I convinced myself that the naming was OK,
because "client" and "server" are general descriptions of the
functionality, and not directly derived from the spec.

Chris

Reply via email to