Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
nus.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_H_
8#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_H_
9
12#include <zephyr/sys/slist.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
23#define BT_UUID_NUS_SRV_VAL \
24 BT_UUID_128_ENCODE(0x6e400001, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
25#define BT_UUID_NUS_RX_CHAR_VAL \
26 BT_UUID_128_ENCODE(0x6e400002, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
27#define BT_UUID_NUS_TX_CHAR_VAL \
28 BT_UUID_128_ENCODE(0x6e400003, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
29
35#define BT_NUS_INST_DEFINE(_name) \
36 Z_INTERNAL_BT_NUS_INST_DEFINE(_name)
37
39struct bt_nus_cb {
46 void (*notif_enabled)(bool enabled, void *ctx);
47
55 void (*received)(struct bt_conn *conn, const void *data, uint16_t len, void *ctx);
56
58 void *ctx;
59
61 sys_snode_t _node;
62};
63
77int bt_nus_inst_cb_register(struct bt_nus_inst *inst, struct bt_nus_cb *cb, void *ctx);
78
93int bt_nus_inst_send(struct bt_conn *conn,
94 struct bt_nus_inst *inst,
95 const void *data,
96 uint16_t len);
97
107static inline int bt_nus_cb_register(struct bt_nus_cb *cb, void *ctx)
108{
109 return bt_nus_inst_cb_register(NULL, cb, ctx);
110}
111
125static inline int bt_nus_send(struct bt_conn *conn, const void *data, uint16_t len)
126{
127 return bt_nus_inst_send(conn, NULL, data, len);
128}
129
130#ifdef __cplusplus
131}
132#endif
133
134
135#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_H_ */
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
static int bt_nus_cb_register(struct bt_nus_cb *cb, void *ctx)
NUS server callback register.
Definition: nus.h:107
int bt_nus_inst_cb_register(struct bt_nus_inst *inst, struct bt_nus_cb *cb, void *ctx)
NUS server Instance callback register.
static int bt_nus_send(struct bt_conn *conn, const void *data, uint16_t len)
Send Data over NUS.
Definition: nus.h:125
int bt_nus_inst_send(struct bt_conn *conn, struct bt_nus_inst *inst, const void *data, uint16_t len)
Send Data to NUS Instance.
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Callbacks for getting notified on NUS Service occurrences.
Definition: nus.h:39
void(* notif_enabled)(bool enabled, void *ctx)
Notifications subscription changed.
Definition: nus.h:46
void * ctx
Internal member.
Definition: nus.h:58
void(* received)(struct bt_conn *conn, const void *data, uint16_t len, void *ctx)
Received Data.
Definition: nus.h:55
Definition: inst.h:18
Bluetooth UUID handling.