mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
Merge branch 'fz-dev' into dev
This commit is contained in:
@@ -35,6 +35,11 @@ void LfRfidAppSceneWrite::on_enter(LfRfidApp* app, bool /* need_restore */) {
|
|||||||
popup->set_icon(0, 3, &I_RFIDDolphinSend_97x61);
|
popup->set_icon(0, 3, &I_RFIDDolphinSend_97x61);
|
||||||
|
|
||||||
app->view_controller.switch_to<PopupVM>();
|
app->view_controller.switch_to<PopupVM>();
|
||||||
|
|
||||||
|
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||||
|
app->old_key_data = (uint8_t*)malloc(size);
|
||||||
|
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
|
||||||
|
|
||||||
lfrfid_worker_start_thread(app->lfworker);
|
lfrfid_worker_start_thread(app->lfworker);
|
||||||
lfrfid_worker_write_start(
|
lfrfid_worker_write_start(
|
||||||
app->lfworker, (LFRFIDProtocol)app->protocol_id, lfrfid_write_callback, app);
|
app->lfworker, (LFRFIDProtocol)app->protocol_id, lfrfid_write_callback, app);
|
||||||
@@ -76,4 +81,8 @@ void LfRfidAppSceneWrite::on_exit(LfRfidApp* app) {
|
|||||||
app->view_controller.get<PopupVM>()->clean();
|
app->view_controller.get<PopupVM>()->clean();
|
||||||
lfrfid_worker_stop(app->lfworker);
|
lfrfid_worker_stop(app->lfworker);
|
||||||
lfrfid_worker_stop_thread(app->lfworker);
|
lfrfid_worker_stop_thread(app->lfworker);
|
||||||
|
|
||||||
|
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
||||||
|
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
|
||||||
|
free(app->old_key_data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -522,9 +522,17 @@ static void lfrfid_worker_mode_write_process(LFRFIDWorker* worker) {
|
|||||||
&read_result);
|
&read_result);
|
||||||
|
|
||||||
if(state == LFRFIDWorkerReadOK) {
|
if(state == LFRFIDWorkerReadOK) {
|
||||||
|
bool read_success = false;
|
||||||
|
|
||||||
|
if(read_result == protocol) {
|
||||||
protocol_dict_get_data(worker->protocols, protocol, read_data, data_size);
|
protocol_dict_get_data(worker->protocols, protocol, read_data, data_size);
|
||||||
|
|
||||||
if(memcmp(read_data, verify_data, data_size) == 0) {
|
if(memcmp(read_data, verify_data, data_size) == 0) {
|
||||||
|
read_success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(read_success) {
|
||||||
if(worker->write_cb) {
|
if(worker->write_cb) {
|
||||||
worker->write_cb(LFRFIDWorkerWriteOK, worker->cb_ctx);
|
worker->write_cb(LFRFIDWorkerWriteOK, worker->cb_ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,8 +112,11 @@ static bool subghz_protocol_encoder_came_get_upload(SubGhzProtocolEncoderCame* i
|
|||||||
instance->encoder.size_upload = size_upload;
|
instance->encoder.size_upload = size_upload;
|
||||||
}
|
}
|
||||||
//Send header
|
//Send header
|
||||||
instance->encoder.upload[index++] =
|
instance->encoder.upload[index++] = level_duration_make(
|
||||||
level_duration_make(false, (uint32_t)subghz_protocol_came_const.te_short * 36);
|
false,
|
||||||
|
((instance->generic.data_count_bit == subghz_protocol_came_const.min_count_bit_for_found) ?
|
||||||
|
(uint32_t)subghz_protocol_came_const.te_short * 39 :
|
||||||
|
(uint32_t)subghz_protocol_came_const.te_short * 76));
|
||||||
//Send start bit
|
//Send start bit
|
||||||
instance->encoder.upload[index++] =
|
instance->encoder.upload[index++] =
|
||||||
level_duration_make(true, (uint32_t)subghz_protocol_came_const.te_short);
|
level_duration_make(true, (uint32_t)subghz_protocol_came_const.te_short);
|
||||||
@@ -213,8 +216,8 @@ void subghz_protocol_decoder_came_feed(void* context, bool level, uint32_t durat
|
|||||||
SubGhzProtocolDecoderCame* instance = context;
|
SubGhzProtocolDecoderCame* instance = context;
|
||||||
switch(instance->decoder.parser_step) {
|
switch(instance->decoder.parser_step) {
|
||||||
case CameDecoderStepReset:
|
case CameDecoderStepReset:
|
||||||
if((!level) && (DURATION_DIFF(duration, subghz_protocol_came_const.te_short * 51) <
|
if((!level) && (DURATION_DIFF(duration, subghz_protocol_came_const.te_short * 56) <
|
||||||
subghz_protocol_came_const.te_delta * 51)) { //Need protocol 36 te_short
|
subghz_protocol_came_const.te_delta * 47)) {
|
||||||
//Found header CAME
|
//Found header CAME
|
||||||
instance->decoder.parser_step = CameDecoderStepFoundStartBit;
|
instance->decoder.parser_step = CameDecoderStepFoundStartBit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ bool subghz_protocol_encoder_chamb_code_deserialize(void* context, FlipperFormat
|
|||||||
FURI_LOG_E(TAG, "Deserialize error");
|
FURI_LOG_E(TAG, "Deserialize error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(instance->generic.data_count_bit <
|
if(instance->generic.data_count_bit >
|
||||||
subghz_protocol_chamb_code_const.min_count_bit_for_found) {
|
subghz_protocol_chamb_code_const.min_count_bit_for_found) {
|
||||||
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
||||||
break;
|
break;
|
||||||
@@ -441,7 +441,7 @@ bool subghz_protocol_decoder_chamb_code_deserialize(void* context, FlipperFormat
|
|||||||
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(instance->generic.data_count_bit <
|
if(instance->generic.data_count_bit >
|
||||||
subghz_protocol_chamb_code_const.min_count_bit_for_found) {
|
subghz_protocol_chamb_code_const.min_count_bit_for_found) {
|
||||||
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user