15#ifndef BLE_NUS_CLIENT_H__
16#define BLE_NUS_CLIENT_H__
19#include <bm/bluetooth/ble_common.h>
20#include <bm/bluetooth/ble_db_discovery.h>
21#include <bm/bluetooth/ble_gq.h>
22#include <bm/softdevice_handler/nrf_sdh_ble.h>
33#define BLE_NUS_CLIENT_DEF(_name) \
34 static struct ble_nus_client _name; \
35 NRF_SDH_BLE_OBSERVER(_name##_obs, ble_nus_client_on_ble_evt, &_name, HIGH)
38#define BLE_NUS_UUID_BASE { 0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, \
39 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E }
42#define BLE_UUID_NUS_SERVICE 0x0001
44#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0002
46#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0003
52#define BLE_NUS_CLIENT_MAX_DATA_LEN_CALC(mtu_size) ((mtu_size) - ATT_OPCODE_LEN - ATT_HANDLE_LEN)
58#ifndef BLE_NUS_CLIENT_MAX_DATA_LEN
59#define BLE_NUS_CLIENT_MAX_DATA_LEN \
60 (BLE_NUS_CLIENT_MAX_DATA_LEN_CALC(CONFIG_NRF_SDH_BLE_GATT_MAX_MTU_SIZE))
uint32_t ble_nus_client_init(struct ble_nus_client *nus_client, const struct ble_nus_client_config *nus_client_config)
Initialize the Nordic UART client service.
uint32_t ble_nus_client_tx_notif_disable(struct ble_nus_client *nus_client)
Request the peer to stop sending notification of TX characteristic.
uint32_t ble_nus_client_handles_assign(struct ble_nus_client *nus_client, uint16_t conn_handle, const struct ble_nus_client_handles *peer_handles)
Assign handles to this instance of the service.
ble_nus_client_evt_type
NUS Client event type.
Definition ble_nus_client.h:66
@ BLE_NUS_CLIENT_EVT_DISCOVERY_COMPLETE
Definition ble_nus_client.h:68
@ BLE_NUS_CLIENT_EVT_ERROR
Definition ble_nus_client.h:74
@ BLE_NUS_CLIENT_EVT_DISCONNECTED
Definition ble_nus_client.h:72
@ BLE_NUS_CLIENT_EVT_TX_DATA
Definition ble_nus_client.h:70
uint32_t ble_nus_client_tx_notif_enable(struct ble_nus_client *nus_client)
Request the peer to start sending notification of TX characteristic.
uint32_t ble_nus_client_string_send(struct ble_nus_client *nus_client, const uint8_t *string, uint16_t length)
Send a string to the server.
void(* ble_nus_client_evt_handler_t)(struct ble_nus_client *ble_nus_c, const struct ble_nus_client_evt *evt)
Nordic UART Service Client event handler type.
Definition ble_nus_client.h:129
void ble_nus_client_on_ble_evt(const ble_evt_t *ble_evt, void *ble_nus_client)
Bluetooth LE event handler for the Nordic UART Service Client.
void ble_nus_client_on_db_disc_evt(struct ble_nus_client *nus_client, const struct ble_db_discovery_evt *evt)
Handle events from the Database Discovery library.
Bluetooth LE database discovery event.
Definition ble_db_discovery.h:61
Bluetooth LE database discovery.
Definition ble_db_discovery.h:122
Bluetooth LE GATT Queue.
Definition ble_gq.h:238
ble_nus_client_evt_handler_t evt_handler
Definition ble_nus_client.h:141
struct ble_db_discovery * db_discovery
Definition ble_nus_client.h:145
const struct ble_gq * gatt_queue
Definition ble_nus_client.h:143
Definition ble_nus_client.h:139
enum ble_nus_client_evt_type evt_type
Definition ble_nus_client.h:96
struct ble_nus_client_evt::@118::@121 tx_data
uint32_t reason
Definition ble_nus_client.h:115
struct ble_nus_client_evt::@118::@122 disconnected
struct ble_nus_client_evt::@118::@123 error
uint8_t * data
Definition ble_nus_client.h:108
uint16_t conn_handle
Definition ble_nus_client.h:98
struct ble_nus_client_handles handles
Definition ble_nus_client.h:103
struct ble_nus_client_evt::@118::@120 discovery_complete
uint16_t length
Definition ble_nus_client.h:110
Nordic UART Service Client event structure.
Definition ble_nus_client.h:94
uint16_t nus_tx_handle
Definition ble_nus_client.h:82
uint16_t nus_rx_handle
Definition ble_nus_client.h:86
uint16_t nus_tx_cccd_handle
Definition ble_nus_client.h:84
Handles of the connected peer device, as provided by a discovery.
Definition ble_nus_client.h:80
struct ble_nus_client_handles handles
Definition ble_nus_client.h:159
const struct ble_gq * gatt_queue
Definition ble_nus_client.h:163
uint16_t conn_handle
Definition ble_nus_client.h:157
ble_nus_client_evt_handler_t evt_handler
Definition ble_nus_client.h:161
uint8_t uuid_type
Definition ble_nus_client.h:153
NUS Client structure.
Definition ble_nus_client.h:151