Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
inst.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Croxel, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_INST_H_
8#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_INST_H_
9
12#include <zephyr/sys/slist.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
25
26#define BT_UUID_NUS_SERVICE BT_UUID_DECLARE_128(BT_UUID_NUS_SRV_VAL)
27#define BT_UUID_NUS_TX_CHAR BT_UUID_DECLARE_128(BT_UUID_NUS_TX_CHAR_VAL)
28#define BT_UUID_NUS_RX_CHAR BT_UUID_DECLARE_128(BT_UUID_NUS_RX_CHAR_VAL)
29
31ssize_t nus_bt_chr_write(struct bt_conn *conn, const struct bt_gatt_attr *attr,
32 const void *buf, uint16_t len, uint16_t offset, uint8_t flags);
33void nus_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value);
34
35#define Z_INTERNAL_BT_NUS_INST_DEFINE(_name) \
36 \
37BT_GATT_SERVICE_DEFINE(_name##_svc, \
38 BT_GATT_PRIMARY_SERVICE(BT_UUID_NUS_SERVICE), \
39 BT_GATT_CHARACTERISTIC(BT_UUID_NUS_TX_CHAR, \
40 BT_GATT_CHRC_NOTIFY, \
41 BT_GATT_PERM_NONE, \
42 NULL, NULL, NULL), \
43 BT_GATT_CCC(nus_ccc_cfg_changed, \
44 BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), \
45 BT_GATT_CHARACTERISTIC(BT_UUID_NUS_RX_CHAR, \
46 BT_GATT_CHRC_WRITE | \
47 BT_GATT_CHRC_WRITE_WITHOUT_RESP, \
48 BT_GATT_PERM_WRITE, \
49 NULL, nus_bt_chr_write, NULL), \
50); \
51 \
52sys_slist_t _name##_cbs = SYS_SLIST_STATIC_INIT(&_name##_cbs); \
53 \
54STRUCT_SECTION_ITERABLE(bt_nus_inst, _name) = { \
55 .svc = &_name##_svc, \
56 .cbs = &_name##_cbs, \
57}
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_INST_H_ */
Generic Attribute Profile handling.
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:49
ssize_t nus_bt_chr_write(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
Required as the service may be instantiated outside of the module.
void nus_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
__SIZE_TYPE__ ssize_t
Definition types.h:28
flags
Definition parser.h:96
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
GATT Attribute.
Definition gatt.h:224
GATT Service structure.
Definition gatt.h:304
Definition inst.h:18
const struct bt_gatt_service_static * svc
Pointer to the NUS Service Instance
Definition inst.h:20
sys_slist_t * cbs
List of subscribers to invoke callbacks on asynchronous events.
Definition inst.h:23