ws_generic.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. uint8_t channel;
  27. uint8_t btn;
  28. float temp;
  29. };
  30. /**
  31. * Get name preset.
  32. * @param preset_name name preset
  33. * @param preset_str Output name preset
  34. */
  35. void ws_block_generic_get_preset_name(const char* preset_name, FuriString* preset_str);
  36. /**
  37. * Serialize data WSBlockGeneric.
  38. * @param instance Pointer to a WSBlockGeneric instance
  39. * @param flipper_format Pointer to a FlipperFormat instance
  40. * @param preset The modulation on which the signal was received, SubGhzRadioPreset
  41. * @return true On success
  42. */
  43. bool ws_block_generic_serialize(
  44. WSBlockGeneric* instance,
  45. FlipperFormat* flipper_format,
  46. SubGhzRadioPreset* preset);
  47. /**
  48. * Deserialize data WSBlockGeneric.
  49. * @param instance Pointer to a WSBlockGeneric instance
  50. * @param flipper_format Pointer to a FlipperFormat instance
  51. * @return true On success
  52. */
  53. bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format);
  54. float ws_block_generic_fahrenheit_to_celsius(float fahrenheit);
  55. #ifdef __cplusplus
  56. }
  57. #endif