nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
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...
 

Macros

#define BLE_UUID_NUS_SERVICE   0x0001
 
#define BLE_NUS_MAX_DATA_LEN   (GATT_MTU_SIZE_DEFAULT - 3)
 

Typedefs

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.
 

Functions

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 S110 SoftDevice. The service is used by the application to send and receive ASCII text strings to and from the peer.

Note
The application must propagate S110 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

#define BLE_NUS_MAX_DATA_LEN   (GATT_MTU_SIZE_DEFAULT - 3)

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.

Parameters
[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 S110 SoftDevice. This function processes the event if it is relevant and calls the Nordic UART Service event handler of the application if necessary.

Parameters
[in]p_nusNordic UART Service structure.
[in]p_ble_evtEvent received from the S110 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.

Parameters
[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.