SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -1,12 +1,50 @@
|
||||
#include "subghz_protocol_common.h"
|
||||
#include <stdio.h>
|
||||
#include <lib/toolbox/hex.h>
|
||||
|
||||
|
||||
SubGhzProtocolEncoderCommon* subghz_protocol_encoder_common_alloc() {
|
||||
SubGhzProtocolEncoderCommon* instance = furi_alloc(sizeof(SubGhzProtocolEncoderCommon));
|
||||
instance->upload = furi_alloc(SUBGHZ_ENCODER_UPLOAD_MAX_SIZE * sizeof(LevelDuration));
|
||||
instance->start = true;
|
||||
instance->repeat = 10; //default number of repeat
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_protocol_encoder_common_free(SubGhzProtocolEncoderCommon* instance) {
|
||||
furi_assert(instance);
|
||||
free(instance->upload);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
size_t subghz_encoder_common_get_repeat_left(SubGhzProtocolEncoderCommon* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->repeat;
|
||||
}
|
||||
|
||||
LevelDuration subghz_protocol_encoder_common_yield(void* context) {
|
||||
SubGhzProtocolEncoderCommon* instance = context;
|
||||
|
||||
if(instance->repeat == 0){
|
||||
return level_duration_reset();
|
||||
}
|
||||
|
||||
LevelDuration ret = instance->upload[instance->front];
|
||||
|
||||
if(++instance->front == instance->size_upload) {
|
||||
instance->repeat--;
|
||||
instance->front = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void subghz_protocol_common_add_bit(SubGhzProtocolCommon *common, uint8_t bit){
|
||||
common->code_found = common->code_found <<1 | bit;
|
||||
common->code_found = common->code_found << 1 | bit;
|
||||
common->code_count_bit++;
|
||||
}
|
||||
|
||||
bool subghz_protocol_common_check_interval (SubGhzProtocolCommon *common, uint32_t duration, uint16_t duration_check) {
|
||||
bool subghz_protocol_common_check_interval(SubGhzProtocolCommon *common, uint32_t duration, uint16_t duration_check) {
|
||||
if ((duration_check >= (duration - common->te_delta))&&(duration_check <= (duration + common->te_delta))){
|
||||
return true;
|
||||
} else {
|
||||
@@ -75,3 +113,27 @@ void subghz_protocol_common_to_str(SubGhzProtocolCommon* instance, string_t outp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool subghz_protocol_common_read_hex(string_t str, uint8_t* buff, uint16_t len) {
|
||||
string_strim(str);
|
||||
uint8_t nibble_high = 0;
|
||||
uint8_t nibble_low = 0;
|
||||
bool parsed = true;
|
||||
|
||||
for(uint16_t i = 0; i < len; i++) {
|
||||
if(hex_char_to_hex_nibble(string_get_char(str, 0), &nibble_high) &&
|
||||
hex_char_to_hex_nibble(string_get_char(str, 1), &nibble_low)) {
|
||||
buff[i] = (nibble_high << 4) | nibble_low;
|
||||
if(string_size(str)>2){
|
||||
string_right(str, 2);
|
||||
}else if(i<len-1){
|
||||
parsed = false;
|
||||
break;
|
||||
};
|
||||
} else {
|
||||
parsed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
Reference in New Issue
Block a user