Connection Supervision timeout

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KimS_967071
Level 2
Level 2
10 replies posted 5 sign-ins 5 replies posted

 

I am designing a connectable Peripheral device with a fixed passkey that has no input or output to the user but I do have a debug port during development.  I set the IO capability to Display only for the Authenticated pairing with encryption to work.  I am testing with CySmart on the computer and also using the app on my iphone.  I am able to disconnect using the button on the computer, just removing the dongle while connected, and by quitting the app.  All result in the peripheral performing the BLE disconnect and resuming normal operation of my device.   If I connect to my device with CySmart and perform a read/write of data and then do nothing else the connection does not timeout.  Is the Connection Supervision timeout supposed to result in a disconnection if there is no activity in the timeout period?  I have tested with 10s and 2s.

KimS_967071_0-1677168708633.png

I am sending the update connection parameters to CySmart

KimS_967071_1-1677168922301.png

 

And CySmart appears to take them

KimS_967071_2-1677169020648.png

 

Do I have to do anything else in my peripheral code for this to work?  

 

thanks,

Kim

 

 

 

 

0 Likes
1 Solution
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello, 

Once the BLE devices are connected, if no data is transferring between the devices (central and peripheral), then empty packets will be sent for every connection interval in order to keep the connection. If your peripheral device is shut down (it stops sending the empty packets), then the central device will keep on sending the empty packets until the supervision timeout occurs. The central device will be disconnected if the peripheral device does not respond.

Thanks,

P Yugandhar. 

View solution in original post

0 Likes
3 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello, 

Once the BLE devices are connected, if no data is transferring between the devices (central and peripheral), then empty packets will be sent for every connection interval in order to keep the connection. If your peripheral device is shut down (it stops sending the empty packets), then the central device will keep on sending the empty packets until the supervision timeout occurs. The central device will be disconnected if the peripheral device does not respond.

Thanks,

P Yugandhar. 

0 Likes

Hi @Yugandhar 

Does CyBle_ProcessEvents() take care of the empty packets?  I have print statements for every event in the Event Handler including a default case and I don't have any activity.  I also put a breakpoint in my Event Handler and I never hit it.  

I put a breakpoint at CyBle_ProcessEvents() after I established a connection with CySmart and sat there.  CySmart never timed out or disconnected until I tried to read data.  Then after I disabled my breakpoint and ran I processed the disconnect.  So, the peripheral BLE hardware was talking despite me being at a breakpoint?  Therefore it was still processing empty packets too?  Or, is CySmart not the best way to test this and should I make my own Central?  I had the same result with CySmart on my phone and using the dongle with my computer.

Is there a function for the peripheral to know it is processing empty packets?  I don't want to leave my peripheral connected with no real activity for too long.  I could set a timer and count read/write events and if there are none I could disconnect but a function would be easier.

thanks,

Kim

 

0 Likes
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Internally Link layer will take care of sending the empty packets to the central device(to maintain the connection). If there is a need from the application to process some data then Cy_BLE_ProcessEvents Checks the internal task queue in the BLE stack and processes pending BLE events.
For your application, if you want to disconnect the device after read/write, then you can use the CyBle_GapDisconnect or CyBle_GapDisconnectWithReason API for disconnecting the device. Please refer to the API description in the BLE Component datasheet for more information.

Thanks,
P Yugandhar.

0 Likes