Skip to content

Commit

Permalink
Fix BLE device name for qpg and EFR32 to match the other platforms. (#…
Browse files Browse the repository at this point in the history
…18006)

These had hardcoded 0, while other platforms use the discriminator.

Fixes #112
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 14, 2023
1 parent 926b2d5 commit 4024931
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
* CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX
*
* A prefix string used in forming the BLE device name. The remainder of the name
* consists of the final two bytes of the device's chip node id in hex.
* typically contains the setup discriminator as a 4-digit decimal number.
*
* NOTE: The device layer limits the total length of a device name to 16 characters.
* However, due to other data sent in CHIPoBLE advertise packets, the device name
Expand Down
7 changes: 6 additions & 1 deletion src/platform/EFR32/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
#include <ble/CHIPBleServiceData.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/EFR32/freertos_bluetooth.h>

using namespace ::chip;
using namespace ::chip::Ble;

Expand Down Expand Up @@ -650,7 +652,10 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)

if (!mFlags.Has(Flags::kDeviceNameSet))
{
snprintf(mDeviceName, sizeof(mDeviceName), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, (uint32_t) 0);
uint16_t discriminator;
SuccessOrExit(err = GetCommissionableDataProvider()->GetSetupDiscriminator(discriminator));

snprintf(mDeviceName, sizeof(mDeviceName), "%s%04u", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator);

mDeviceName[kMaxDeviceNameLength] = 0;
mDeviceNameLength = strlen(mDeviceName);
Expand Down
6 changes: 5 additions & 1 deletion src/platform/qpg/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <ble/BleUUID.h>
#include <ble/CHIPBleServiceData.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/internal/BLEManager.h>

#include <lib/support/CodeUtils.h>
Expand Down Expand Up @@ -459,7 +460,10 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)

if (!mFlags.Has(Flags::kDeviceNameSet))
{
snprintf(deviceName, sizeof(deviceName), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, (uint32_t) 0);
uint16_t discriminator;
SuccessOrExit(err = GetCommissionableDataProvider()->GetSetupDiscriminator(discriminator));

snprintf(deviceName, sizeof(deviceName), "%s%04u", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator);

deviceName[kMaxDeviceNameLength] = 0;
err = MapBLEError(qvCHIP_BleSetDeviceName(deviceName));
Expand Down

0 comments on commit 4024931

Please sign in to comment.