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

Problem with slow advertising nRF51 SDK9

I use SDK 9 and nrF51 in the advertising mode. I want to advertise each 1s packets. First, I call function

set_adv_params(&m_adv_params);

where I

static void set_adv_params(ble_gap_adv_params_t * adv_params)

{ memset(adv_params, 0, sizeof(ble_gap_adv_params_t));

adv_params->type        	= BLE_GAP_ADV_TYPE_ADV_IND;
adv_params->p_peer_addr 	= NULL;
adv_params->fp          	= BLE_GAP_ADV_FP_ANY;
adv_params->interval	    = 1600;
adv_params->timeout     	= 180;

}

Than

sd_ble_gap_adv_start(&m_adv_params);

It is work. But I see very strange behavior. When I insert battery in my deevice, after few time I see that adv packet send and central received it. Repeat, first start and advertise is fast. When I out of range from ble device, central loss adv packet and disconnect it. After that I again close peripherial to central and central again received adv packets but with some delay (5-8 seconds). I mean same program started on the peripherial without reset. What reason of this strange behavior?

  • Are you actually connecting (pairing) the central to the peripheral, or is your central just listening to the advertisement packets from the peripheral?

  • Central connect via static passkey to pheriferial. But I think that pheriferial has no problem. I can see on my oscilloscope consumption every adertising time period. For me it is 1 S. But central sometimes can't see pheriferial 5-10 seconds! Why? I send adv packets every 1S. Any idea?

  • Hello Mikhail

    I suspect the reason you see such varying delays before your central detects your peripheral is due an unlucky choice of advertising interval and scan interval/window.

    Your peripheral only advertises once every second, during which time it advertises sequentially on all three advertisement channels. The duration of this broadcast is very short.

    Your central is configured with a scan window and interval, and will look for the peripheral once per scan interval, for the time specified by the scan window, and in only one channel at a time. With a long advertisement interval as you have the central and peripheral intervals might "miss" one another, so that the peripheral isn't advertising when the central is looking for it.

    Please see section A in this blog post for more details on how central and peripheral behaves during advertisement devzone.nordicsemi.com/.../

    You could try to change your peripherals advertisement interval, or the central's scan interval and window, to see if you get a more predictable result.

    Best regards

    Jørn Frøysa

  • Thanks, J0rn, for datailed answer. Yes, I try to change scan window in my central before. Could You advise me what better for my case shoul I settings? Now my settings in central is:

    #define SCAN_INTERVAL           160
    #define SCAN_WINDOW                158
    

    or better make 160 and 160 both? or better will another digits? power consumption for central doesn't matter. Peripherial- from battery. This behavior of central- is it only in scan window setup?

  • I don't think having them both at 160 would be a good idea. 160 corresponds to 100 ms, so you are looking for the advertiser for 100 ms, and then waiting 100 ms. In the long run you end up with a periodicity which aligns with the advertiser, meaning that in an ideal world you would always miss the advertisement, if you missed it the first time. You could try using Scan interval 160 and scan window 320 as a start. If I'm not mistaken that should guarantee you catch the next advertisement if you miss the first.

Related