Closed mfinmuch closed 3 years ago
Please ensure that you use unique GATT parameter variables for each simultaneous connection. For instance, your cmd_read
which is using the same single static struct bt_gatt_read_params read_params;
across all active connections.
Hello
I'm not sure what you mean, I didn't use cmd_read
, I did bt_gatt_write
on the conn when I received the notify from the peripheral
This should not use the same.
Please ensure that you use unique GATT parameter variables for each simultaneous connection. For instance, your
cmd_read
which is using the same singlestatic struct bt_gatt_read_params read_params;
across all active connections.
@cvinayak
Hello
Or should I modify my bt_gatt_write_params
to be like this?
static struct bt_gatt_write_params write_params[CONFIG_BT_MAX_CONN];
Then when writing, use this to manage?
write_params[bt_conn_index(conn)]
yes, something like that, to avoid using the same memory for multiple simultaneous transactions.
It's like it still didn't solve my problem In the end there was still the problem of ATT timeout error.
yes, something like that, to avoid using the same memory for multiple simultaneous transactions.
In this case, does discover_params also need to be set to
static struct bt_gatt_discover_params discover_params[CONFIG_BT_MAX_CONN];
?
But after I changed it to this, the ATT timeout error still appears
So ATT timeout error, is it a problem that occurs when I use the same memory for multiple transactions at the same time?
is it a problem that occurs when I use the same memory for multiple transactions at the same time?
Yes.
If you have based your application out of an upstream sample. I suggest you send a PR with your changes to make the sample capable of multiple connections simultaneously. This will make it easier to review your changes.
I suggest you send a PR with your changes to make the sample capable of multiple connections simultaneously.
how can I send a PR?I don’t know how to get my code up In addition, I found that I can improve my stability by changing these
#define MIN_CONNECTION_INTERVAL
#define MAX_CONNECTION_INTERVAL
#define SLAVE_LATENCY
#define SUPERVISION_TIMEOUT
Is there any reason for this?
I pulled my code request but I’m not sure if I’m doing this right https://github.com/zephyrproject-rtos/zephyr/pull/30680#issue-538975971
Multiple connections are being established sequntially and gatt service discovery is performed using the same single instance of discover_params
. This is bug in application and not in the Bluetooth Subsystem.
No guard preventing sequential multiple connections: https://github.com/zephyrproject-rtos/zephyr/pull/30680/files#diff-2fcfc31aeea68ed5719fe2686a5507a564ea9c85d0ca14216d6d6953eb7af5f8R452
Use of single instance of discover_params
to perform GATT discovery:
https://github.com/zephyrproject-rtos/zephyr/pull/30680/files#diff-2fcfc31aeea68ed5719fe2686a5507a564ea9c85d0ca14216d6d6953eb7af5f8R574
Resolving as issue in the user's code. Please reopen if you find that not to be the case.
Describe the bug Situation: Modify the example of zephyr BLE central_hr so that it can be connected to multiple peripherals. Each peripheral will subscribe to the central, and then the peripheral uses
notify
to send the data to the central, and the central usesbt_gatt_write
to return the value to the peripheral. Now I use one central to 5 peripherals to test connection stability It will work normally at first, but after a period of time, central will suddenly get stuck and the following error message will pop up.In addition, the time of each error is random Sometimes jump out
<err> bt_gatt: Error sending ATT PDU: -57
And I made the following changes in prj.conf
Expected behavior At present, I want to allow central to communicate with 30 peripherals through BLE, so that the connection will continue to be stable. If the peripheral is disconnected, it will be reconnected, and there will be no bt_att: ATT Timeout error.
Impact I don’t know which side is the problem at the moment, I don’t know what to do, I’m very helpless.
Logs and console output Usually there are errors as shown below Sometimes there will be more
<err> bt_gatt: Error sending ATT PDU
The link is my running video. The first few minutes were normal and met my expectations, but in the end it got stuck and an error occurred https://youtu.be/m5Ki--iXmXw
Environment (please complete the following information):
Additional context This is my central code, if you need to read it, you can download it, hope it helps C_N_w.zip