BLE connection disconnect(reason)에 따른 Advertising Timeout
- 비정상 연결 해제 시 무제한 광고 - 그 외 10분 광고 후 전원 OFF
This commit is contained in:
+20
-2
@@ -276,6 +276,21 @@ static void adv_restart_handler(struct k_work *work)
|
||||
led_set_state(LED_STATE_ADVERTISING);
|
||||
}
|
||||
|
||||
static bool ble_disconnect_reason_uses_unlimited_adv(uint8_t reason)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case BT_HCI_ERR_CONN_TIMEOUT:
|
||||
case BT_HCI_ERR_LL_RESP_TIMEOUT:
|
||||
case BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL:
|
||||
case BT_HCI_ERR_CONN_FAIL_TO_ESTAB:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void adv_timeout_handler(struct k_work *work)
|
||||
{
|
||||
ARG_UNUSED(work);
|
||||
@@ -284,6 +299,7 @@ static void adv_timeout_handler(struct k_work *work)
|
||||
{
|
||||
DBG_PRINTF("[BLE] Advertising timeout\r\n");
|
||||
(void)ble_advertising_stop();
|
||||
device_power_off_reason("ble-advertising-timeout");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,8 +440,10 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
|
||||
}
|
||||
|
||||
ble_connection_st = false;
|
||||
advertising_unlimited = true;
|
||||
DBG_CORE("[BLE] Disconnected (reason 0x%02x)\r\n", reason);
|
||||
advertising_unlimited = ble_disconnect_reason_uses_unlimited_adv(reason);
|
||||
DBG_CORE("[BLE] Disconnected reason=0x%02x adv=%s\r\n",
|
||||
reason,
|
||||
advertising_unlimited ? "unlimited" : "10min");
|
||||
|
||||
/* 워크큐에서 advertising 재시작 */
|
||||
k_work_submit(&adv_restart_work);
|
||||
|
||||
Reference in New Issue
Block a user