This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to receive UART-BLE from peripheral

Hi there! I'm using the nRF Toolbox's UART to test the receiving of my data stream. I'm trying to send a data array collected (from spi) in my main loop and send it via UART-BLE to my mobile phone. However, on the Toolbox app, I'm not receiving any string from my peripheral even though I called ble_nus_string_send.

//Global variable

bool ble_connected = false;


----------


static void on_ble_evt(ble_evt_t * p_ble_evt)
{
	
	
	switch (p_ble_evt->header.evt_id)
	{
		case BLE_GAP_EVT_CONNECTED:
			ble_connected = true;
			m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
			break;
			
		case BLE_GAP_EVT_DISCONNECTED:
			ble_connected = false;
			m_conn_handle = BLE_CONN_HANDLE_INVALID;
			break;
    }
}


----------


int main (void) 
{
   
/* SPI data comes in and gets stored into array data_array */
    
        data_array[0] = something;
        data_array[1] = something;
        data_array[2] = something;

         if(ble_connected)
      
          ble_nus_string_send(&m_nus, data_array, length_of_data_array)
}
  • FormerMember
    0 FormerMember

    To be able to transmit data from your device (server) to the phone (client), the phone will first have to enable notifications on the server side. A server is not allowed to transmit notifications unless the client has enabled it. Enabling of notifications happens after a connection has been established.

    To enable notifications, the client has to write to the CCCD of the characteristic in question. Part 1 of this video tutorial introduces CCCDs at approximately 17:00, and continues to talk about data transfer/notifications from 19:30 to 22:40. In part 2 of the tutorial, the code walk through goes through how notifications are enabled at the server time, that part starts at approximately 14:50.

  • Hi Kristin, thanks for the resp. I get the basic idea that (i) the client(smartphone) establishes the connection with the server(nRF), then (ii) the client(smartphone) writes to the CCCD register of the server(nRF). Am I able to test it out using the nRF Toolbox's UART-BLE? Or am I suppose to use the nRF Connect to write to the CCCD and then switch to nRF Toolbox's UART-BLE?

    Also, once my new SPI data is read to the nRF, I plan to use UART-BLE to send it over to the client. Am I able to use the ble_nus_string_send function to do so after enabling the CCCD?

    Sorry, I'm getting a little lost here. Am I right to say I don't have to change anything in the code here, but just have the client write to the CCCD of BLE-NUS before I use ble_nus_string_send?

  • Used the nRF Connect app to turn on the CCCD of BLE-NUS then switched to nRF Toolbox to see the datastream.

  • FormerMember
    0 FormerMember in reply to FormerMember

    Both nRF Connect and nRF Toolbox --> UART should work for testing the UART example ble_app_uart. Both of them can write to the CCCD of the UART service and enable notifications.

    "Am I right to say I don't have to change anything in the code here, but just have the client write to the CCCD of BLE-NUS before I use ble_nus_string_send?" Yes, that's correct.

Related