Bluetooth: GATT: Add GATT service by default
GATT is mandatory service and now that the db can only be build dynamically there is no reason to keep the applications registering it. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
d837a6ec4b
commit
aa5b47fc3f
2 changed files with 24 additions and 1 deletions
|
@ -219,6 +219,11 @@ struct bt_uuid_128 {
|
|||
*/
|
||||
#define BT_UUID_GAP_PPCP BT_UUID_DECLARE_16(0x2a04)
|
||||
#define BT_UUID_GAP_PPCP_VAL 0x2a04
|
||||
/** @def BT_UUID_GATT_SVC_CHANGED
|
||||
* @brief GATT Characteristic Service Changed
|
||||
*/
|
||||
#define BT_UUID_GATT_SC BT_UUID_DECLARE_16(0x2a05)
|
||||
#define BT_UUID_GATT_SC_VAL 0x2a05
|
||||
/** @def BT_UUID_BAS_BATTERY_LEVEL
|
||||
* @brief BAS Characteristic Battery Level
|
||||
*/
|
||||
|
|
|
@ -67,6 +67,22 @@ static struct bt_gatt_attr gap_attrs[] = {
|
|||
read_appearance, NULL, NULL),
|
||||
};
|
||||
|
||||
static struct bt_gatt_ccc_cfg sc_ccc_cfg[CONFIG_BLUETOOTH_MAX_PAIRED] = {};
|
||||
|
||||
static void sc_ccc_cfg_changed(const struct bt_gatt_attr *attr,
|
||||
u16_t value)
|
||||
{
|
||||
BT_DBG("value 0x%04x", value);
|
||||
}
|
||||
|
||||
static struct bt_gatt_attr gatt_attrs[] = {
|
||||
BT_GATT_PRIMARY_SERVICE(BT_UUID_GATT),
|
||||
BT_GATT_CHARACTERISTIC(BT_UUID_GATT_SC, BT_GATT_CHRC_INDICATE),
|
||||
BT_GATT_DESCRIPTOR(BT_UUID_GATT_SC, BT_GATT_PERM_NONE,
|
||||
NULL, NULL, NULL),
|
||||
BT_GATT_CCC(sc_ccc_cfg, sc_ccc_cfg_changed),
|
||||
};
|
||||
|
||||
static int gatt_register(struct bt_gatt_attr *attrs, size_t count)
|
||||
{
|
||||
sys_slist_t list;
|
||||
|
@ -115,6 +131,7 @@ populate:
|
|||
void bt_gatt_init(void)
|
||||
{
|
||||
gatt_register(gap_attrs, ARRAY_SIZE(gap_attrs));
|
||||
gatt_register(gatt_attrs, ARRAY_SIZE(gatt_attrs));
|
||||
}
|
||||
|
||||
int bt_gatt_register(struct bt_gatt_attr *attrs, size_t count)
|
||||
|
@ -123,7 +140,8 @@ int bt_gatt_register(struct bt_gatt_attr *attrs, size_t count)
|
|||
__ASSERT(count, "invalid parameters\n");
|
||||
|
||||
/* Do no allow to register mandatory services twice */
|
||||
if (!bt_uuid_cmp(attrs->uuid, BT_UUID_GAP)) {
|
||||
if (!bt_uuid_cmp(attrs->uuid, BT_UUID_GAP) ||
|
||||
!bt_uuid_cmp(attrs->uuid, BT_UUID_GATT)) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue