:fix:add bt turn on event

Signed-off-by: ma-haoyun <mahaoyun2@huawei.com>
This commit is contained in:
ma-haoyun 2024-10-16 16:27:19 +08:00
parent 5be38cb78d
commit b181224572
2 changed files with 26 additions and 13 deletions

View File

@ -113,6 +113,7 @@ typedef enum {
UPDATE_SCREEN_STATE_INFO,
UPDATE_BT_STATE_OPEN_INFO,
UPDATE_BT_STATE_CLOSE_INFO,
UPDATE_BR_TURN_ON_INFO,
UPDATE_HB_MAX_INFO,
} LnnHeartbeatUpdateInfoType;

View File

@ -342,6 +342,30 @@ static void HbDelaySetHighScanParam(void *para)
}
}
static void HbHandleBleStateChange(SoftBusBtState btState)
{
g_enableState = false;
LNN_LOGI(LNN_HEART_BEAT, "HB handle SOFTBUS_BLE_TURN_ON, state=%{public}d", btState);
LnnUpdateHeartbeatInfo(UPDATE_BT_STATE_OPEN_INFO);
ClearAuthLimitMap();
ClearLnnBleReportExtraMap();
HbConditionChanged(false);
if (LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), HbDelaySetHighScanParam, NULL, 0) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "HB async set high param fail");
}
if (LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), HbDelaySetNormalScanParam, NULL,
HB_START_DELAY_LEN + HB_SEND_RELAY_LEN_ONCE) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "HB async set normal param fail");
}
if (LnnStartHbByTypeAndStrategy(HEARTBEAT_TYPE_BLE_V0 | HEARTBEAT_TYPE_BLE_V3,
STRATEGY_HB_SEND_ADJUSTABLE_PERIOD, false) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "start ble heartbeat fail");
}
if (btState == SOFTBUS_BR_TURN_ON) {
LnnUpdateHeartbeatInfo(UPDATE_BR_TURN_ON_INFO);
}
}
static void HbBtStateChangeEventHandler(const LnnEventBasicInfo *info)
{
if (info == NULL || info->event != LNN_EVENT_BT_STATE_CHANGED) {
@ -354,19 +378,7 @@ static void HbBtStateChangeEventHandler(const LnnEventBasicInfo *info)
switch (btState) {
case SOFTBUS_BLE_TURN_ON:
case SOFTBUS_BR_TURN_ON:
g_enableState = false;
LNN_LOGI(LNN_HEART_BEAT, "HB handle SOFTBUS_BLE_TURN_ON, state=%{public}d", btState);
LnnUpdateHeartbeatInfo(UPDATE_BT_STATE_OPEN_INFO);
ClearAuthLimitMap();
ClearLnnBleReportExtraMap();
HbConditionChanged(false);
LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), HbDelaySetHighScanParam, NULL, 0);
LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), HbDelaySetNormalScanParam, NULL,
HB_START_DELAY_LEN + HB_SEND_RELAY_LEN_ONCE);
if (LnnStartHbByTypeAndStrategy(HEARTBEAT_TYPE_BLE_V0 | HEARTBEAT_TYPE_BLE_V3,
STRATEGY_HB_SEND_ADJUSTABLE_PERIOD, false) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "start ble heartbeat fail");
}
HbHandleBleStateChange(btState);
break;
case SOFTBUS_BR_TURN_OFF:
if (SoftBusGetBtState() == BLE_DISABLE) {