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);
|
current_conn = bt_conn_ref(conn);
|
||||||
ble_connection_st = true;
|
ble_connection_st = true;
|
||||||
|
(void)ble_advertising_stop();
|
||||||
ble_tx_power_on_connected(conn); // TX power/RSSI 상태는 별도 모듈에서 관리
|
ble_tx_power_on_connected(conn); // TX power/RSSI 상태는 별도 모듈에서 관리
|
||||||
|
|
||||||
char addr_str[BT_ADDR_LE_STR_LEN];
|
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);
|
k_work_init_delayable(&pairing_window_timeout_work, pairing_window_timeout_handler);
|
||||||
#endif
|
#endif
|
||||||
ble_tx_power_init();
|
ble_tx_power_init();
|
||||||
|
|
||||||
// BLE stack 활성화
|
// BLE stack 활성화
|
||||||
err = bt_enable(NULL);
|
err = bt_enable(NULL);
|
||||||
if (err)
|
if (err)
|
||||||
@@ -825,7 +827,7 @@ int ble_advertising_start(void)
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct bt_le_adv_param adv_param = BT_LE_ADV_PARAM_INIT(
|
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, // min interval
|
||||||
APP_ADV_INTERVAL, // max interval
|
APP_ADV_INTERVAL, // max interval
|
||||||
NULL // undirected
|
NULL // undirected
|
||||||
@@ -862,6 +864,13 @@ int ble_advertising_start(void)
|
|||||||
int ble_advertising_stop(void)
|
int ble_advertising_stop(void)
|
||||||
{
|
{
|
||||||
int err = bt_le_adv_stop();
|
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)
|
if (err)
|
||||||
{
|
{
|
||||||
DBG_ERR("[BLE] Adv stop failed (err %d)\r\n", err);
|
DBG_ERR("[BLE] Adv stop failed (err %d)\r\n", err);
|
||||||
|
|||||||
Reference in New Issue
Block a user