1 /**
2 * Copyright (c) 2019 Oticon A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 /**
7 * @brief Service B.5
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 /**
20 * @brief UUID for the Service B.5
21 */
22 #define BT_UUID_SERVICE_B_5 BT_UUID_DECLARE_16(0xa00b)
23
24 /**
25 * @brief UUID for the Value V8 Characteristic
26 */
27 #define BT_UUID_VALUE_V8 BT_UUID_DECLARE_16(0xb008)
28
29 static uint8_t value_v8_value = 0x08;
30
31 /**
32 * @brief Attribute read call back for the Value V8 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_v8(struct bt_conn * conn,const struct bt_gatt_attr * attr,void * buf,uint16_t len,uint16_t offset)43 static ssize_t read_value_v8(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_v8_value));
51 }
52
53 static struct bt_gatt_attr service_b_5_3_attrs[] = {
54 BT_GATT_H_PRIMARY_SERVICE(BT_UUID_SERVICE_B_5, 0x30),
55 BT_GATT_H_CHARACTERISTIC(BT_UUID_VALUE_V8,
56 BT_GATT_CHRC_READ,
57 BT_GATT_PERM_READ,
58 read_value_v8, NULL, &value_v8_value, 0x31)
59 };
60
61 static struct bt_gatt_service service_b_5_3_svc =
62 BT_GATT_SERVICE(service_b_5_3_attrs);
63
64 /**
65 * @brief Register the Service B.5 and all its Characteristics...
66 */
service_b_5_3_init(void)67 void service_b_5_3_init(void)
68 {
69 bt_gatt_service_register(&service_b_5_3_svc);
70 }
71
72 /**
73 * @brief Un-Register the Service B.5 and all its Characteristics...
74 */
service_b_5_3_remove(void)75 void service_b_5_3_remove(void)
76 {
77 bt_gatt_service_unregister(&service_b_5_3_svc);
78 }
79