furi_hal_region.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef struct {
  9. uint32_t start;
  10. uint32_t end;
  11. int8_t power_limit;
  12. uint8_t duty_cycle;
  13. } FuriHalRegionBand;
  14. typedef struct {
  15. char country_code[4];
  16. uint16_t bands_count;
  17. FuriHalRegionBand bands[];
  18. } FuriHalRegion;
  19. /** Initialize region */
  20. void furi_hal_region_init();
  21. /** Get Region Data.
  22. *
  23. * Region data may be allocated in Flash or in RAM.
  24. * Keep in mind that we don't do memory management on our side.
  25. *
  26. * @return pointer to FuriHalRegion instance (in RAM or Flash, check before freeing on region update)
  27. */
  28. const FuriHalRegion* furi_hal_region_get();
  29. /** Set device region data
  30. *
  31. * @param region pointer to the FuriHalRegion
  32. */
  33. void furi_hal_region_set(FuriHalRegion* region);
  34. /** Check if region data provisioned
  35. *
  36. * @return true if provisioned, false otherwise
  37. */
  38. bool furi_hal_region_is_provisioned();
  39. /** Get region name
  40. *
  41. * 2 letter Region code according to iso 3166 standard
  42. * There are 2 extra values that we use in special cases:
  43. * - "00" - developer edition, unlocked
  44. * - "WW" - world wide, region provisioned by default
  45. * - "--" - no provisioned region
  46. *
  47. * @return Pointer to string
  48. */
  49. const char* furi_hal_region_get_name();
  50. /** Сheck if transmission is allowed on this frequency for your flipper region
  51. *
  52. * @param[in] frequency The frequency
  53. * @param value frequency in Hz
  54. *
  55. * @return true if allowed
  56. */
  57. bool furi_hal_region_is_frequency_allowed(uint32_t frequency);
  58. /** Get band data for frequency
  59. *
  60. *
  61. *
  62. * @param[in] frequency The frequency
  63. *
  64. * @return { description_of_the_return_value }
  65. */
  66. const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency);
  67. #ifdef __cplusplus
  68. }
  69. #endif