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

How to change baudrate of BLE central device?

Hi,

I am using two devices in which one is running with ble_app_uart code which is ble_peripheral device and another is running with ble_app_uart_c code which is central device.  Peripheral device can be configured to the different baud rates through the commands, but there is a disconnection issue while each device is running with different baud rate. So need to configure the baud rate of central device.

How it can be done?

Parents Reply Children
  • I am not doing anything on Central device, but on peripheral device I will be sending commands from mobile phone to change the baud rate.The command is ab below

    static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
    {
        
        char data[10];
    	  uint32_t i;
    	
        for (i = 0; i < length; i++)
        {
            while(app_uart_put(p_data[i]) != NRF_SUCCESS);
    			  data[i]=p_data[i];
        }
        while(app_uart_put('\n') != NRF_SUCCESS);
    		// Added- For changing the baud rate dynamically
    		if(strstr(data,"BAUD9600")!=NULL)
    		{
    			app_uart_close();
    			baud_rate= UART_BAUDRATE_BAUDRATE_Baud9600;
    			uart_init();
    		}
    		if(strstr(data,"BAUD57600")!=NULL)
    		{
    			app_uart_close();
    			baud_rate= UART_BAUDRATE_BAUDRATE_Baud57600;
    			uart_init();
    		}
    }

    Same as this I wanted to do it in central device. Is there any possibility?

  • sorry for late response, uart_init could fail, check if it has failed due to some reason. Please do not ignore the return value of the functions.

Related