Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TCR] Extended Announcement additions #31532

Merged
merged 25 commits into from Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
92426a9
additions to support changes as discussed in connectedhomeip-spec #7825
Jan 18, 2024
ac19a15
add Silabs platform example implementation
Jan 18, 2024
7e664bc
add extension for ExtendedAnnouncementFlag + Silabs platform usage
Jan 18, 2024
af8f64d
Merge branch 'master' into master
Jan 19, 2024
3fb50df
Restyled by clang-format
restyled-commits Jan 19, 2024
3cc0139
Merge branch 'project-chip:master' into master
Jan 19, 2024
e32d6ac
adjust based on review comments - 1
Jan 19, 2024
6d3f9e1
Restyled by clang-format
restyled-commits Jan 19, 2024
996d86f
add missing include guard for default case
Jan 19, 2024
f5f6f9e
Revert "Restyled by clang-format"
Jan 19, 2024
1dd364c
fix extra bracket causing a bug + restyle changes
Jan 19, 2024
213688e
Restyled by clang-format
restyled-commits Jan 19, 2024
a236e3a
adjust based on review comments - 2
Jan 19, 2024
96e31f4
Merge branch 'master' into master
Jan 19, 2024
856a9c9
Restyled by clang-format
restyled-commits Jan 19, 2024
3b59593
Merge branch 'master' into master
Jan 19, 2024
6863bcb
Merge branch 'master' into master
Jan 19, 2024
675dddb
Merge branch 'master' into master
Jan 19, 2024
d3ee601
Merge branch 'master' into master
Jan 19, 2024
d48b6ca
Merge branch 'master' into master
Jan 20, 2024
542c6ec
Merge branch 'master' into master
Jan 20, 2024
9908dcf
Merge branch 'master' into master
Jan 20, 2024
0522f97
Merge branch 'master' into master
Jan 20, 2024
3e5694c
Merge branch 'master' into master
Jan 20, 2024
9d0f74d
Merge branch 'master' into master
Jan 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ class CommissioningWindowManager : public Messaging::UnsolicitedMessageHandler,

static constexpr System::Clock::Seconds16 MaxCommissioningTimeout()
{
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
// Specification section 2.3.1 - Extended Announcement Duration up to 48h
return System::Clock::Seconds16(60 * 60 * 48);
This conversation was marked as resolved.
Show resolved Hide resolved
#else
// Specification section 5.4.2.3. Announcement Duration says 15 minutes.
return System::Clock::Seconds16(15 * 60);
#endif
}

System::Clock::Seconds16 MinCommissioningTimeout() const
Expand Down
14 changes: 14 additions & 0 deletions src/ble/CHIPBleServiceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct ChipBLEDeviceIdentificationInfo
{
constexpr static uint16_t kDiscriminatorMask = 0xfff;
constexpr static uint8_t kAdditionalDataFlagMask = 0x1;
constexpr static uint8_t kExtendedAnnouncementFlagMask = 0x2;
constexpr static uint8_t kAdvertisementVersionMask = 0xf0;
constexpr static uint8_t kAdvertisementVersionShiftBits = 4u;

Expand Down Expand Up @@ -112,6 +113,19 @@ struct ChipBLEDeviceIdentificationInfo
AdditionalDataFlag &= static_cast<uint8_t>(~kAdditionalDataFlagMask);
}
}

void SetExtendedAnnouncementFlag(bool flag)
{
if (flag)
{
AdditionalDataFlag |= kExtendedAnnouncementFlagMask;
}
else
{
AdditionalDataFlag &= static_cast<uint8_t>(~kExtendedAnnouncementFlagMask);
}
}

} __attribute__((packed));

} /* namespace Ble */
Expand Down
55 changes: 55 additions & 0 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,61 @@
#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME 30000
#endif

/**
* CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
*
* Optional configuration to enable Extended Announcement Duration up to 48h.
* Should be used together with extending CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS past 15 minutes.
* Disabled by default.
*/

#ifndef CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 0
#endif

