/* Function for handling Handle Value Notification received from the SoftDevice. 
This function will uses the Handle Value Notification received from the SoftDevice and checks if it is a notification of the NUS RX characteristic from the peer. If it is, this function will decode the data and send it to the application. */
static void on_hvx(ble_nus_c_t *p_ble_nus_c, const ble_evt_t *p_ble_evt)
/* Function for handling Handle Value Notification received from the SoftDevice. 
This function will uses the Handle Value Notification received from the SoftDevice and checks if it is a notification of the NUS RX characteristic from the peer. If it is, this function will decode the data and send it to the application. */
static void on_hvx(ble_nus_c_t *p_ble_nus_c, const ble_evt_t *p_ble_evt)
{
    if ( (p_ble_nus_c->handles.nus_rx_handle != BLE_GATT_HANDLE_INVALID)
            && (p_ble_evt->evt.gattc_evt.params.hvx.handle == p_ble_nus_c->handles.nus_rx_handle)
            && (p_ble_nus_c->evt_handler != NULL)
        )
    {
        ble_nus_c_evt_t ble_nus_c_evt;
        ble_nus_c_evt.evt_type = BLE_NUS_C_EVT_NUS_RX_EVT;
        ble_nus_c_evt.p_data   = (uint8_t *)p_ble_evt->evt.gattc_evt.params.hvx.data;
        ble_nus_c_evt.data_len = p_ble_evt->evt.gattc_evt.params.hvx.len;
        p_ble_nus_c->evt_handler(p_ble_nus_c, &ble_nus_c_evt);
    }
}