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

Start scaning right after starting advertising.

I use sdk 9.0.0, softdevice s130, nrf51422_xxac. In my application I have to both scan and advertise. When I start one of them (scanning or advertising) application starts running properly but when I start them both my application not always starts executing properly (sometimes it looks like processor is executing total mess and I have to restart it, using button, few times till it starts executing properly). In my code I call starting functions consecutively:

err = ble_advertising_start(BLE_ADV_MODE_FAST); 
APP_ERROR_CHECK(err);
err = sd_ble_gap_scan_start(&scan_params); 

The order of calling these 2 functions does not change anything. In ble_gap.h I did not realize any function for checking if softdevice is ready to start next functionality. I lack ideas what is the reason of such behaviour.

Parents
  • /**< Determines scan interval in units of 0.625 millisecond. */                  
    #define SCAN_INTERVAL 0x00A0    /** < 0.1 s */  
    
                                     
    /**< Determines scan window in units of 0.625 millisecond. */                    
    #define SCAN_WINDOW 0x0050      /** < 0.05 s */                                  
                                                                                 
    static ble_gap_adv_params_t bc_adv_params;                                       
                                                                                     
    static const ble_gap_scan_params_t scan_params = { 0,// Active scanning not set  
                                                     0,// Selective scanning not set. 
                                                    NULL, // White-list not set.     
                                     (uint16_t)SCAN_INTERVAL, // Scan interval.       
                                    (uint16_t)SCAN_WINDOW,   // Scan window.         
                             0 /* Never stop scanning unless explicitly asked to */};
    
    #define APP_ADV_FAST_INTERVAL            0x0028 // 25 ms                         
    #define APP_ADV_SLOW_INTERVAL            0x0C80 // 2 sec                         
    #define APP_ADV_FAST_TIMEOUT             0 // sec                                
    #define APP_ADV_SLOW_TIMEOUT             0 
    

    I use fast advertising. Sorry Aryan I have not answered in comment but it was easier and more clear.

  • I use Linux so my debugging tool is arm-none-eabi-gdb. I have tried watch uart_count if uart_count > 100 to stop my program to see when this value gets so high. Unfortunately gdb stops every time uart_count is changed but because of active soft device I got into hard fault after long breaks. I know that cortex M0 supports hardware watchpoints but do you know if supporting conditional hardware watchpoints is something else ?

Reply
  • I use Linux so my debugging tool is arm-none-eabi-gdb. I have tried watch uart_count if uart_count > 100 to stop my program to see when this value gets so high. Unfortunately gdb stops every time uart_count is changed but because of active soft device I got into hard fault after long breaks. I know that cortex M0 supports hardware watchpoints but do you know if supporting conditional hardware watchpoints is something else ?

Children
No Data
Related