[FL-1409] Flipper name in reports (#507)
* USB CDC descriptor: join product name from two strings * add f5 support * USB CDC descriptor: use constant device name across all device * BLE: use device name in advertising and model * BLE: truncate device name Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#include <api-hal-version.h>
|
||||
#include <stm32wbxx.h>
|
||||
#include <stm32wbxx_ll_rtc.h>
|
||||
#include <stdio.h>
|
||||
#include "ble.h"
|
||||
|
||||
#define FLIPPER_NAME_LENGTH 8
|
||||
|
||||
typedef struct {
|
||||
uint8_t version;
|
||||
@@ -8,15 +12,35 @@ typedef struct {
|
||||
uint8_t body;
|
||||
uint8_t connect;
|
||||
uint32_t timestamp;
|
||||
char name[8];
|
||||
char name[FLIPPER_NAME_LENGTH];
|
||||
} ApiHalVersionOTP;
|
||||
|
||||
#define FLIPPER_ARRAY_NAME_LENGTH (FLIPPER_NAME_LENGTH + 1)
|
||||
// BLE symbol + "Flipper Zero " + name
|
||||
#define FLIPPER_DEVICE_NAME_LENGTH (1 + 8 + FLIPPER_ARRAY_NAME_LENGTH)
|
||||
|
||||
// Initialiazed from OTP, used to guarantee zero terminated C string
|
||||
static char flipper_name[9];
|
||||
static char flipper_name[FLIPPER_ARRAY_NAME_LENGTH];
|
||||
static char flipper_device_name[FLIPPER_DEVICE_NAME_LENGTH];
|
||||
|
||||
void api_hal_version_init() {
|
||||
char* name = ((ApiHalVersionOTP*)OTP_AREA_BASE)->name;
|
||||
strlcpy(flipper_name, name, 9);
|
||||
strlcpy(flipper_name, name, FLIPPER_ARRAY_NAME_LENGTH);
|
||||
|
||||
if(api_hal_version_get_name_ptr() != NULL) {
|
||||
snprintf(
|
||||
flipper_device_name,
|
||||
FLIPPER_DEVICE_NAME_LENGTH,
|
||||
"xFlipper %s",
|
||||
flipper_name);
|
||||
} else {
|
||||
snprintf(
|
||||
flipper_device_name,
|
||||
FLIPPER_DEVICE_NAME_LENGTH,
|
||||
"xFlipper");
|
||||
}
|
||||
|
||||
flipper_device_name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
|
||||
}
|
||||
|
||||
bool api_hal_version_do_i_belong_here() {
|
||||
@@ -43,10 +67,18 @@ const uint32_t api_hal_version_get_hw_timestamp() {
|
||||
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
|
||||
}
|
||||
|
||||
const char * api_hal_version_get_name_ptr() {
|
||||
const char* api_hal_version_get_name_ptr() {
|
||||
return *flipper_name == 0xFFU ? NULL : flipper_name;
|
||||
}
|
||||
|
||||
const char* api_hal_version_get_device_name_ptr() {
|
||||
return flipper_device_name + 1;
|
||||
}
|
||||
|
||||
const char* api_hal_version_get_ble_local_device_name_ptr() {
|
||||
return flipper_device_name;
|
||||
}
|
||||
|
||||
const struct Version* api_hal_version_get_fw_version(void) {
|
||||
return version_get();
|
||||
}
|
||||
@@ -56,7 +88,6 @@ const struct Version* api_hal_version_get_boot_version(void) {
|
||||
return 0;
|
||||
#else
|
||||
/* Backup register which points to structure in flash memory */
|
||||
return (const struct Version*) LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR1);
|
||||
return (const struct Version*)LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user