This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE disconnects after sending a packet

HI,

i am using nrf51422  with sdk13.3.0 and soft device 130

i am receiving 69 byte of data through UART, i am compressing data in two packets. here after transmitting a packet  BLE is disconnected

i don't want BLE to be disconnected after sending a packet. can you please help me to overcome from this.

regards,

Bindushree

void removeChar(char *s, int c,int c_1,int c_2){

    int j, n = strlen(s);
    for (int i=j=0; i<n; i++)
       if ((s[i] != c)&&(s[i]!=c_1)&&(s[i]!=c_2))
          s[j++] = s[i];

    s[j] = '\0';
}

void my_method(char *s)
{
	uint32_t       err_code;
  char ANALOG_DATA[17];	
  removeChar(s, '.','/',':');
        
  char *start=strtok(s,",");
  char *HGS=strtok(NULL,",");
  char *AT_1=strtok(NULL,",");
  char *RT_1=strtok(NULL,",");
  char *EM=strtok(NULL,",");
  char *OUTPUT=strtok(NULL,",");
  char *INPUT=strtok(NULL,",");
  char *FAULT_DATA=strtok(NULL,",");
  char *MODE=strtok(NULL,",");
  char *DATE=strtok(NULL,",");
  char *TIME=strtok(NULL,",");
  char *AT_2=strtok(NULL,",");
  char *RT_2=strtok(NULL,",");
  sprintf(ANALOG_DATA,"%s%s%s%s%s%s%s","A",HGS,AT_1,RT_1,AT_2,RT_2,"#");
	
 err_code=ble_nus_string_send(&m_nus,(uint8_t*)ANALOG_DATA, 17);
  if (err_code != NRF_ERROR_INVALID_STATE)
    {
       APP_ERROR_CHECK(err_code);
    }


}
void uart_event_handle(app_uart_evt_t * p_event)
{
	    

	   uint16_t j;
     char my_data[72];
	   static uint8_t data_array[72];
    
    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
         UNUSED_VARIABLE(app_uart_get(&data_array[index]));
				 index++;
				for(j=0;j<72;j++)
				{
				my_data[j]=data_array[j];
				}
        if ((data_array[0] == '$') && (data_array[68] == '#'))
            {
							
							my_method((char*)my_data);
              							
              index = 0;
            }
           
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;

        default:
            break;
    }
}

Parents
  • Hello,

    Why does the device disconnect?

    Does the connection time out? What are you connected to? Does it give some reason for why it disconnected?

    I assume you use SDK 12.3.0? My initial guess is that ble_nus_string_send returns something other than NRF_SUCCESS.

    Try to define DEBUG in your preprocessor defines, and watch your log (RTT log, not UART). Use J-Link RTT Viewer to monitor the RTT log.

    Best regards,

    Edvin

  • i have not modified any parameters used  in ble_app_uart  example, i only processing the data received through UART

    i sending data from docklight, for the first transmission i am able to receive the packet in mobile app successfully, but if i try to send more than once i am not able to receive the packet and soon after ble will disconnets

    i connected nRF UART app in my mobile

    no it is not giving any reasons for disconnection

    yes i am using SDK 12.3.0

Reply
  • i have not modified any parameters used  in ble_app_uart  example, i only processing the data received through UART

    i sending data from docklight, for the first transmission i am able to receive the packet in mobile app successfully, but if i try to send more than once i am not able to receive the packet and soon after ble will disconnets

    i connected nRF UART app in my mobile

    no it is not giving any reasons for disconnection

    yes i am using SDK 12.3.0

Children
Related