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

11 months ago
5 months ago
11 months ago
5 months ago
11 months ago
5 months ago
11 months ago
5 months ago
11 months ago
11 months ago
11 months ago
  1. #include "sn.h"
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. /*******************************************************************************
  7. * EXTERN *
  8. *******************************************************************************/
  9. static sn_t m_sn;
  10. sn_t* xs_device_info_get() { //
  11. sn_t* info = (sn_t*)DEVICE_INFO_START_ADD;
  12. m_sn = *info;
  13. if (m_sn.year == 255) {
  14. m_sn.year = 0;
  15. }
  16. if (m_sn.weak == 255) {
  17. m_sn.weak = 0;
  18. }
  19. if (m_sn.index == 65535) {
  20. m_sn.index = 0;
  21. }
  22. return &m_sn;
  23. }
  24. const char* sn_get_str() {
  25. sn_t* info = xs_device_info_get();
  26. static char sn_str[32];
  27. sprintf(sn_str, "%s%02d%02d%04d", "SN", info->year, info->weak, info->index);
  28. return sn_str;
  29. }