Merge remote-tracking branch 'OFW/dev' into dev

This commit is contained in:
MX
2025-02-20 03:08:53 +03:00
28 changed files with 621 additions and 127 deletions
+16
View File
@@ -8,6 +8,11 @@
#include "flipper_format_stream.h"
#include "flipper_format_stream_i.h"
// permits direct casting between `FlipperFormatOffset` and `StreamOffset`
static_assert((size_t)FlipperFormatOffsetFromCurrent == (size_t)StreamOffsetFromCurrent);
static_assert((size_t)FlipperFormatOffsetFromStart == (size_t)StreamOffsetFromStart);
static_assert((size_t)FlipperFormatOffsetFromEnd == (size_t)StreamOffsetFromEnd);
/********************************** Private **********************************/
struct FlipperFormat {
Stream* stream;
@@ -127,6 +132,17 @@ bool flipper_format_rewind(FlipperFormat* flipper_format) {
return stream_rewind(flipper_format->stream);
}
size_t flipper_format_tell(FlipperFormat* flipper_format) {
furi_check(flipper_format);
return stream_tell(flipper_format->stream);
}
bool flipper_format_seek(FlipperFormat* flipper_format, int32_t offset, FlipperFormatOffset anchor) {
furi_check(flipper_format);
// direct usage of `anchor` made valid by `static_assert`s at the top of this file
return stream_seek(flipper_format->stream, offset, (StreamOffset)anchor);
}
bool flipper_format_seek_to_end(FlipperFormat* flipper_format) {
furi_check(flipper_format);
return stream_seek(flipper_format->stream, 0, StreamOffsetFromEnd);
+24
View File
@@ -94,6 +94,12 @@ extern "C" {
typedef struct FlipperFormat FlipperFormat;
typedef enum {
FlipperFormatOffsetFromCurrent,
FlipperFormatOffsetFromStart,
FlipperFormatOffsetFromEnd,
} FlipperFormatOffset;
/** Allocate FlipperFormat as string.
*
* @return FlipperFormat* pointer to a FlipperFormat instance
@@ -216,6 +222,24 @@ void flipper_format_set_strict_mode(FlipperFormat* flipper_format, bool strict_m
*/
bool flipper_format_rewind(FlipperFormat* flipper_format);
/** Get the RW pointer position
*
* @param flipper_format Pointer to a FlipperFormat instance
*
* @return RW pointer position
*/
size_t flipper_format_tell(FlipperFormat* flipper_format);
/** Set the RW pointer position to an arbitrary value
*
* @param flipper_format Pointer to a FlipperFormat instance
* @param offset Offset relative to the anchor point
* @param anchor Anchor point (e.g. start of file)
*
* @return True on success
*/
bool flipper_format_seek(FlipperFormat* flipper_format, int32_t offset, FlipperFormatOffset anchor);
/** Move the RW pointer at the end. Can be useful if you want to add some data
* after reading.
*
+1
View File
@@ -317,6 +317,7 @@ SubGhzProtocolStatus
res = SubGhzProtocolStatusErrorEncoderGetUpload;
break;
}
instance->encoder.is_running = true;
res = SubGhzProtocolStatusOk;