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