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

UART not working in nRF52832 as an observer role only.

I am using a nRF52832 which act as an observer role only and what is observe it send observed data to another device over UART.

When i turn off scanning and just run UART it works properly but when scanning is on it doesn't send any data on UART. When I add a break point on UART function then it again works.

The program doesn't stuck at any point and it continuously scan the advertising data. I am not getting whats going wrong with UART.

I have added the UART function 'app_uart_put' in that function 'find_adv_uuid()'

Parents
  • I have just edit the ble_app_hrs_c central example and add the UART code from UART example.

    Finally put a uart function in find uuid function.

    Have a look on following function Observer +UART.rar

    static bool find_adv_uuid(const ble_gap_evt_adv_report_t *p_adv_report, const uint16_t uuid_to_find)
     {
    
        //Send data on UART
        while (app_uart_put('1') != NRF_SUCCESS);
    
    
      uint32_t err_code;
      data_t   adv_data;
      data_t   type_data;
    
      // Initialize advertisement report for parsing.
      adv_data.p_data     = (uint8_t *)p_adv_report->data;
      adv_data.data_len   = p_adv_report->dlen;
    
      err_code = adv_report_parse(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE,
                                &adv_data,
                                &type_data);
    
     
    
    
    uint8_t uuid_start = 9;
    uint8_t uuid_end = 24;
    
    uint8_t major_start = 25;
    uint8_t major_end = 26;
    uint8_t minor_start = 27;
    uint8_t minor_end = 28;
    
    int chk =1;
    int j=0;
    int sec=1;
    
    for (int i =uuid_start; i<=uuid_end;i++)
    { 
    	if (p_adv_report->data[i] == uuid_two[j])
    	{
    		sec++;
    		if (sec==17)
    			nrf_gpio_pin_toggle(LED1);
    	}
    	else if (p_adv_report->data[i] == uuid_one[j])
    	{
    		chk++;
    		if(chk ==17)
    			nrf_gpio_pin_toggle(LED);		
    	}	
    }
    j++;
    
    }
    return false;
    

    }

    When It found the nearby device then LED blinks but not data send over UART. When I run it in debugger then it works fine and send data over UART.

Reply
  • I have just edit the ble_app_hrs_c central example and add the UART code from UART example.

    Finally put a uart function in find uuid function.

    Have a look on following function Observer +UART.rar

    static bool find_adv_uuid(const ble_gap_evt_adv_report_t *p_adv_report, const uint16_t uuid_to_find)
     {
    
        //Send data on UART
        while (app_uart_put('1') != NRF_SUCCESS);
    
    
      uint32_t err_code;
      data_t   adv_data;
      data_t   type_data;
    
      // Initialize advertisement report for parsing.
      adv_data.p_data     = (uint8_t *)p_adv_report->data;
      adv_data.data_len   = p_adv_report->dlen;
    
      err_code = adv_report_parse(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE,
                                &adv_data,
                                &type_data);
    
     
    
    
    uint8_t uuid_start = 9;
    uint8_t uuid_end = 24;
    
    uint8_t major_start = 25;
    uint8_t major_end = 26;
    uint8_t minor_start = 27;
    uint8_t minor_end = 28;
    
    int chk =1;
    int j=0;
    int sec=1;
    
    for (int i =uuid_start; i<=uuid_end;i++)
    { 
    	if (p_adv_report->data[i] == uuid_two[j])
    	{
    		sec++;
    		if (sec==17)
    			nrf_gpio_pin_toggle(LED1);
    	}
    	else if (p_adv_report->data[i] == uuid_one[j])
    	{
    		chk++;
    		if(chk ==17)
    			nrf_gpio_pin_toggle(LED);		
    	}	
    }
    j++;
    
    }
    return false;
    

    }

    When It found the nearby device then LED blinks but not data send over UART. When I run it in debugger then it works fine and send data over UART.

Children
Related