feat(ble): 添加快速广告配置并优化连接状态检查
添加了BLE快速广告相关的配置选项到prj.conf中,包括快速广告间隔、超时等参数。 同时修复了ble_bond_module中的连接状态检查逻辑,避免在挂起后保留LE连接时进行不必要的 断开操作。 在ble_hid_module和usb_hid_module中改进了HID传输事件处理逻辑,确保在相应模式未激活 或连接未建立时正确提交传输完成事件,提高了设备响应的准确性。 BREAKING CHANGE: 广告行为在连接保持情况下有所改变,可能影响配对流程。
This commit is contained in:
@@ -215,6 +215,23 @@ static void disconnect_le_conn_cb(struct bt_conn *conn, void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
static void mark_le_conn_found_cb(struct bt_conn *conn, void *user_data)
|
||||
{
|
||||
bool *found = user_data;
|
||||
|
||||
ARG_UNUSED(conn);
|
||||
*found = true;
|
||||
}
|
||||
|
||||
static bool has_any_le_conn(void)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
bt_conn_foreach(BT_CONN_TYPE_LE, mark_le_conn_found_cb, &found);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
struct peer_bond_lookup {
|
||||
const bt_addr_le_t *peer_addr;
|
||||
bool found;
|
||||
@@ -532,7 +549,16 @@ static bool app_event_handler(const struct app_event_header *aeh)
|
||||
if (bond.state == BLE_BOND_STATE_STANDBY) {
|
||||
bond.state = BLE_BOND_STATE_IDLE;
|
||||
module_set_state(MODULE_STATE_READY);
|
||||
submit_peer_op_event(PEER_OPERATION_SELECTED, bond.storage.cur_peer_id);
|
||||
/*
|
||||
* If a LE link survived suspend, keep it untouched. CAF ble_adv
|
||||
* treats PEER_OPERATION_SELECTED as a real identity switch and
|
||||
* will disconnect the current peer. If no link exists, re-emit
|
||||
* the selection so advertising resumes on the selected slot.
|
||||
*/
|
||||
if (!has_any_le_conn()) {
|
||||
submit_peer_op_event(PEER_OPERATION_SELECTED,
|
||||
bond.storage.cur_peer_id);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user