20#include <bm/bluetooth/ble_common.h>
21#include <bm/softdevice_handler/nrf_sdh_ble.h>
28#define BLE_NUS_UUID_BASE { 0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, \
29 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E }
32#define BLE_UUID_NUS_SERVICE 0x0001
34#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0002
36#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0003
44#define BLE_NUS_DEF(_name) \
45 static struct ble_nus _name; \
46 NRF_SDH_BLE_OBSERVER(_name##_obs, ble_nus_on_ble_evt, &_name, HIGH)
49#define BLE_NUS_CONFIG_SEC_MODE_DEFAULT \
52 .read = BLE_GAP_CONN_SEC_MODE_OPEN, \
53 .write = BLE_GAP_CONN_SEC_MODE_OPEN, \
56 .read = BLE_GAP_CONN_SEC_MODE_OPEN, \
57 .cccd_write = BLE_GAP_CONN_SEC_MODE_OPEN, \
65#define BLE_NUS_MAX_DATA_LEN_CALC(mtu_size) ((mtu_size) - ATT_OPCODE_LEN - ATT_HANDLE_LEN)
71#define BLE_NUS_MAX_DATA_LEN BLE_NUS_MAX_DATA_LEN_CALC(CONFIG_NRF_SDH_BLE_GATT_MAX_MTU_SIZE)
150 ble_gap_conn_sec_mode_t
read;
228 uint16_t conn_handle);
void(* ble_nus_evt_handler_t)(struct ble_nus *nus, const struct ble_nus_evt *evt)
Nordic UART Service event handler type.
Definition ble_nus.h:126
void ble_nus_on_ble_evt(const ble_evt_t *ble_evt, void *ble_nus)
Bluetooth LE event handler for the Nordic UART Service.
uint32_t ble_nus_init(struct ble_nus *nus, const struct ble_nus_config *nus_config)
Function for initializing the Nordic UART Service.
ble_nus_evt_type
Nordic UART Service event types.
Definition ble_nus.h:74
@ BLE_NUS_EVT_TX_RDY
Service is ready to accept new data to be transmitted.
Definition ble_nus.h:82
@ BLE_NUS_EVT_COMM_STOPPED
Notification has been disabled.
Definition ble_nus.h:90
@ BLE_NUS_EVT_COMM_STARTED
Notification has been enabled.
Definition ble_nus.h:86
@ BLE_NUS_EVT_ERROR
Error event.
Definition ble_nus.h:94
@ BLE_NUS_EVT_RX_DATA
Data received.
Definition ble_nus.h:78
uint32_t ble_nus_data_send(struct ble_nus *nus, uint8_t *data, uint16_t *length, uint16_t conn_handle)
Send data on the NUS TX characteristic as a notification.
ble_nus_evt_handler_t evt_handler
Definition ble_nus.h:137
struct ble_nus_config::@115::@117 nus_tx_char
struct ble_nus_config::@115::@116 nus_rx_char
ble_gap_conn_sec_mode_t read
Definition ble_nus.h:143
ble_gap_conn_sec_mode_t cccd_write
Definition ble_nus.h:152
struct ble_nus_config::@115 sec_mode
ble_gap_conn_sec_mode_t write
Definition ble_nus.h:145
Nordic UART Service initialization structure.
Definition ble_nus.h:135
uint16_t conn_handle
Definition ble_nus.h:106
struct ble_nus_evt::@111::@114 error
const uint8_t * data
Definition ble_nus.h:111
uint32_t reason
Definition ble_nus.h:118
struct ble_nus_evt::@111::@113 rx_data
uint16_t length
Definition ble_nus.h:113
enum ble_nus_evt_type evt_type
Definition ble_nus.h:104
Nordic UART Service event structure.
Definition ble_nus.h:102
ble_gatts_char_handles_t rx_handles
Definition ble_nus.h:170
ble_gatts_char_handles_t tx_handles
Definition ble_nus.h:168
uint8_t uuid_type
Definition ble_nus.h:164
uint16_t service_handle
Definition ble_nus.h:166
ble_nus_evt_handler_t evt_handler
Definition ble_nus.h:172
Nordic UART Service structure.
Definition ble_nus.h:162