[FL-378] Update usb descriptor to display unique flipper name (#373)

* update usb descriptor to display unique flipper name

* added flip_ prefix for usb descriptor, updated manufacturer string

* include name in ApiHalVersionOTP struct, update assets.py

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
its your bedtime
2021-03-12 12:18:13 +03:00
committed by GitHub
parent f002f117fd
commit fc12f91a64
8 changed files with 58 additions and 13 deletions

View File

@@ -20,6 +20,8 @@ const uint8_t api_hal_version_get_hw_connect();
const uint32_t api_hal_version_get_hw_timestamp();
const char * api_hal_version_get_name_ptr();
#ifdef __cplusplus
}
#endif

View File

@@ -51,7 +51,7 @@
#define DEVICE_ID2 (UID_BASE + 0x4)
#define DEVICE_ID3 (UID_BASE + 0x8)
#define USB_SIZ_STRING_SERIAL 0x1A
#define USB_SIZ_STRING_SERIAL 0x1E
/* USER CODE BEGIN EXPORTED_CONSTANTS */

View File

@@ -23,7 +23,7 @@
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_conf.h"
#include "api-hal-version.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */
@@ -65,12 +65,11 @@
#define USBD_VID 1155
#define USBD_LANGID_STRING 1033
#define USBD_MANUFACTURER_STRING "Flipper"
#define USBD_MANUFACTURER_STRING "Flipper Devices Inc."
#define USBD_PID 22336
#define USBD_PRODUCT_STRING "Flipper Control Virtual ComPort"
#define USBD_CONFIGURATION_STRING "CDC Config"
#define USBD_INTERFACE_STRING "CDC Interface"
/* USER CODE BEGIN PRIVATE_DEFINES */
/* USER CODE END PRIVATE_DEFINES */
@@ -285,8 +284,13 @@ uint8_t * USBD_CDC_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length
/* Update the serial number string descriptor with the data from the unique
* ID */
Get_SerialNum();
if(api_hal_version_get_name_ptr()){
char buffer[14] = "flip_";
strncat(buffer, api_hal_version_get_name_ptr(), 8);
USBD_GetString((uint8_t*) buffer, USBD_StringSerial, length);
} else {
Get_SerialNum();
}
/* USER CODE BEGIN USBD_CDC_SerialStrDescriptor */
/* USER CODE END USBD_CDC_SerialStrDescriptor */

View File

@@ -7,6 +7,7 @@ typedef struct {
uint8_t body;
uint8_t connect;
uint32_t timestamp;
char name[8];
} ApiHalVersionOTP;
bool api_hal_version_do_i_belong_here() {
@@ -32,3 +33,8 @@ const uint8_t api_hal_version_get_hw_connect() {
const uint32_t api_hal_version_get_hw_timestamp() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
}
const char * api_hal_version_get_name_ptr() {
char * name = ((ApiHalVersionOTP*)OTP_AREA_BASE)->name;
return *name == 0xFFU ? NULL : name;
}

View File

@@ -51,7 +51,7 @@
#define DEVICE_ID2 (UID_BASE + 0x4)
#define DEVICE_ID3 (UID_BASE + 0x8)
#define USB_SIZ_STRING_SERIAL 0x1A
#define USB_SIZ_STRING_SERIAL 0x1E
/* USER CODE BEGIN EXPORTED_CONSTANTS */

View File

@@ -23,7 +23,7 @@
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_conf.h"
#include "api-hal-version.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */
@@ -65,12 +65,11 @@
#define USBD_VID 1155
#define USBD_LANGID_STRING 1033
#define USBD_MANUFACTURER_STRING "Flipper"
#define USBD_MANUFACTURER_STRING "Flipper Devices Inc."
#define USBD_PID 22336
#define USBD_PRODUCT_STRING "Flipper Control Virtual ComPort"
#define USBD_CONFIGURATION_STRING "CDC Config"
#define USBD_INTERFACE_STRING "CDC Interface"
/* USER CODE BEGIN PRIVATE_DEFINES */
/* USER CODE END PRIVATE_DEFINES */
@@ -285,8 +284,13 @@ uint8_t * USBD_CDC_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length
/* Update the serial number string descriptor with the data from the unique
* ID */
Get_SerialNum();
if(api_hal_version_get_name_ptr()){
char buffer[14] = "flip_";
strncat(buffer, api_hal_version_get_name_ptr(), 8);
USBD_GetString((uint8_t*) buffer, USBD_StringSerial, length);
} else {
Get_SerialNum();
}
/* USER CODE BEGIN USBD_CDC_SerialStrDescriptor */
/* USER CODE END USBD_CDC_SerialStrDescriptor */

View File

@@ -7,6 +7,7 @@ typedef struct {
uint8_t body;
uint8_t connect;
uint32_t timestamp;
char name[8];
} ApiHalVersionOTP;
bool api_hal_version_do_i_belong_here() {
@@ -32,3 +33,8 @@ const uint8_t api_hal_version_get_hw_connect() {
const uint32_t api_hal_version_get_hw_timestamp() {
return ((ApiHalVersionOTP*)OTP_AREA_BASE)->timestamp;
}
const char * api_hal_version_get_name_ptr() {
char * name = ((ApiHalVersionOTP*)OTP_AREA_BASE)->name;
return *name == 0xFFU ? NULL : name;
}