NCS 3.1.0 vble connect error at bt_hci_cmd_send_sync()

I am using nrf54l15 with NCS v3.1.0 with the following error when i connect it(i worked in NCS v2.9.1 successfully):

Controller unresponsive, command opcode 0x2035 timeout with err -11 in bt_hci_cmd_send_sync() function;
some error log info:

for matching ncs 3.1.0 I change this code:

bt_hci_cmd_create()  was  deprecated,

So, I modified the functionality implemented with bt_hci_cmd_create to the code shown in the above image. Now it compiles successfully, but when connecting to the device and trying to reset the transmit power, the errors mentioned earlier occur.

My solution is to place set_tx_power inside a k_work_init_delayable for initialization and call it upon connection, while also stopping advertising during the connection. With this approach, the device can now connect successfully.

   

MY BT configs:

CONFIG_BT=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_LOG_LEVEL_WRN=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_CTLR_SDC_TX_PACKET_COUNT=10
CONFIG_BT_BUF_EVT_RX_COUNT=12
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_DATA_LEN_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
I would like to ask whether there is a correct solution to the aforementioned connection issue, or if my current solution is acceptable. If it is, why does modifying it in this way fix the connection problem?

Thank you very much!

Related