From 12b4d466919c771f139c62058b22ae41649df1cf Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Thu, 5 Jun 2025 17:06:28 +0200 Subject: [PATCH] feat(nordic,core): change device code to single byte value [no changelog] --- core/embed/io/ble/stm32/ble.c | 4 +++- core/embed/io/ble/stm32/ble_comm_defs.h | 2 +- core/embed/models/T3W1/model_T3W1.h | 1 + nordic/trezor/trezor-ble/src/ble/advertising.c | 7 ++----- nordic/trezor/trezor-ble/src/ble/ble_internal.h | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/embed/io/ble/stm32/ble.c b/core/embed/io/ble/stm32/ble.c index 0ddfdcbc58..7a8095b0c3 100644 --- a/core/embed/io/ble/stm32/ble.c +++ b/core/embed/io/ble/stm32/ble.c @@ -19,6 +19,8 @@ #ifdef KERNEL_MODE +#include +#include #include #include @@ -99,7 +101,7 @@ static bool ble_send_advertising_on(ble_driver_t *drv, bool whitelist) { .whitelist = whitelist ? 1 : 0, .color = props.color, .static_addr = drv->adv_cmd.static_mac, - .device_code = HW_MODEL, + .device_code = MODEL_BLE_CODE, }; memcpy(data.name, drv->adv_cmd.name, BLE_ADV_NAME_LEN); diff --git a/core/embed/io/ble/stm32/ble_comm_defs.h b/core/embed/io/ble/stm32/ble_comm_defs.h index 859b8947ec..5c09c54894 100644 --- a/core/embed/io/ble/stm32/ble_comm_defs.h +++ b/core/embed/io/ble/stm32/ble_comm_defs.h @@ -73,7 +73,7 @@ typedef struct { uint8_t whitelist; uint8_t color; uint8_t static_addr; - uint32_t device_code; + uint8_t device_code; uint8_t name[BLE_ADV_NAME_LEN]; } cmd_advertising_on_t; diff --git a/core/embed/models/T3W1/model_T3W1.h b/core/embed/models/T3W1/model_T3W1.h index 9578d49733..fdbf2664e1 100644 --- a/core/embed/models/T3W1/model_T3W1.h +++ b/core/embed/models/T3W1/model_T3W1.h @@ -33,6 +33,7 @@ #define MODEL_USB_MANUFACTURER "Trezor Company" #define MODEL_USB_PRODUCT MODEL_FULL_NAME #define MODEL_HOMESCREEN_MAXSIZE 65536 +#define MODEL_BLE_CODE 6 #define MODEL_BOARDLOADER_KEYS \ (const uint8_t *)"\xe8\x91\x2f\x81\xb3\xe7\x80\xee\x65\x0e\xd3\x85\x6d\xb5\x32\x6e\x0b\x9e\xff\x10\x36\x4b\x33\x91\x93\xe7\xa8\xf1\x0f\x76\x21\xb9", \ diff --git a/nordic/trezor/trezor-ble/src/ble/advertising.c b/nordic/trezor/trezor-ble/src/ble/advertising.c index f38b9e0053..2388d72704 100644 --- a/nordic/trezor/trezor-ble/src/ble/advertising.c +++ b/nordic/trezor/trezor-ble/src/ble/advertising.c @@ -65,7 +65,7 @@ void advertising_setup_wl(void) { bt_foreach_bond(BT_ID_DEFAULT, add_to_whitelist, NULL); } -void advertising_start(bool wl, uint8_t color, uint32_t device_code, +void advertising_start(bool wl, uint8_t color, uint8_t device_code, bool static_addr, char *name, int name_len) { if (advertising) { LOG_WRN("Restarting advertising"); @@ -90,10 +90,7 @@ void advertising_start(bool wl, uint8_t color, uint32_t device_code, } manufacturer_data[3] = color; - manufacturer_data[4] = device_code & 0xff; - manufacturer_data[5] = (device_code >> 8) & 0xff; - manufacturer_data[6] = (device_code >> 16) & 0xff; - manufacturer_data[7] = (device_code >> 24) & 0xff; + manufacturer_data[4] = device_code; advertising_data[0].type = BT_DATA_FLAGS; advertising_data[0].data_len = 1; diff --git a/nordic/trezor/trezor-ble/src/ble/ble_internal.h b/nordic/trezor/trezor-ble/src/ble/ble_internal.h index 917b2541eb..6004ea2251 100644 --- a/nordic/trezor/trezor-ble/src/ble/ble_internal.h +++ b/nordic/trezor/trezor-ble/src/ble/ble_internal.h @@ -103,7 +103,7 @@ typedef struct { uint8_t whitelist; uint8_t color; uint8_t static_addr; - uint32_t device_code; + uint8_t device_code; uint8_t name[BLE_ADV_NAME_LEN]; } cmd_advertising_on_t; @@ -146,7 +146,7 @@ bool bonds_erase_current(void); // Initialization void advertising_init(void); // Start advertising, with or without whitelist -void advertising_start(bool wl, uint8_t color, uint32_t device_code, +void advertising_start(bool wl, uint8_t color, uint8_t device_code, bool static_addr, char *name, int name_len); // Stop advertising void advertising_stop(void);