nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches

◆ BT_NSMS_DEF

#define BT_NSMS_DEF ( _nsms,
_name,
_slevel,
_status_init,
_len_max )

#include <include/bluetooth/services/nsms.h>

Value:
static K_MUTEX_DEFINE(_CONCAT(_nsms, _status_mtx)); \
static char _CONCAT(_nsms, _status_buf)[_len_max] = _status_init; \
static const struct bt_nsms_status_str _CONCAT(_nsms, _status_str) = { \
.mtx = &_CONCAT(_nsms, _status_mtx), \
.size = (_len_max), \
.buf = _CONCAT(_nsms, _status_buf) \
}; \
BT_NSMS_SERVICE_DEF(_CONCAT(_nsms, _svc), \
BT_GATT_PRIMARY_SERVICE(BT_UUID_NSMS_SERVICE), \
BT_GATT_CHARACTERISTIC(BT_UUID_NSMS_STATUS, \
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, \
_BT_NSMS_CH_READ_PERM(_slevel), \
NULL, \
(void *)&_CONCAT(_nsms, _status_str)), \
BT_GATT_CCC(NULL, _BT_NSMS_CH_READ_PERM(_slevel) | \
_BT_NSMS_CH_WRITE_PERM(_slevel)), \
BT_GATT_CUD(_name, _BT_NSMS_CH_READ_PERM(_slevel)), \
); \
static const struct bt_nsms _nsms = { \
.status_attr = &_CONCAT(_nsms, _svc).attrs[2], \
}
#define BT_UUID_NSMS_SERVICE
Definition nsms.h:35
#define BT_UUID_NSMS_STATUS
Definition nsms.h:36
ssize_t bt_nsms_status_read(struct bt_conn *conn, struct bt_gatt_attr const *attr, void *buf, uint16_t len, uint16_t offset)
Nordic Status Message Service reading command.
char * buf
Definition nsms.h:46
The status.
Definition nsms.h:40
Nordic Status Message Service structure.
Definition nsms.h:53

Create the Nordic Status Message Service instance.

This macro creates the Nordic Status Message Service instance and prepares it to work. Note that it allows to implement multiple instances and the only difference between them would be the name.

Parameters
_nsmsName of Status Message Service instance.
_nameNULL terminated string used as a CUD for Status Message Characteristic.
_slevelSecurity level to use the characteristic.
  • BT_NSMS_SECURITY_LEVEL_AUTHEN - requires authentication
  • BT_NSMS_SECURITY_LEVEL_ENCRYPT - encryption is sufficient
  • BT_NSMS_SECURITY_LEVEL_NONE and other values - none
_status_initInitial message.
_len_maxMaximal size of the message. The size of the message buffer.