You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2019/09/13 13:33:01 UTC

[mynewt-nimble] 31/32: apps/bttester: Add Include Service

This is an automated email from the ASF dual-hosted git repository.

naraj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit fc113f13d41fa051ca9003093df0721de3f25df0
Author: MichaƂ Narajowski <mi...@codecoup.pl>
AuthorDate: Fri Aug 30 15:47:17 2019 +0200

    apps/bttester: Add Include Service
---
 apps/bttester/src/gatt.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/apps/bttester/src/gatt.c b/apps/bttester/src/gatt.c
index 79fc47f..6f2cdc5 100644
--- a/apps/bttester/src/gatt.c
+++ b/apps/bttester/src/gatt.c
@@ -135,12 +135,36 @@ gatt_svr_dsc_read_write_long_test(uint16_t conn_handle, uint16_t attr_handle,
 				  struct ble_gatt_access_ctxt *ctxt,
 				  void *arg);
 
+static const struct ble_gatt_svc_def gatt_svr_inc_svcs[] = {
+	{
+		.type = BLE_GATT_SVC_TYPE_PRIMARY,
+		.uuid = PTS_UUID_DECLARE(PTS_INC_SVC),
+		.characteristics = (struct ble_gatt_chr_def[]) {{
+			.uuid = PTS_UUID_DECLARE(PTS_CHR_READ_WRITE_ALT),
+			.access_cb = gatt_svr_read_write_test,
+			.flags = BLE_GATT_CHR_F_WRITE |
+				 BLE_GATT_CHR_F_READ,
+		}, {
+		0,
+		} },
+	},
+
+	{
+		0, /* No more services. */
+	},
+};
+
+static const struct ble_gatt_svc_def *inc_svcs[] = {
+	&gatt_svr_inc_svcs[0],
+	NULL,
+};
 
 static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
 	{
 		/*** Service: PTS test. */
 		.type = BLE_GATT_SVC_TYPE_PRIMARY,
 		.uuid = PTS_UUID_DECLARE(PTS_SVC),
+		.includes = inc_svcs,
 		.characteristics = (struct ble_gatt_chr_def[]) { {
 			.uuid = PTS_UUID_DECLARE(PTS_CHR_READ_WRITE),
 			.access_cb = gatt_svr_read_write_test,
@@ -295,6 +319,7 @@ gatt_svr_read_write_test(uint16_t conn_handle, uint16_t attr_handle,
 
 	switch (uuid16) {
 	case PTS_CHR_READ_WRITE:
+	case PTS_CHR_READ_WRITE_ALT:
 		if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
 			rc = gatt_svr_chr_write(conn_handle, attr_handle,
 						ctxt->om, 0,
@@ -1995,6 +2020,16 @@ int gatt_svr_init(void)
 {
 	int rc;
 
+	rc = ble_gatts_count_cfg(gatt_svr_inc_svcs);
+	if (rc != 0) {
+		return rc;
+	}
+
+	rc = ble_gatts_add_svcs(gatt_svr_inc_svcs);
+	if (rc != 0) {
+		return rc;
+	}
+
 	rc = ble_gatts_count_cfg(gatt_svr_svcs);
 	if (rc != 0) {
 		return rc;