#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING

/**
* CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS
*
* The amount of time in miliseconds after which BLE advertisement should be switched from the slow
* advertising to the extended advertising, counting from the moment of advertisement commencement.
*
* Defaults to 900000 ms.
*/
#ifndef CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS
#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS (15 * 60 * 1000)
#endif

/**
* CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN
*
* The minimum interval (in units of 0.625ms) at which the device will send BLE advertisements while
* in the extended advertising mode. The minimum interval shall not be smaller than the default value
* and should not be equal to the CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX.
*
* Defaults to 1920 (1200 ms).
*/
#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN 1920

/**
* CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX
*
* The maximum interval (in units of 0.625ms) at which the device will send BLE advertisements while
* in the extended advertising mode. The maximum interval should be greater and not equal to the
* CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN.
*
* Defaults to 1936 (1210 ms).
*/
#ifndef CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX
#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX 1936
#endif

This conversation was marked as resolved.
Show resolved Hide resolved
static_assert(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN < CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX,
"Max Extended Advertising Interval cannot be smaller or equal to the Min Extended Advertising Interval");

#endif

// -------------------- Service Provisioning Configuration --------------------

/**
Expand Down
1 change: 1 addition & 0 deletions src/platform/silabs/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
kRestartAdvertising = 0x0008,
kEFRBLEStackInitialized = 0x0010,
kDeviceNameSet = 0x0020,
kExtAdvertisingEnabled = 0x0040,
};

enum
Expand Down
38 changes: 38 additions & 0 deletions src/platform/silabs/efr32/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,17 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)
advData[index++] = CHIP_ADV_DATA_TYPE_SERVICE_DATA; // AD type : Service Data
advData[index++] = ShortUUID_CHIPoBLEService[0]; // AD value
advData[index++] = ShortUUID_CHIPoBLEService[1];

#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
This conversation was marked as resolved.
Show resolved Hide resolved
// Check for extended advertisement interval and redact VID/PID if past the initial period.
if (mFlags.Has(Flags::kExtAdvertisingEnabled))
{
mDeviceIdInfo.SetVendorId(0);
mDeviceIdInfo.SetProductId(0);
mDeviceIdInfo.SetExtendedAnnouncementFlag(true);
}
#endif

memcpy(&advData[index], (void *) &mDeviceIdInfo, mDeviceIdInfoLength); // AD value
index += mDeviceIdInfoLength;

Expand Down Expand Up @@ -554,8 +565,21 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
}
else
{
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
if (!mFlags.Has(Flags::kExtAdvertisingEnabled))
{
interval_min = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN;
interval_max = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX;
}
else
{
interval_min = CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN;
interval_max = CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX;
}
#else
interval_min = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN;
interval_max = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX;
#endif
}

ret = sl_bt_advertiser_set_timing(advertising_set_handle, interval_min, interval_max, 0, 0);
Expand Down Expand Up @@ -953,8 +977,22 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer)
if (BLEMgrImpl().mFlags.Has(Flags::kFastAdvertisingEnabled))
{
ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertissment");
BLEMgrImpl().mFlags.Set(Flags::kAdvertising);
This conversation was marked as resolved.
Show resolved Hide resolved
BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising);
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
BLEMgrImpl().mFlags.Clear(Flags::kExtAdvertisingEnabled);
This conversation was marked as resolved.
Show resolved Hide resolved
BLEMgrImpl().StartBleAdvTimeoutTimer(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS);
#endif
}
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
else
{
ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start extended advertisment");
This conversation was marked as resolved.
Show resolved Hide resolved
BLEMgrImpl().mFlags.Set(Flags::kAdvertising);
This conversation was marked as resolved.
Show resolved Hide resolved
BLEMgrImpl().mFlags.Set(Flags::kExtAdvertisingEnabled);
BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising);
This conversation was marked as resolved.
Show resolved Hide resolved
}
#endif
}

void BLEManagerImpl::CancelBleAdvTimeoutTimer(void)
Expand Down
Loading