Nordic UART Service implementation.
More...
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.
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 for initializing the Nordic UART Service.
- Parameters
-
[out] | p_nus | Nordic 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_init | Information needed to initialize the service. |
- Return values
-
NRF_SUCCESS | If the service was successfully initialized. Otherwise, an error code is returned. |
NRF_ERROR_NULL | If either of the pointers p_nus or p_nus_init is NULL. |
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_nus | Nordic UART Service structure. |
[in] | p_ble_evt | Event 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_nus | Pointer to the Nordic UART Service structure. |
[in] | p_string | String to be sent. |
[in] | length | Length of the string. |
- Return values
-
NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned. |