1 /**
2 * Copyright (c) 2019 Oticon A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 /**
7 * @brief Service D
8 *
9 * This code is auto-generated from the Excel Workbook
10 * 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 3'
11 */
12 #include <zephyr/sys/byteorder.h>
13 #include <zephyr/sys/printk.h>
14
15 #include <zephyr/bluetooth/gatt.h>
16
17 #include "gatt_macs.h"
18
19 extern struct bt_gatt_attr service_c_1_3_attrs[];
20
21 /**
22 * @brief UUID for the Service D
23 */
24 #define BT_UUID_SERVICE_D BT_UUID_DECLARE_16(0xa00d)
25
26 /**
27 * @brief UUID for the Value V12 Characteristic
28 */
29 #define BT_UUID_VALUE_V12 BT_UUID_DECLARE_16(0xb00c)
30
31 /**
32 * @brief UUID for the Value V11 (128-bit UUID) Characteristic
33 */
34 #define BT_UUID_VALUE_V11__128_BIT_UUID BT_UUID_DECLARE_128( \
35 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, \
36 0x00, 0x00, 0x00, 0x00, 0x0b, 0xb0, 0x00, 0x00)
37
38 static uint8_t value_v12_value = 0x0C;
39 static uint8_t value_v11__128_bit_uuid_value = 0x0B;
40
41 /**
42 * @brief Attribute read call back for the Value V12 attribute
43 *
44 * @param conn The connection that is requesting to read
45 * @param attr The attribute that's being read
46 * @param buf Buffer to place the read result in
47 * @param len Length of data to read
48 * @param offset Offset to start reading from
49 *
50 * @return Number of bytes read, or in case of an error - BT_GATT_ERR()
51 * with a specific ATT error code.
52 */
read_value_v12(struct bt_conn * conn,const struct bt_gatt_attr * attr,void * buf,uint16_t len,uint16_t offset)53 static ssize_t read_value_v12(struct bt_conn *conn,
54 const struct bt_gatt_attr *attr, void *buf,
55 uint16_t len, uint16_t offset)
56 {
57 const uint8_t *value = attr->user_data;
58
59 return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
60 sizeof(value_v12_value));
61 }
62
63 /**
64 * @brief Attribute read call back for the Value V11 (128-bit UUID) attribute
65 *
66 * @param conn The connection that is requesting to read
67 * @param attr The attribute that's being read
68 * @param buf Buffer to place the read result in
69 * @param len Length of data to read
70 * @param offset Offset to start reading from
71 *
72 * @return Number of bytes read, or in case of an error - BT_GATT_ERR()
73 * with a specific ATT error code.
74 */
read_value_v11__128_bit_uuid(struct bt_conn * conn,const struct bt_gatt_attr * attr,void * buf,uint16_t len,uint16_t offset)75 static ssize_t read_value_v11__128_bit_uuid(struct bt_conn *conn,
76 const struct bt_gatt_attr *attr,
77 void *buf, uint16_t len, uint16_t offset)
78 {
79 const uint8_t *value = attr->user_data;
80
81 return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
82 sizeof(value_v11__128_bit_uuid_value));
83 }
84
85 struct bt_gatt_attr service_d_3_attrs[] = {
86 BT_GATT_H_SECONDARY_SERVICE(BT_UUID_SERVICE_D, 0x20),
87 BT_GATT_H_INCLUDE_SERVICE(service_c_1_3_attrs, 0x21),
88 BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V12,
89 BT_GATT_CHRC_READ,
90 BT_GATT_PERM_READ,
91 read_value_v12, NULL, &value_v12_value, 0x22),
92 BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V11__128_BIT_UUID,
93 BT_GATT_CHRC_READ,
94 BT_GATT_PERM_READ,
95 read_value_v11__128_bit_uuid, NULL,
96 &value_v11__128_bit_uuid_value, 0x24)
97 };
98
99 static struct bt_gatt_service service_d_3_svc =
100 BT_GATT_SERVICE(service_d_3_attrs);
101
102 /**
103 * @brief Register the Service D and all its Characteristics...
104 */
service_d_3_init(void)105 void service_d_3_init(void)
106 {
107 bt_gatt_service_register(&service_d_3_svc);
108 }
109
110 /**
111 * @brief Un-Register the Service D and all its Characteristics...
112 */
service_d_3_remove(void)113 void service_d_3_remove(void)
114 {
115 bt_gatt_service_unregister(&service_d_3_svc);
116 }
117