nRF5 SDK v11.0.0
Data Structures | Macros | Typedefs | Functions
Nordic UART Service

Nordic UART Service implementation. More...

Data Structures

struct  ble_nus_init_t
 Nordic UART Service initialization structure. More...
struct  ble_nus_s
 Nordic UART Service structure. More...


#define BLE_UUID_NUS_SERVICE   0x0001


typedef struct ble_nus_s ble_nus_t
typedef void(* ble_nus_data_handler_t )(ble_nus_t *p_nus, uint8_t *p_data, uint16_t length)
 Nordic UART Service event handler type.


uint32_t ble_nus_init (ble_nus_t *p_nus, const ble_nus_init_t *p_nus_init)
 Function for initializing the Nordic UART Service. More...
void ble_nus_on_ble_evt (ble_nus_t *p_nus, ble_evt_t *p_ble_evt)
 Function for handling the Nordic UART Service's BLE events. More...
uint32_t ble_nus_string_send (ble_nus_t *p_nus, uint8_t *p_string, uint16_t length)
 Function for sending a string to the peer. More...

Detailed Description

Nordic UART Service implementation.

The Nordic UART Service is a simple GATT-based service with TX and RX characteristics. Data received from the peer is passed to the application, and the data received from the application of this service is sent to the peer as Handle Value Notifications. This module demonstrates how to implement a custom GATT-based service and characteristics using the SoftDevice. The service is used by the application to send and receive ASCII text strings to and from the peer.

The application must propagate SoftDevice events to the Nordic UART Service module by calling the ble_nus_on_ble_evt() function from the ble_stack_handler callback.

Macro Definition Documentation


Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module.

#define BLE_UUID_NUS_SERVICE   0x0001

The UUID of the Nordic UART Service.

Function Documentation

uint32_t ble_nus_init ( ble_nus_t p_nus,
const ble_nus_init_t p_nus_init 

Function for initializing the Nordic UART Service.

[out]p_nusNordic UART Service structure. This structure must be supplied by the application. It is initialized by this function and will later be used to identify this particular service instance.
[in]p_nus_initInformation needed to initialize the service.
Return values
NRF_SUCCESSIf the service was successfully initialized. Otherwise, an error code is returned.
NRF_ERROR_NULLIf either of the pointers p_nus or p_nus_init is NULL.
void ble_nus_on_ble_evt ( ble_nus_t p_nus,
ble_evt_t p_ble_evt 

Function for handling the Nordic UART Service's BLE events.

The Nordic UART Service expects the application to call this function each time an event is received from the SoftDevice. This function processes the event if it is relevant and calls the Nordic UART Service event handler of the application if necessary.

[in]p_nusNordic UART Service structure.
[in]p_ble_evtEvent received from the SoftDevice.
uint32_t ble_nus_string_send ( ble_nus_t p_nus,
uint8_t *  p_string,
uint16_t  length 

Function for sending a string to the peer.

This function sends the input string as an RX characteristic notification to the peer.

[in]p_nusPointer to the Nordic UART Service structure.
[in]p_stringString to be sent.
[in]lengthLength of the string.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.

Documentation feedback | Developer Zone | Updated