From 1d9582c26a12d245b13597be8678dc107532962f Mon Sep 17 00:00:00 2001 From: Arne Seime Date: Tue, 25 Jun 2024 19:00:34 +0200 Subject: [PATCH] Added BTHome packet id for deduplication --- code/nrf-connect/samples/ble/Kconfig | 2 +- code/nrf-connect/samples/ble/src/encoding.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code/nrf-connect/samples/ble/Kconfig b/code/nrf-connect/samples/ble/Kconfig index 15cc887..01a95fc 100644 --- a/code/nrf-connect/samples/ble/Kconfig +++ b/code/nrf-connect/samples/ble/Kconfig @@ -39,7 +39,7 @@ config PRST_BLE_ENCODING_SERVICE_DATA_LEN Size of the service data buffer. default 20 if PRST_BLE_ENCODING_BPARASITE_V2 default 18 if PRST_BLE_ENCODING_BTHOME_V1 - default 19 if PRST_BLE_ENCODING_BTHOME_V2 + default 21 if PRST_BLE_ENCODING_BTHOME_V2 config PRST_BLE_HAS_USER_DEFINED_RANDOM_STATIC_ADDR diff --git a/code/nrf-connect/samples/ble/src/encoding.c b/code/nrf-connect/samples/ble/src/encoding.c index 360f035..763c4be 100644 --- a/code/nrf-connect/samples/ble/src/encoding.c +++ b/code/nrf-connect/samples/ble/src/encoding.c @@ -132,6 +132,11 @@ int prst_ble_encode_service_data(const prst_sensors_t* sensors, uint8_t batt_percentage_val = 100 * sensors->batt.percentage + 0.5f; out[18] = batt_percentage_val; + // Misc packet-id + static uint8_t run_counter; + out[19] = 0x00; + out[20] = run_counter++ & 0xFF; + #endif // Encoding protocols LOG_HEXDUMP_DBG(out, out_len, "Encoded BLE adv: ");