ws_generic.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include <lib/flipper_format/flipper_format.h>
  6. #include "furi.h"
  7. #include "furi_hal.h"
  8. #include <lib/subghz/types.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #define WS_NO_ID 0xFFFFFFFF
  13. #define WS_NO_BATT 0xFF
  14. #define WS_NO_HUMIDITY 0xFF
  15. #define WS_NO_CHANNEL 0xFF
  16. #define WS_NO_BTN 0xFF
  17. #define WS_NO_TEMPERATURE -273.0f
  18. typedef struct WSBlockGeneric WSBlockGeneric;
  19. struct WSBlockGeneric {
  20. const char* protocol_name;
  21. uint64_t data;
  22. uint32_t id;
  23. uint8_t data_count_bit;
  24. uint8_t battery_low;
  25. uint8_t humidity;
  26. uint32_t timestamp;
  27. uint8_t channel;
  28. uint8_t btn;
  29. float temp;
  30. };
  31. /**
  32. * Get name preset.
  33. * @param preset_name name preset
  34. * @param preset_str Output name preset
  35. */
  36. void ws_block_generic_get_preset_name(const char* preset_name, FuriString* preset_str);
  37. /**
  38. * Serialize data WSBlockGeneric.
  39. * @param instance Pointer to a WSBlockGeneric instance
  40. * @param flipper_format Pointer to a FlipperFormat instance
  41. * @param preset The modulation on which the signal was received, SubGhzRadioPreset
  42. * @return true On success
  43. */
  44. bool ws_block_generic_serialize(
  45. WSBlockGeneric* instance,
  46. FlipperFormat* flipper_format,
  47. SubGhzRadioPreset* preset);
  48. /**
  49. * Deserialize data WSBlockGeneric.
  50. * @param instance Pointer to a WSBlockGeneric instance
  51. * @param flipper_format Pointer to a FlipperFormat instance
  52. * @return true On success
  53. */
  54. bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format);
  55. float ws_block_generic_fahrenheit_to_celsius(float fahrenheit);
  56. #ifdef __cplusplus
  57. }
  58. #endif