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

ble_app_uart getting stuck when connected

I was doing some works with ble_app_uart in nrf51822. I have added some modification in the main function according to my requirements. What i have to do is, read data over the ble and do some works according to the received data. Now i am facing some problem. The problem is that when i connect my app to the nrf51822 the controller stops the execution of my code and waits for the ble data as long as the device is connected. when the device is disconnected it resumes the normal execution. I have to make this device to execute my code while the device is connected to the app. How can i achieve this thing? Some times the nrf51822 is automatically restarts. Why this is happening? What is this power_manage() function doing?

  • Seems like there are two things.

    1. some bug in your code that is triggered only after the connection is established.
    1. sometimes chip restarts means that some function returned error, and the APP_ERROR_CHECK macro will by default reset your chip if the error code is not NRF_SUCCESS

    It is difficult to analyze more without some code snippets. Can you post your code?

  • Thanks for the fast reply. My doubt , is that the nrf 51822 is capable of executing other codes while it is connected.

  • Did you try commenting the power_manage() function?

    During the initial stages of our development, we were stuck in power_manage() function.

  • Yes, your application can do some other things while the connection is active, Normal things that application do are data transfer or handling events happening through the connection. Not limited to the connection, it can do anything it want just considering that the connection will steal some of the CPU time from application. Maintaining the connection is done in the highest thread priority.

  • But what i am seeing is that , it is stopping the execution of the normal code and waits as long as it is connected. I will post the snippet, can you give me any solution. below code is the event handling function

    enter code here

        static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t                         err_code;
        
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    						data_length=0;
    				new_data=true;
    				
    				
    				
    				break;
                
            case BLE_GAP_EVT_DISCONNECTED:										
    
    					
    					data_end=true;				//* ========== FLAG FOR NEW DATA INDICATION ============ *//
    		      new_data=false;
    																
    				 err_code = bsp_indication_set(BSP_INDICATE_IDLE);
             APP_ERROR_CHECK(err_code);
             m_conn_handle = BLE_CONN_HANDLE_INVALID;	
    						
              break;
    
            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_SYS_ATTR_MISSING:
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
    
            default:
                // No implementation needed.
                break;
        }
    }
    
Related