Skip to content

Commit

Permalink
[Telink] Fix crash during boot (#26163)
Browse files Browse the repository at this point in the history
  • Loading branch information
andriy-bilynskyy authored Apr 20, 2023
1 parent 4766142 commit e2341d8
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/platform/telink/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,6 @@ inline CHIP_ERROR BLEManagerImpl::PrepareAdvertisingRequest(void)
mAdvertisingRequest.advertisingData = Span<bt_data>(advertisingData);
mAdvertisingRequest.scanResponseData = nameSize ? Span<bt_data>(scanResponseData) : Span<bt_data>{};

mAdvertisingRequest.onStarted = [](int rc) {
if (rc == 0)
{
ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started");
}
else
{
ChipLogError(DeviceLayer, "Failed to start CHIPoBLE advertising: %d", rc);
}
};

return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -339,7 +328,13 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
#endif

// Request advertising
ReturnErrorOnFailure(BLEAdvertisingArbiter::InsertRequest(mAdvertisingRequest));
ReturnErrorOnFailure(System::MapErrorZephyr(bt_le_adv_stop()));
const bt_le_adv_param params = BT_LE_ADV_PARAM_INIT(mAdvertisingRequest.options, mAdvertisingRequest.minInterval,
mAdvertisingRequest.maxInterval, nullptr);
ReturnErrorOnFailure(System::MapErrorZephyr(
bt_le_adv_start(&params, mAdvertisingRequest.advertisingData.data(), mAdvertisingRequest.advertisingData.size(),
mAdvertisingRequest.scanResponseData.data(), mAdvertisingRequest.scanResponseData.size())));
ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started");

// Transition to the Advertising state...
if (!mFlags.Has(Flags::kAdvertising))
Expand Down Expand Up @@ -375,7 +370,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
return CHIP_ERROR_INCORRECT_STATE;
}

BLEAdvertisingArbiter::CancelRequest(mAdvertisingRequest);
ReturnErrorOnFailure(System::MapErrorZephyr(bt_le_adv_stop()));

// Transition to the not Advertising state...
if (mFlags.Has(Flags::kAdvertising))
Expand Down

0 comments on commit e2341d8

Please sign in to comment.