mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-12 23:48:10 -07:00
Merge branch 'ofwdev' into 420
This commit is contained in:
@@ -218,9 +218,9 @@ uint16_t subghz_protocol_blocks_lfsr_digest16(
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], unsigned num_bytes) {
|
||||
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t num_bytes) {
|
||||
int result = 0;
|
||||
for(unsigned i = 0; i < num_bytes; ++i) {
|
||||
for(size_t i = 0; i < num_bytes; ++i) {
|
||||
result += message[i];
|
||||
}
|
||||
return (uint8_t)result;
|
||||
@@ -232,17 +232,17 @@ int subghz_protocol_blocks_parity8(uint8_t byte) {
|
||||
return (0x6996 >> byte) & 1;
|
||||
}
|
||||
|
||||
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_bytes) {
|
||||
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t num_bytes) {
|
||||
int result = 0;
|
||||
for(unsigned i = 0; i < num_bytes; ++i) {
|
||||
for(size_t i = 0; i < num_bytes; ++i) {
|
||||
result ^= subghz_protocol_blocks_parity8(message[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], unsigned num_bytes) {
|
||||
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t num_bytes) {
|
||||
uint8_t result = 0;
|
||||
for(unsigned i = 0; i < num_bytes; ++i) {
|
||||
for(size_t i = 0; i < num_bytes; ++i) {
|
||||
result ^= message[i];
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -167,7 +167,7 @@ uint16_t subghz_protocol_blocks_lfsr_digest16(
|
||||
* @param num_bytes number of bytes to sum
|
||||
* @return summation value
|
||||
**/
|
||||
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], unsigned num_bytes);
|
||||
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], size_t num_bytes);
|
||||
|
||||
/**
|
||||
* Compute bit parity of a single byte (8 bits).
|
||||
@@ -182,7 +182,7 @@ int subghz_protocol_blocks_parity8(uint8_t byte);
|
||||
* @param num_bytes number of bytes to sum
|
||||
* @return 1 odd parity, 0 even parity
|
||||
**/
|
||||
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_bytes);
|
||||
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], size_t num_bytes);
|
||||
|
||||
/**
|
||||
* Compute XOR (byte-wide parity) of a number of bytes.
|
||||
@@ -190,7 +190,7 @@ int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_by
|
||||
* @param num_bytes number of bytes to sum
|
||||
* @return summation value, per bit-position 1 odd parity, 0 even parity
|
||||
**/
|
||||
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], unsigned num_bytes);
|
||||
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], size_t num_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+12
-18
@@ -43,6 +43,7 @@ struct SubGhzProtocolDecoderRAW {
|
||||
bool has_rssi_above_threshold;
|
||||
int rssi_threshold;
|
||||
uint8_t postroll_frames;
|
||||
bool pause;
|
||||
};
|
||||
|
||||
struct SubGhzProtocolEncoderRAW {
|
||||
@@ -169,6 +170,7 @@ bool subghz_protocol_raw_save_to_file_init(
|
||||
instance->upload_raw = malloc(SUBGHZ_DOWNLOAD_MAX_SIZE * sizeof(int32_t));
|
||||
instance->file_is_open = RAWFileIsOpenWrite;
|
||||
instance->sample_write = 0;
|
||||
instance->pause = false;
|
||||
init = true;
|
||||
} while(0);
|
||||
|
||||
@@ -240,6 +242,14 @@ void subghz_protocol_decoder_raw_set_auto_mode(void* context, bool auto_mode) {
|
||||
subghz_protocol_decoder_raw_reset(context);
|
||||
}
|
||||
|
||||
void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause) {
|
||||
furi_assert(instance);
|
||||
|
||||
if(instance->pause != pause) {
|
||||
instance->pause = pause;
|
||||
}
|
||||
}
|
||||
|
||||
size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolDecoderRAW* instance) {
|
||||
return instance->sample_write + instance->ind_write;
|
||||
}
|
||||
@@ -306,24 +316,8 @@ void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t durati
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderRAW* instance = context;
|
||||
|
||||
if(instance->upload_raw != NULL && duration > subghz_protocol_raw_const.te_short) {
|
||||
if(instance->auto_mode) {
|
||||
float rssi = furi_hal_subghz_get_rssi();
|
||||
|
||||
if(rssi >= instance->rssi_threshold) {
|
||||
subghz_protocol_decoder_raw_write_data(context, level, duration);
|
||||
instance->has_rssi_above_threshold = true;
|
||||
instance->postroll_frames = 0;
|
||||
} else if(instance->has_rssi_above_threshold) {
|
||||
subghz_protocol_decoder_raw_write_data(instance, level, duration);
|
||||
instance->postroll_frames++;
|
||||
|
||||
if(instance->postroll_frames >= SUBGHZ_AUTO_DETECT_RAW_POSTROLL_FRAMES) {
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!instance->pause && (instance->upload_raw != NULL)) {
|
||||
if(duration > subghz_protocol_raw_const.te_short) {
|
||||
if(instance->last_level != level) {
|
||||
instance->last_level = (level ? true : false);
|
||||
instance->upload_raw[instance->ind_write++] = (level ? duration : -duration);
|
||||
|
||||
@@ -142,6 +142,13 @@ void subghz_protocol_encoder_raw_free(void* context);
|
||||
*/
|
||||
void subghz_protocol_encoder_raw_stop(void* context);
|
||||
|
||||
/**
|
||||
* pause writing to flash.
|
||||
* @param context Pointer to a SubGhzProtocolEncoderRAW instance
|
||||
* @param pause pause writing
|
||||
*/
|
||||
void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause);
|
||||
|
||||
/**
|
||||
* Set callback on completion of file transfer.
|
||||
* @param instance Pointer to a SubGhzProtocolEncoderRAW instance
|
||||
|
||||
Reference in New Issue
Block a user