Bluetooth: GATT: Add support for static services

This reintroduces support for static service in the form of a new API,
BT_GATT_SERVICE_DEFINE, and changes the internal services (GAP/GATT)
to be defined as const as they are never register/unregistered.

Internal service needed to be renamed in order to keep the same order
as before since the section elements are sorted by name.

The result is the following (make ram_report):

before:
      gatt.c                                    572     0.66%
        cf_cfg                                   32     0.04%
        db                                        8     0.01%
        db_hash                                  16     0.02%
        db_hash_work                             32     0.04%
        gap_attrs				180     0.21%
        gap_svc                                  12     0.01%
        gatt_attrs                              160     0.18%
        gatt_sc                                  80     0.09%
        gatt_svc                                 12     0.01%
        sc_ccc_cfg                               32     0.04%
        subscriptions                             8     0.01%

after:
      gatt.c                                    210     0.24%
        cf_cfg                                   32     0.04%
        db                                        8     0.01%
        db_hash                                  16     0.02%
        db_hash_work                             32     0.04%
        gatt_sc                                  80     0.09%
        last_static_handle                        2     0.00%
        sc_ccc_cfg                               32     0.04%
        subscriptions                             8     0.01%

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2019-04-15 15:42:50 +03:00 committed by Johan Hedberg
commit e0f3ab6bf2
4 changed files with 139 additions and 45 deletions

View file

@ -67,6 +67,13 @@
__net_l2_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
SECTION_DATA_PROLOGUE(_bt_services_area,,SUBALIGN(4))
{
_bt_services_start = .;
KEEP(*(SORT_BY_NAME("._bt_services.static.*")))
_bt_services_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#if defined(CONFIG_BT_SETTINGS)
SECTION_DATA_PROLOGUE(_bt_settings_area,,SUBALIGN(4))
{