BLE advertising 상태 정리
- 연결 성공 시 advertising stop - 이미 advertising 꺼진 경우 -EALREADY 정상 처리 - advertising identity 사용 옵션 추가: BT_LE_ADV_OPT_USE_IDENTITY
This commit is contained in:
+10
-1
@@ -571,6 +571,7 @@ static void connected(struct bt_conn *conn, uint8_t err)
|
||||
|
||||
current_conn = bt_conn_ref(conn);
|
||||
ble_connection_st = true;
|
||||
(void)ble_advertising_stop();
|
||||
ble_tx_power_on_connected(conn); // TX power/RSSI 상태는 별도 모듈에서 관리
|
||||
|
||||
char addr_str[BT_ADDR_LE_STR_LEN];
|
||||
@@ -768,6 +769,7 @@ int ble_service_init(ble_data_rx_cb_t rx_cb)
|
||||
k_work_init_delayable(&pairing_window_timeout_work, pairing_window_timeout_handler);
|
||||
#endif
|
||||
ble_tx_power_init();
|
||||
|
||||
// BLE stack 활성화
|
||||
err = bt_enable(NULL);
|
||||
if (err)
|
||||
@@ -825,7 +827,7 @@ int ble_advertising_start(void)
|
||||
};
|
||||
|
||||
struct bt_le_adv_param adv_param = BT_LE_ADV_PARAM_INIT(
|
||||
BT_LE_ADV_OPT_CONN,
|
||||
BT_LE_ADV_OPT_CONN | BT_LE_ADV_OPT_USE_IDENTITY,
|
||||
APP_ADV_INTERVAL, // min interval
|
||||
APP_ADV_INTERVAL, // max interval
|
||||
NULL // undirected
|
||||
@@ -862,6 +864,13 @@ int ble_advertising_start(void)
|
||||
int ble_advertising_stop(void)
|
||||
{
|
||||
int err = bt_le_adv_stop();
|
||||
if (err == -EALREADY)
|
||||
{
|
||||
k_work_cancel_delayable(&adv_timeout_work);
|
||||
DBG_PRINTF("[BLE] Advertising already stopped\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
DBG_ERR("[BLE] Adv stop failed (err %d)\r\n", err);
|
||||
|
||||
Reference in New Issue
Block a user