Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Receiving data from nRF UART compared to data from nRF Connect

Hello Nordic community! My setup is pca10040, android tablet, s132, sdk14.2.

This time I am trying to understand why this code:

uint8_t 		string2[40];
uint8_t			siusti_duomenis1[60];
char indentification_string[]="Hello_Simb";
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
	char received_string[81], received_string2[81];

	uint8_t index_to_symbol;
	const char *pointer_to_symbol;
	char *pointer_to_received_string= received_string;

    if (p_evt->type == BLE_NUS_EVT_RX_DATA)
    {	
			received_data_length = p_evt->params.rx_data.length;
			sprintf(received_string,"%s",p_evt->params.rx_data.p_data);	
			received_string[received_data_length]='\0'; // Panaikinami praejusio seanso metu irasyti simboliai ilgesni, nei dabar gauto stringo ilgis.
			
			sprintf(received_string2,"%s",p_evt->params.rx_data.p_data);
			received_string2[received_data_length]='\0'; // Panaikinami praejusio seanso metu irasyti simboliai ilgesni, nei dabar gauto stringo ilgis.
			
			sprintf((char*)string1,"Received from phone:%s\r\n",received_string);
			SEGGER_RTT_WriteString(0, (char*)string1);
			
			
			if(identification_flag == false)
		{
			if( strcmp(received_string,indentification_string) == 0)
			{
				identification_flag = true;
				SEGGER_RTT_WriteString(0,"Identification succedded\n\r");
				sprintf((char*)string2,"Identification succedded\n\r");
				sprintf((char*)siusti_duomenis1,"H:%.2f T:%.2f BATTERY:%d BAT_V:%.2f MYGT:%d",BME280_humidity,BME280_temperature,BAT_PERCENT,BAT_VOLT,mygtukas_nuspaustas);
				ble_nus_string_send(&m_nus,string2,&ilgis_40);
				ble_nus_string_send(&m_nus,siusti_duomenis1,&ilgis_60);
				string2[0] = '\0';
				siusti_duomenis1[0]='\0';
			}
			else
			{
				SEGGER_RTT_WriteString(0,"Identification failed\n\r");
				sprintf((char*)string2,"Identification failed\n\r");
				ble_nus_string_send(&m_nus,string2,&ilgis_40);
				string2[0] = '\0';
			}
		}

While using nrf toolbox nrf UART prints out in RTT viewer "identifiaction failed" message and while using nrf Connect application, i receive "Identification succedded" message? Hoewer I am sending the same: "Hello_simb" string which should be recognised.

If there is lack of data, please, let me know.

Best regards 

Related