Thanks Sai Kalyana Raman, now I understand your question.
I did a quick look. As in the doc you pointed out, Section 7.2, the 1st sentence:
"To define a GATT Database at run-time, the gGattDbDynamic_d macro must be defined in app_preinclude.h with the value equal to 1."
And if we search the macro gGattDbDynamic_d in file gatt_database.c, the codes look like:
#if !gGattDbDynamic_d
... ...
/*! Declare the Attribute database */
gattDbAttribute_t static_gattDatabase[] = {
#include "gatt_decl_x.h"
};
gattDbAttribute_t* gattDatabase = static_gattDatabase;
... ...
#else
gattDbAttribute_t* gattDatabase;
uint16_t gGattDbAttributeCount_c;
#endifSo this looks clear to me the Static and Dynamic should be mutual exclusive. At least the code is designed in such way.
If the macro is defined as "1" dynamic, the application needs to allocate an array and assign the pointer to gattDatabase, and count value to gGattDbAttributeCount_c
If the macro is defined as "0" static, the BLE static will allocate a static_gattDatabase[] for you.
I hope this answered your question.
If there is a use case where a dynamic GATT database must be used, why not try to config all your 5x services in the dynamic way?
What I would do is:
(1) Create dynamic GATT database with X services.
(2) Make BLE connection, and do a service discovery
(3) Do the BLE thing as needed.
(4) If we want to update the GATT database structure, I'd disconnect first.
(5) Update dynamically (i.e. in run-time) GATT database with Y services.
(6) Reconnect, and make another service discovery, this is needed so the GATT client knows your database has been changed.
(7) Continue with updated GATT database.
Kind regards,
Xiang