You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
832 B

#include "sn.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*******************************************************************************
* EXTERN *
*******************************************************************************/
static sn_t m_sn;
sn_t* xs_device_info_get() { //
sn_t* info = (sn_t*)DEVICE_INFO_START_ADD;
m_sn = *info;
if (m_sn.year == 255) {
m_sn.year = 0;
}
if (m_sn.weak == 255) {
m_sn.weak = 0;
}
if (m_sn.index == 65535) {
m_sn.index = 0;
}
return &m_sn;
}
const char* sn_get_str() {
sn_t* info = xs_device_info_get();
static char sn_str[32];
sprintf(sn_str, "%s%02d%02d%04d", "SN", info->year, info->weak, info->index);
return sn_str;
}