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

Multilink Example - long time needed to establish connection and enable notifications

The m_client_count is like instantly increased when I power up another (or the first) peripheral.

But with increasing connection interval the time till the central finally enables notifications on the peripheral is dramatically increased - why is that?

peripheral - main.c - Connected and bonded with nRFMaster Panel and notifications enabled in no time -> Problem is the central?

RTT Output:

It seems like the time is indeed lost/needed for securing the link. As the first few lines come in pretty fast. Looking at the clock I would say

Scan gestartet // of course instant as always
GAP_EVT_ADV_REPORT // from here
EVT_DEVICE_CONTEXT_LOADED
EVT_CONNECTION
GAP_EVT_ADV_REPORT
EVT_DEVICE_CONTEXT_LOADED
EVT_CONNECTION
GAP_EVT_ADV_REPORT
EVT_DEVICE_CONTEXT_LOADED
EVT_CONNECTION
GAP_EVT_ADV_REPORT
EVT_DEVICE_CONTEXT_LOADED
EVT_CONNECTION // till here only a few seconds (3~4)
EVT_LINK_SECURED //but to reach this takes the biggest part
DM_EVT_LINK_SECURED
0;0;97962;22826;0;0;0;0
0;0;97965;22820;0;0;0;0
0;0;97964;22826;0;0;0;0
0;0;97963;22840;0;0;0;0
EVT_LINK_SECURED
DM_EVT_LINK_SECURED
0;0;97966;22843;0;0;0;0
0;0;97958;22850;0;0;0;0
0;0;97950;22843;0;0;0;0
0;0;97950;22850;98044;22856;0;0
0;0;97951;22856;98040;22846;0;0
0;0;97953;22863;98044;22860;0;0
EVT_LINK_SECURED
DM_EVT_LINK_SECURED
0;0;97952;22856;98046;22853;0;0
0;0;97945;22856;98042;22860;0;0
0;0;97946;22856;98041;22863;0;0
0;0;97945;22863;98028;22860;97952;22713
0;0;97946;22863;98033;22870;97951;22706
0;0;97952;22866;98032;22870;97954;22706
EVT_LINK_SECURED
DM_EVT_LINK_SECURED
0;0;97944;22860;98031;22876;97956;22716
0;0;97949;22866;98025;22870;97955;22713
0;0;97947;22870;98024;22883;97955;22716
98015;22686;97941;22870;98023;22876;97944;22726
98017;22696;97945;22873;98021;22886;97940;22726

Above with 4seconds conn_int => >2,5minutes till 4th peripheral send first measurement.

With 50ms it is quite fast. (Same time for the evt_conn but like no time for link_secured for all 4 peripherals vs. ~40seconds each with 4second interval.)

30seconds till last peripheral is link_secured with 500ms interval.

So what is the easiest way to change connection intervall after all inks are secured?

central - main.c

central - client_handling.c

//Edit:

image description

The measurements on the left come in fine.. the 1*interval delay (2nd from top) can happen..

But on the right the 4times connection interval doesn't make sense to me. at least I can't explain it..

4s timer on peripherals does: Measurement + sd_ble_gatts_hvx();

4s timer on central ouputs the values received by

	case BLE_GATTC_EVT_HVX:
	for (int i=0; i<8; i++) {
	empf_buffer[i] = p_ble_evt->evt.gattc_evt.params.hvx.data[i];
	}
	modul_nr = empf_buffer[7];
	zaehler[modul_nr] = 0;
	druck[modul_nr] = empf_buffer[0]<<16 | empf_buffer[1]<<8 | empf_buffer[2];
	temperatur[modul_nr] = empf_buffer[3]<<16 | empf_buffer[4]<<8 | empf_buffer[5];
	spannung[modul_nr] = empf_buffer[6];

