1 /**
2 * Copyright (c) 2019 Oticon A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 /**
7 * @brief Service E
8 *
9 * This code is auto-generated from the Excel Workbook
10 * 'GATT_Test_Databases.xlsm' Sheet: 'Large Database 2'
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 /**
20 * @brief UUID for the Service E
21 */
22 #define BT_UUID_SERVICE_E BT_UUID_DECLARE_16(0xa00e)
23
24 /**
25 * @brief UUID for the Value V13 Characteristic
26 */
27 #define BT_UUID_VALUE_V13 BT_UUID_DECLARE_16(0xb00d)
28
29 static uint8_t value_v13_value = 0x0D;
30
31 /**
32 * @brief Attribute read call back for the Value V13 attribute
33 *
34 * @param conn The connection that is requesting to read
35 * @param attr The attribute that's being read
36 * @param buf Buffer to place the read result in
37 * @param len Length of data to read
38 * @param offset Offset to start reading from
39 *
40 * @return Number of bytes read, or in case of an error - BT_GATT_ERR()
41 * with a specific ATT error code.
42 */
read_value_v13(struct bt_conn * conn,const struct bt_gatt_attr * attr,void * buf,uint16_t len,uint16_t offset)43 static ssize_t read_value_v13(struct bt_conn *conn,
44 const struct bt_gatt_attr *attr, void *buf,
45 uint16_t len, uint16_t offset)
46 {
47 const uint8_t *value = attr->user_data;
48
49 return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
50 sizeof(value_v13_value));
51 }
52
53 static struct bt_gatt_attr service_e_2_attrs[] = {
54 BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_E, 0xFFFD),
55 BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V13,
56 BT_GATT_CHRC_READ,
57 BT_GATT_PERM_READ,
58 read_value_v13, NULL, &value_v13_value, 0xFFFE)
59 };
60
61 static struct bt_gatt_service service_e_2_svc =
62 BT_GATT_SERVICE(service_e_2_attrs);
63
64 /**
65 * @brief Register the Service E and all its Characteristics...
66 */
service_e_2_init(void)67 void service_e_2_init(void)
68 {
69 bt_gatt_service_register(&service_e_2_svc);
70 }
71
72 /**
73 * @brief Un-Register the Service E and all its Characteristics...
74 */
service_e_2_remove(void)75 void service_e_2_remove(void)
76 {
77 bt_gatt_service_unregister(&service_e_2_svc);
78 }
79