2024-09-07 11:48 AM - edited 2024-09-07 12:00 PM
What is the proper way of keeping connection from Client to Server alive?
I'm working with smart glasses and after connection STM32 client sends the data, however, after some 10-20 seconds or so glasses show "Client disconnected" message.
What puzzles me is that I constantly send new messages every 2 seconds, so connection should be alive, but it's not.
The other strange thing is when I connect to laptop's Bluetooth, inside LightBlue logs I constantly see fresh messages every 2 seconds continuously as expected, for as long as client device is powered on.
Is there any check to periodically refresh connection state, or what's the right way?
Update: do I need to handle Server's notification in any way to keep connection alive?
2024-09-10 02:51 AM
I found one part of the problem - in this method
result = aci_gap_create_connection(SCAN_P,
SCAN_L,
GAP_PUBLIC_ADDR,
P2P_SERVER1_BDADDR,
GAP_PUBLIC_ADDR,
CONN_P1,
CONN_P2,
0,
SUPERV_TIMEOUT,
CONN_L1,
CONN_L2);
I got much faster connects and response by setting
Connection Interval: 15ms - 30ms
Slave Latency: 0
Supervision Timeout: 4s
The values were taken from "Peripheral Preferred Connection Parameters" characteristic of Server device. You can find them either in documentation or from device itself by reading
Generic Access service - UUID 0x1800
Characteristics:
Peripheral Preferred Connection Parameters | 00002A04-0000-1000-8000-00805F9B34FB |
The client still disconnects, and after timing this with stopwatch I see that Disconnect is happening around every 32 seconds - suspiciously close to maximum possible value of Supervision Timeout
Any ideas why that might happen? I'm pretty sure I'm passing 4s to aci_gap_create_connection and I see the same in p_connection_complete_event->Supervision_Timeout inside HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE
2024-09-25 09:08 AM
Hello @roman_tl
Have you updated your FUS and wireless stack to the last version (available on the V1.20.0 of the SDK).
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.