ws_generic.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 status
  44. */
  45. SubGhzProtocolStatus 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 status
  54. */
  55. SubGhzProtocolStatus
  56. ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format);
  57. /**
  58. * Deserialize data WSBlockGeneric.
  59. * @param instance Pointer to a WSBlockGeneric instance
  60. * @param flipper_format Pointer to a FlipperFormat instance
  61. * @param count_bit Count bit protocol
  62. * @return status
  63. */
  64. SubGhzProtocolStatus ws_block_generic_deserialize_check_count_bit(
  65. WSBlockGeneric* instance,
  66. FlipperFormat* flipper_format,
  67. uint16_t count_bit);
  68. #ifdef __cplusplus
  69. }
  70. #endif