Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
nus.h File Reference

Go to the source code of this file.

Data Structures

struct  bt_nus_cb
 Callbacks for getting notified on NUS Service occurrences. More...
 

Macros

#define BT_UUID_NUS_SRV_VAL    BT_UUID_128_ENCODE(0x6e400001, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
 UUIDs of Nordic UART GATT Service.
 
#define BT_UUID_NUS_RX_CHAR_VAL    BT_UUID_128_ENCODE(0x6e400002, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
 
#define BT_UUID_NUS_TX_CHAR_VAL    BT_UUID_128_ENCODE(0x6e400003, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
 
#define BT_NUS_INST_DEFINE(_name)    Z_INTERNAL_BT_NUS_INST_DEFINE(_name)
 Macro to define instance of NUS Service.
 

Functions

int bt_nus_inst_cb_register (struct bt_nus_inst *inst, struct bt_nus_cb *cb, void *ctx)
 NUS server Instance callback register.
 
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.
 
static int bt_nus_cb_register (struct bt_nus_cb *cb, void *ctx)
 NUS server callback register.
 
static int bt_nus_send (struct bt_conn *conn, const void *data, uint16_t len)
 Send Data over NUS.
 

Macro Definition Documentation

◆ BT_NUS_INST_DEFINE

#define BT_NUS_INST_DEFINE (   _name)     Z_INTERNAL_BT_NUS_INST_DEFINE(_name)

Macro to define instance of NUS Service.

It allows users to define multiple NUS instances, analogous to Serial endpoints, and use each one for different purposes. A default NUS instance may be defined through Kconfig.

◆ BT_UUID_NUS_RX_CHAR_VAL

#define BT_UUID_NUS_RX_CHAR_VAL    BT_UUID_128_ENCODE(0x6e400002, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)

◆ BT_UUID_NUS_SRV_VAL

#define BT_UUID_NUS_SRV_VAL    BT_UUID_128_ENCODE(0x6e400001, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)

UUIDs of Nordic UART GATT Service.

Service: 6e400001-b5a3-f393-e0a9-e50e24dcca9e RX Char: 6e400002-b5a3-f393-e0a9-e50e24dcca9e TX Char: 6e400003-b5a3-f393-e0a9-e50e24dcca9e

◆ BT_UUID_NUS_TX_CHAR_VAL

#define BT_UUID_NUS_TX_CHAR_VAL    BT_UUID_128_ENCODE(0x6e400003, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)

Function Documentation

◆ bt_nus_cb_register()

static int bt_nus_cb_register ( struct bt_nus_cb cb,
void *  ctx 
)
inlinestatic

NUS server callback register.

Parameters
cbPointer to callbacks structure. Must be valid throughout the lifetime of the application.
ctxUser context to be provided through the callback.
Returns
0 on success, negative error code if failed.
-EINVAL in case cb is NULL

◆ bt_nus_inst_cb_register()

int bt_nus_inst_cb_register ( struct bt_nus_inst inst,
struct bt_nus_cb cb,
void *  ctx 
)

NUS server Instance callback register.

This function registers callbacks that will be called in certain events related to NUS.

Parameters
instPointer to instance of NUS service. NULL if using default instance.
cbPointer to callbacks structure. Must be valid throughout the lifetime of the application.
ctxUser context to be provided through the callback.
Returns
0 on success
-EINVAL in case cb is NULL

◆ bt_nus_inst_send()

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.

Note
This API sends the data to the specified peer.
Parameters
connConnection object to send data to. NULL if notifying all peers.
instPointer to instance of NUS service. NULL if using default instance.
dataPointer to buffer with bytes to send.
lenLength in bytes of data to send.
Returns
0 on success, negative error code if failed.
-EAGAIN when Bluetooth stack has not been enabled.
-ENOTCONN when either no connection has been established or no peers have subscribed.

◆ bt_nus_send()

static int bt_nus_send ( struct bt_conn *  conn,
const void *  data,
uint16_t  len 
)
inlinestatic

Send Data over NUS.

Note
This API sends the data to the specified peer.
Parameters
connConnection object to send data to. NULL if notifying all peers.
dataPointer to buffer with bytes to send.
lenLength in bytes of data to send.
Returns
0 on success, negative error code if failed.
-EAGAIN when Bluetooth stack has not been enabled.
-ENOTCONN when either no connection has been established or no peers have subscribed.