From eb5d6ea9fd6acd221b8880650728e13968e54d3d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 18 Feb 2023 18:16:44 +1100 Subject: [PATCH] Make BLE name more unique --- source/Core/BSP/Pinecilv2/ble_peripheral.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Core/BSP/Pinecilv2/ble_peripheral.c b/source/Core/BSP/Pinecilv2/ble_peripheral.c index 1753f47a..8127034a 100644 --- a/source/Core/BSP/Pinecilv2/ble_peripheral.c +++ b/source/Core/BSP/Pinecilv2/ble_peripheral.c @@ -268,8 +268,10 @@ int ble_start_adv(void) { .interval_min = BT_GAP_ADV_FAST_INT_MIN_3, .interval_max = BT_GAP_ADV_FAST_INT_MAX_3, }; - char nameBuffer[16]; - int nameLen = snprintf(nameBuffer, 16, "Pinecil-%03d", (int)(getDeviceID() & 0xFFFF)); + char nameBuffer[16]; + uint32_t scratch = getDeviceID() & 0xFFFFFFFF; + scratch ^= (getDeviceID() >> 32) & 0xFFFFFFFF; + int nameLen = snprintf(nameBuffer, 16, "Pinecil-%08X", (int)scratch); // scan and response data must each stay < 31 bytes struct bt_data adv_data[2] = {BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_NO_BREDR | BT_LE_AD_GENERAL)), BT_DATA(BT_DATA_NAME_COMPLETE, nameBuffer, nameLen)};