identity.cpp 1.2 KB

123456789101112131415161718192021222324252627
  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. // 0x83 attributes for the CONTROLLER -- the EXACT 25-byte blob read from a real Steam Controller
  8. // (28DE:1302) over USB: `scmd 1302 --up 1 83` -> `01 83 19 <these 25 bytes>`. As [tag][u32-LE] records:
  9. // tag 01 = product 0x1302; tag 02 = capabilities; tag 0A = bootloader build 0x68D2F92E; tag 04 = fw
  10. // build 0x6A18D057; tag 09 = board rev 0x48. These are firmware/model values (shared across units, not
  11. // per-device), so verbatim is correct; the per-unit serial lives in 0xAE instead. Steam validates these
  12. // byte-for-byte -- two wrong bytes (the puck's bootloader build + board rev) were why it kept re-asking.
  13. const uint8_t ATTR83[] = { 0x01, 0x02, 0x13, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  14. 0x00, 0x0A, 0x2E, 0xF9, 0xD2, 0x68, 0x04, 0x57, 0xD0,
  15. 0x18, 0x6A, 0x09, 0x48, 0x00, 0x00, 0x00 };
  16. const uint16_t ATTR83_LEN = sizeof ATTR83;
  17. void genSerial()
  18. {
  19. uint32_t id = NRF_FICR->DEVICEID[0] ^ NRF_FICR->DEVICEID[1];
  20. snprintf(g_unit, sizeof g_unit, "FXA99602%05lX",
  21. (unsigned long)(id & 0xFFFFF));
  22. snprintf(g_board, sizeof g_board, "MXA99602%05lX",
  23. (unsigned long)(id & 0xFFFFF));
  24. }