Commit 3637202c authored by Luiz Augusto von Dentz's avatar Luiz Augusto von Dentz Committed by Anas Nashif
Browse files

Bluetooth: GATT: Ensure GATT service is registered first

Accourding to Bluetooth specification the Service Changed
Characteristic shall not have its handle changed once it has been
bonded, so this moves the GATT service to be the very first service
registered that way it is guaranteed that it won't change even if
device is flashed with a different configuration which end up changing
the handles after it.

Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent a4d57234
Loading
Loading
Loading
Loading
+6 −1
Changes for subsys/bluetooth/host/gatt.c: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -170,6 +170,11 @@ static void sc_ccc_cfg_changed(const struct bt_gatt_attr *attr,

static struct bt_gatt_attr gatt_attrs[] = {
	BT_GATT_PRIMARY_SERVICE(BT_UUID_GATT),
	/* Bluetooth 5.0, Vol3 Part G:
	 * The Service Changed characteristic Attribute Handle on the server
	 * shall not change if the server has a trusted relationship with any
	 * client.
	 */
	BT_GATT_CHARACTERISTIC(BT_UUID_GATT_SC, BT_GATT_CHRC_INDICATE,
			       BT_GATT_PERM_NONE, NULL, NULL, NULL),
	BT_GATT_CCC(sc_ccc_cfg, sc_ccc_cfg_changed),
@@ -285,8 +290,8 @@ void bt_gatt_init(void)
	}

	/* Register mandatory services */
	gatt_register(&gap_svc);
	gatt_register(&gatt_svc);
	gatt_register(&gap_svc);

	k_delayed_work_init(&gatt_sc.work, sc_process);
}