Skip to content

Commit f862c53

Browse files
committed
SubGhz Honeywell 5834: size encoder buffer for 48-bit frame only
Allocate encoder upload buffer for exactly 99 LevelDuration entries (sync 3 + 48 bits * 2) instead of 128, saving ~116 bytes RAM per encoder instance on Flipper Zero. Add H5834_UPLOAD_MAX constant and use it for allocation and bounds check.
1 parent 75dd2c3 commit f862c53

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/subghz/protocols/honeywell_5834.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define H5834_SYNC_PULSE 300
3333
#define H5834_GAP 120
3434
#define H5834_MIN_COUNT_BIT 48
35+
/* Encoder: sync(3) + 48 data bits * 2 (pulse+gap) = 99 LevelDuration entries */
36+
#define H5834_UPLOAD_MAX (3 + (H5834_MIN_COUNT_BIT * 2))
3537

3638
static const SubGhzBlockConst subghz_protocol_honeywell_5834_const = {
3739
.te_short = H5834_TE_SHORT,
@@ -105,7 +107,7 @@ void* subghz_protocol_encoder_honeywell_5834_alloc(SubGhzEnvironment* environmen
105107
instance->generic.protocol_name = instance->base.protocol->name;
106108

107109
instance->encoder.repeat = 10;
108-
instance->encoder.size_upload = 128;
110+
instance->encoder.size_upload = H5834_UPLOAD_MAX;
109111
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
110112
instance->encoder.is_running = false;
111113
return instance;
@@ -126,10 +128,10 @@ static bool subghz_protocol_encoder_honeywell_5834_get_upload(
126128
SubGhzProtocolEncoderHoneywell5834* instance) {
127129
furi_assert(instance);
128130

129-
/* sync(3) + data_bits * 2 = 3 + 48*2 = 99 max, well within 128 */
131+
/* sync(3) + data_bits * 2; 48-bit frame => 99 entries (H5834_UPLOAD_MAX) */
130132
size_t index = 0;
131133
size_t size_upload = 3 + (instance->generic.data_count_bit * 2);
132-
if(size_upload > instance->encoder.size_upload) {
134+
if(size_upload > H5834_UPLOAD_MAX) {
133135
FURI_LOG_E(TAG, "Size upload exceeds allocated encoder buffer.");
134136
return false;
135137
}

0 commit comments

Comments
 (0)