so no buffering of data.. or does sd_ble_gatts_hvx(); a sort of buffering?

  • I just left my workplace so I can't try out anything till tomorrow. But for advertise and scanning it is:

    APP_ADV_INTERVAL                   MSEC_TO_UNITS(20, UNIT_0_625_MS)
    
    SCAN_INTERVAL                    0x0029                                         /** in units of 0.625 millisecond. */
    SCAN_WINDOW                      0x0028                                         /** in units of 0.625 millisecond. */
    

    Connection interval at beginning 4000ms when it takes 37seconds.. down to 5seconds with 50ms interval e.g.

    Is there a way to log time with RTT?

    I am back atr work now and put in some more RTT_printfs...

    It seems like the time is indeed lost/needed for securing the link. As the first few lines come in pretty fast. Looking at the clock I would say

    Scan gestartet // of course instant as always
    GAP_EVT_ADV_REPORT // from here
    EVT_DEVICE_CONTEXT_LOADED
    EVT_CONNECTION
    GAP_EVT_ADV_REPORT
    EVT_DEVICE_CONTEXT_LOADED
    EVT_CONNECTION
    GAP_EVT_ADV_REPORT
    EVT_DEVICE_CONTEXT_LOADED
    EVT_CONNECTION
    GAP_EVT_ADV_REPORT
    EVT_DEVICE_CONTEXT_LOADED
    EVT_CONNECTION // till here only a few seconds (3~4)
    EVT_LINK_SECURED //but to reach this takes the biggest part
    DM_EVT_LINK_SECURED
    0;0;97962;22826;0;0;0;0
    0;0;97965;22820;0;0;0;0
    0;0;97964;22826;0;0;0;0
    0;0;97963;22840;0;0;0;0
    EVT_LINK_SECURED
    DM_EVT_LINK_SECURED
    0;0;97966;22843;0;0;0;0
    0;0;97958;22850;0;0;0;0
    0;0;97950;22843;0;0;0;0
    0;0;97950;22850;98044;22856;0;0
    0;0;97951;22856;98040;22846;0;0
    0;0;97953;22863;98044;22860;0;0
    EVT_LINK_SECURED
    DM_EVT_LINK_SECURED
    0;0;97952;22856;98046;22853;0;0
    0;0;97945;22856;98042;22860;0;0
    0;0;97946;22856;98041;22863;0;0
    0;0;97945;22863;98028;22860;97952;22713
    0;0;97946;22863;98033;22870;97951;22706
    0;0;97952;22866;98032;22870;97954;22706
    EVT_LINK_SECURED
    DM_EVT_LINK_SECURED
    0;0;97944;22860;98031;22876;97956;22716
    0;0;97949;22866;98025;22870;97955;22713
    0;0;97947;22870;98024;22883;97955;22716
    98015;22686;97941;22870;98023;22876;97944;22726
    98017;22696;97945;22873;98021;22886;97940;22726
    

    Above with 4seconds conn_int - >2,5minutes till 4th peripheral send first measurement. With 50ms it is quite fast. (Same time for the evt_conn but like no time for link_secured for all 4 peripherals vs. ~40seconds each with 4second interval. 30seconds till last peripheral is link_secured with 500ms interval.

    So what again is the easiest way to change connection intervall after all inks are secured?

  • @muhkuhns: I strongly recommend you to get hold of a nRF51 dongle, or nRF51 DK kit to use as a sniffer to sniff the connection. I saw you mentioned that you have a nRF51 DK , so it should be possible. With the sniffer trace we can easily spot what cause the slow encryption.

  • Why is there no application for Windows 8 to sniff BLE :( I bought a Windows 8.1 tablet with Bluetooth 4.0 and BLE compatible.. but there is just no useful software :/

    I need to get another module then to act as a central.. the problem is my modules are based on revision 1 and the DK on rev3.. so I can't just use on of them to act as a central.. to free up the DK for use as a sniffer

    I got another module now bases on rev 2 chip and without the 32mhz clock so I changed the centrals sd init function to use NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION and the ram size to 0x2000 But it does not seem to work..

    www.i-syst.com/.../IMM-NRF51822_RefMan.pdf

  • @muhkuhns: The nRF51 DK or nRF51 dongle wouldn't cost much more than a module when offering much more features. So I would suggest you to get one.

    Windows 8.x should work fine with the nRFSniffer , but not the Windows 8.x RT. You would need a Surface Pro tablet. Note that you still need to connect a dongle/DK to the PC to be able to sniff.

  • Of course my tablet is running real Windows 8.1, not RT. I would just like to be able to use the internal chip..

    Also I got ONE nRF51-DK! But it can't act as central and sniffer at once. And I am not going to let the university buy another one just for this one time use during my master-thesis.

    It should be possible to track down the problem without a sniffer.. 37seconds between connection and link secured with 4000ms conn_int. It shouldn't take that long, right?

Related