shapshup_files.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <furi.h>
  3. #include "m-array.h"
  4. #include <toolbox/path.h>
  5. #include <flipper_format_i.h>
  6. #include <flipper_format_stream_i.h>
  7. /**
  8. * @brief file operation result response
  9. *
  10. */
  11. typedef enum {
  12. ShapShupFileResultOk,
  13. ShapShupFileResultOpenError,
  14. ShapShupFileResultIncorrectHeader,
  15. ShapShupFileResultTypeOfVersionMismatch,
  16. ShapShupFileResultNotRawFile,
  17. ShapShupFileResultMissingFrequency,
  18. ShapShupFileResultMissingPreset,
  19. ShapShupFileResultMissingProtocol,
  20. ShapShupFileResultKeyNotFound,
  21. ShapShupFileResultUnknown,
  22. ShapShupFileResultTotal
  23. } ShapShupFileResults;
  24. /**
  25. * @brief Construct a new array def object
  26. *
  27. */
  28. ARRAY_DEF(array_raw, int32_t)
  29. /**
  30. * @brief contains info about .sub file
  31. *
  32. */
  33. typedef struct {
  34. ShapShupFileResults result;
  35. uint32_t frequency;
  36. uint64_t total_len;
  37. uint64_t total_count;
  38. int32_t min_value;
  39. int32_t max_value;
  40. uint64_t min_len;
  41. uint64_t max_len;
  42. array_raw_t values;
  43. } ShapShupRawFile;
  44. /**
  45. * @brief load_file_shapshup
  46. *
  47. * @param file_path
  48. * @return ShapShupRawFile*
  49. */
  50. ShapShupRawFile* load_file_shapshup(const char* file_path);
  51. /**
  52. * @brief read_int32_shapshup
  53. *
  54. * @param stream stream to read
  55. * @param _data return readed data
  56. * @param data_size size of data to read
  57. * @return true/false
  58. */
  59. bool read_int32_shapshup(Stream* stream, int32_t* _data, uint16_t data_size);
  60. /**
  61. * @brief get description about file operation
  62. *
  63. * @param result_code struct @see ShapShupFileResults
  64. * @return human readable description about result code
  65. */
  66. const char* shapshup_files_result_description(ShapShupFileResults result_code);
  67. /**
  68. * @brief make clean of array to read new values
  69. *
  70. * @param raw_file @see ShapShupRawFile
  71. */
  72. void clean_raw_values(ShapShupRawFile* raw_file);