identity.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "identity.h"
  2. #include <Arduino.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. char g_unit[16];
  6. char g_board[16];
  7. char g_usbSerial[18];
  8. // clang-format off
  9. const uint8_t ATTR83_PUCK[25] = { // 0x83 attributes
  10. // 1 byte tag, 4 byte little-endian value.
  11. 0x01, 0x04, 0x13, 0x00, 0x00, // product_id = 0x1304
  12. 0x02, 0x00, 0x00, 0x00, 0x00, // capabilities = 0 (bitfield)
  13. 0x0A, 0xF2, 0xF9, 0xD2, 0x68, // boot_build_timestamp = 0x68D2F9F2
  14. 0x04, 0x59, 0x83, 0x62, 0x6A, // build_timestamp = 0x6A628359 todo: keep updated
  15. 0x09, 0x47, 0x00, 0x00, 0x00 // hw_id = 0x47
  16. };
  17. const uint8_t ATTR83_MACHINE[25] = { // 0x83 attributes
  18. // 1 byte tag, 4 byte little-endian value.
  19. 0x01, 0x04, 0x13, 0x00, 0x00, // product_id = 0x1304. (same as the Puck, interestingly!)
  20. 0x02, 0x00, 0x00, 0x00, 0x00, // capabilities = 0 (bitfield)
  21. 0x0A, 0x01, 0x97, 0xCC, 0x68, // boot_build_timestamp = 0x68CC9701
  22. 0x04, 0x59, 0x83, 0x62, 0x6A, // build_timestamp = 0x6A628359 todo: keep updated
  23. 0x09, 0x44, 0x00, 0x00, 0x00 // hw_id = 0x44
  24. };
  25. // clang-format on
  26. void genSerial()
  27. {
  28. uint32_t id = NRF_FICR->DEVICEID[0] ^ NRF_FICR->DEVICEID[1];
  29. snprintf(g_unit, sizeof g_unit, "FXB99602%05lX",
  30. (unsigned long)(id & 0xFFFFF));
  31. snprintf(g_board, sizeof g_board, "MXB99602%05lX",
  32. (unsigned long)(id & 0xFFFFF));
  33. }