findmy_state.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <extra_beacon.h>
  3. #define FINDMY_STATE_HEADER "FindMy Flipper State"
  4. #define FINDMY_STATE_VER 1
  5. #define FINDMY_STATE_DIR EXT_PATH("apps_data/findmy")
  6. #define FINDMY_STATE_PATH FINDMY_STATE_DIR "/findmy_state.txt"
  7. #define BATTERY_FULL 0x00
  8. #define BATTERY_MEDIUM 0x50
  9. #define BATTERY_LOW 0xA0
  10. #define BATTERY_CRITICAL 0xF0
  11. typedef enum {
  12. FindMyTypeApple,
  13. FindMyTypeSamsung,
  14. FindMyTypeTile,
  15. } FindMyType;
  16. typedef struct {
  17. bool beacon_active;
  18. uint8_t broadcast_interval;
  19. uint8_t transmit_power;
  20. bool show_mac;
  21. uint8_t mac[EXTRA_BEACON_MAC_ADDR_SIZE];
  22. uint8_t data[EXTRA_BEACON_MAX_DATA_SIZE];
  23. FindMyType tag_type;
  24. // Generated from the other state values
  25. GapExtraBeaconConfig config;
  26. uint8_t battery_level;
  27. } FindMyState;
  28. bool findmy_state_load(FindMyState* out_state);
  29. void findmy_state_apply(FindMyState* state);
  30. void findmy_state_sync_config(FindMyState* state);
  31. void findmy_state_save(FindMyState* state);
  32. void findmy_update_payload_battery(uint8_t* data, uint8_t battery_level, FindMyType type);
  33. uint8_t findmy_state_data_size(FindMyType type);