mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-23 23:18:16 +00:00
send ble sw versions in status
This commit is contained in:
parent
370df244bb
commit
4a9819bf7a
@ -396,6 +396,7 @@ env.Replace(
|
||||
CPPPATH=[
|
||||
'embed/ble_firmware',
|
||||
'embed/bootloader/protob',
|
||||
'embed/ble_bootloader/dfu',
|
||||
'embed/sdk/nrf52',
|
||||
'embed/lib',
|
||||
'vendor/nanopb',
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "protob_helpers.h"
|
||||
#include "stdint.h"
|
||||
#include "trezor_t3w1_d1_NRF.h"
|
||||
#include "nrf_dfu_types.h"
|
||||
|
||||
#define SPI_INSTANCE 0 /**< SPI instance index. */
|
||||
|
||||
@ -28,6 +29,14 @@ static const nrf_drv_spi_t spi =
|
||||
static volatile bool spi_xfer_done = true; /**< Flag used to indicate that SPI
|
||||
instance completed the transfer. */
|
||||
|
||||
|
||||
#define CODE_PAGE_SIZE (MBR_PAGE_SIZE_IN_WORDS * sizeof(uint32_t))
|
||||
#define BOOTLOADER_SETTINGS_PAGE_SIZE (CODE_PAGE_SIZE)
|
||||
uint8_t m_dfu_settings_buffer[BOOTLOADER_SETTINGS_PAGE_SIZE]
|
||||
__attribute__((section(".bootloader_settings_page")))
|
||||
__attribute__((used));
|
||||
|
||||
|
||||
/**
|
||||
* @brief SPI user event handler.
|
||||
* @param event
|
||||
@ -353,15 +362,27 @@ void nus_data_handler(ble_nus_evt_t *p_evt) {
|
||||
/**@snippet [Handling the data received over BLE] */
|
||||
|
||||
void send_status_event(void) {
|
||||
uint8_t tx_data[] = {
|
||||
INTERNAL_EVENT_STATUS,
|
||||
(get_connection_handle() != BLE_CONN_HANDLE_INVALID) ? 1
|
||||
: 0, // connected
|
||||
is_advertising() ? 1 : 0, // advertising
|
||||
is_advertising_wl() ? 1 : 0, // advertising whitelist
|
||||
pm_peer_count(), // peer count
|
||||
};
|
||||
send_packet(INTERNAL_EVENT, tx_data, sizeof(tx_data));
|
||||
|
||||
ble_version_t version ={0};
|
||||
nrf_dfu_settings_t * settins= (nrf_dfu_settings_t *)m_dfu_settings_buffer;
|
||||
|
||||
sd_ble_version_get(&version);
|
||||
|
||||
|
||||
|
||||
event_status_msg_t msg = {0};
|
||||
msg.msg_id = INTERNAL_EVENT_STATUS;
|
||||
msg.connected = (get_connection_handle() != BLE_CONN_HANDLE_INVALID) ? 1 : 0;
|
||||
msg.advertising = is_advertising() ? 1 : 0;
|
||||
msg.advertising_whitelist = is_advertising_wl() ? 1 : 0;
|
||||
msg.peer_count = pm_peer_count();
|
||||
msg.sd_version_number = version.version_number;
|
||||
msg.sd_company_id = version.company_id;
|
||||
msg.sd_subversion_number = version.subversion_number;
|
||||
msg.app_version = settins->app_version;
|
||||
msg.bld_version = settins->bootloader_version;
|
||||
|
||||
send_packet(INTERNAL_EVENT, (uint8_t*) &msg, sizeof(msg));
|
||||
}
|
||||
|
||||
void send_success_event(void) {
|
||||
|
@ -7,10 +7,19 @@ MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x49000
|
||||
RAM (rwx) : ORIGIN = 0x20002ae8, LENGTH = 0x1d518
|
||||
bootloader_settings_page (r) : ORIGIN = 0x0007F000, LENGTH = 0x1000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = ALIGN(4);
|
||||
.bootloader_settings_page(NOLOAD) :
|
||||
{
|
||||
PROVIDE(__start_bootloader_settings_page = .);
|
||||
KEEP(*(SORT(.bootloader_settings_page*)))
|
||||
PROVIDE(__stop_bootloader_settings_page = .);
|
||||
} > bootloader_settings_page
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
|
@ -15,6 +15,25 @@
|
||||
#define EXTERNAL_MESSAGE (0xA1)
|
||||
#define INTERNAL_MESSAGE (0xA0)
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t msg_id;
|
||||
uint8_t connected;
|
||||
uint8_t advertising;
|
||||
uint8_t advertising_whitelist;
|
||||
|
||||
uint8_t peer_count;
|
||||
uint8_t reserved[2];
|
||||
uint8_t sd_version_number;
|
||||
|
||||
uint16_t sd_company_id;
|
||||
uint16_t sd_subversion_number;
|
||||
|
||||
uint32_t app_version;
|
||||
uint32_t bld_version;
|
||||
|
||||
}event_status_msg_t;
|
||||
|
||||
typedef enum {
|
||||
INTERNAL_EVENT_STATUS = 0x01,
|
||||
INTERNAL_EVENT_SUCCESS = 0x02,
|
||||
|
Loading…
Reference in New Issue
Block a user