Use same serial number encoding algo that is used in DFU. We now show same serial number in USB, BLE and device info data. Update firmware revision to 1.0.0.

fsk9600 v1.0.0
Rob Riggs 2019-01-12 14:25:22 -06:00
rodzic 5ba4233871
commit e00cb3d8ba
4 zmienionych plików z 27 dodań i 24 usunięć

Wyświetl plik

@ -156,7 +156,6 @@
#define CMD_USB_RESUME 26 #define CMD_USB_RESUME 26
extern int reset_requested; extern int reset_requested;
extern char serial_number[25];
extern char serial_number_64[17]; extern char serial_number_64[17];
extern uint8_t mac_address[6]; extern uint8_t mac_address[6];
extern char error_message[80]; extern char error_message[80];

Wyświetl plik

@ -147,7 +147,6 @@ osStaticTimerDef_t usbShutdownTimerControlBlock;
int lost_power = 0; int lost_power = 0;
int reset_requested = 0; int reset_requested = 0;
char serial_number[25];
char serial_number_64[17] = {0}; char serial_number_64[17] = {0};
// Make sure it is not overwritten during resets (bss3). // Make sure it is not overwritten during resets (bss3).
uint8_t mac_address[6] __attribute__((section(".bss3"))) = {0}; uint8_t mac_address[6] __attribute__((section(".bss3"))) = {0};
@ -348,6 +347,30 @@ void shutdown(void const * argument)
HAL_NVIC_SystemReset(); HAL_NVIC_SystemReset();
} }
/*
* Same algorithm as here: https://github.com/libopencm3/libopencm3/blob/master/lib/stm32/desig.c
*/
void encode_serial_number()
{
uint8_t *uid = (uint8_t *)UID_BASE;
uint8_t serial[6];
serial[0] = uid[11];
serial[1] = uid[10] + uid[2];
serial[2] = uid[9];
serial[3] = uid[8] + uid[0];
serial[4] = uid[7];
serial[5] = uid[6];
snprintf(
serial_number_64,
sizeof(serial_number_64),
"%02X%02X%02X%02X%02X%02X",
serial[0], serial[1], serial[2],
serial[3], serial[4], serial[5]
);
}
/* USER CODE END 0 */ /* USER CODE END 0 */
/** /**
@ -413,14 +436,7 @@ int main(void)
indicate_turning_on(); // LEDs on during boot. indicate_turning_on(); // LEDs on during boot.
} }
// Fetch the device serial number. encode_serial_number();
uint32_t* uid = (uint32_t*) UID_BASE;
snprintf(serial_number, sizeof(serial_number), "%08lx%08lx%08lx", uid[0], uid[1], uid[2]);
{
uint32_t len = 17;
base64encode((const uint8_t*) UID_BASE, 12, serial_number_64, &len);
}
// The Bluetooth module is powered on during MX_GPIO_Init(). BT_CMD // The Bluetooth module is powered on during MX_GPIO_Init(). BT_CMD
// has a weak pull-up on the BT module and is in OD mode. Pull the // has a weak pull-up on the BT module and is in OD mode. Pull the

Wyświetl plik

@ -366,8 +366,6 @@ void startLedBlinkerTask(void const*)
} }
} }
extern osThreadId cdcBlinkerHandle;
namespace mobilinkd { namespace mobilinkd {
namespace tnc { namespace tnc {
@ -379,7 +377,7 @@ void print_startup_banner()
INFO("%s version %s", mobilinkd::tnc::kiss::HARDWARE_VERSION, INFO("%s version %s", mobilinkd::tnc::kiss::HARDWARE_VERSION,
mobilinkd::tnc::kiss::FIRMWARE_VERSION); mobilinkd::tnc::kiss::FIRMWARE_VERSION);
INFO("CPU core clock: %luHz", SystemCoreClock); INFO("CPU core clock: %luHz", SystemCoreClock);
INFO(" Serial number: %08lX %08lX %08lX", uid[0], uid[1], uid[2]); INFO(" Device UID: %08lX %08lX %08lX", uid[0], uid[1], uid[2]);
INFO(" MAC Address: %02X:%02X:%02X:%02X:%02X:%02X", INFO(" MAC Address: %02X:%02X:%02X:%02X:%02X:%02X",
mac_address[0], mac_address[1], mac_address[2], mac_address[0], mac_address[1], mac_address[2],
mac_address[3], mac_address[4], mac_address[5]) mac_address[3], mac_address[4], mac_address[5])
@ -392,15 +390,5 @@ void print_startup_banner()
#endif #endif
} }
void start_cdc_blink()
{
osThreadResume(cdcBlinkerHandle);
}
void stop_cdc_blink()
{
osThreadSuspend(cdcBlinkerHandle);
}
} }
} // mobilinkd::tnc } // mobilinkd::tnc

Wyświetl plik

@ -26,7 +26,7 @@ int powerOffViaUSB(void)
namespace mobilinkd { namespace tnc { namespace kiss { namespace mobilinkd { namespace tnc { namespace kiss {
const char FIRMWARE_VERSION[] = "0.8.14"; const char FIRMWARE_VERSION[] = "1.0.0";
const char HARDWARE_VERSION[] = "Mobilinkd TNC3 2.1.1"; const char HARDWARE_VERSION[] = "Mobilinkd TNC3 2.1.1";
Hardware& settings() Hardware& settings()