Skip to content

Commit

Permalink
Latest Release RM0210-1603-0.97.2-2707a31 on PATREON - SUBG OVERHAUL …
Browse files Browse the repository at this point in the history
…PREWORK
  • Loading branch information
RogueMaster committed Feb 12, 2024
1 parent 1b29e4f commit 4f3f47d
Show file tree
Hide file tree
Showing 25 changed files with 207 additions and 45 deletions.
3 changes: 3 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ This software is for experimental purposes only and is not meant for any illegal
- OFW: [Check universal remote files before loading #3438 (By gsurkov)](https://github.com/flipperdevices/flipperzero-firmware/pull/3438)
- OFW: [Fixed MyKey LockID #3412 (By zProAle)](https://github.com/flipperdevices/flipperzero-firmware/pull/3412) - Was Already In RM
- Minor var type changes for the coming OFW update [3254](https://github.com/flipperdevices/flipperzero-firmware/pull/3254) (By Willy-JL)
- [CFW Settings - favorite_timeout (By WillyJL)]()
- [SubGhz protocol integrations (Weather, Pocsag, TPMS) (By htotoo)]()
- [Add GPS support for SubGHz (By Sil333033)]()
- To Be Merged OFW PRs: [3352](https://github.com/flipperdevices/flipperzero-firmware/pull/3352), [3302](https://github.com/flipperdevices/flipperzero-firmware/pull/3302), [3211](https://github.com/flipperdevices/flipperzero-firmware/pull/3211), [3366](https://github.com/flipperdevices/flipperzero-firmware/pull/3366), [3250](https://github.com/flipperdevices/flipperzero-firmware/pull/3250), [3402](https://github.com/flipperdevices/flipperzero-firmware/pull/3402), [3409](https://github.com/flipperdevices/flipperzero-firmware/pull/3409), [3406](https://github.com/flipperdevices/flipperzero-firmware/pull/3406), [3431](https://github.com/flipperdevices/flipperzero-firmware/pull/3431), [3254](https://github.com/flipperdevices/flipperzero-firmware/pull/3254) & [3429](https://github.com/flipperdevices/flipperzero-firmware/pull/3429)

<a name="release">
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/unit_tests/nfc/nfc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void nfc_test_alloc() {
}

static void nfc_test_free() {
furi_assert(nfc_test);
furi_check(nfc_test);

furi_record_close(RECORD_STORAGE);
free(nfc_test);
Expand Down
50 changes: 25 additions & 25 deletions applications/debug/unit_tests/nfc/nfc_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Nfc* nfc_alloc() {
}

void nfc_free(Nfc* instance) {
furi_assert(instance);
furi_check(instance);

free(instance);
}
Expand Down Expand Up @@ -165,9 +165,9 @@ NfcError nfc_iso14443a_listener_set_col_res_data(
uint8_t uid_len,
uint8_t* atqa,
uint8_t sak) {
furi_assert(instance);
furi_assert(uid);
furi_assert(atqa);
furi_check(instance);
furi_check(uid);
furi_check(atqa);

nfc_prepare_col_res_data(instance, uid, uid_len, atqa, sak);

Expand All @@ -176,7 +176,7 @@ NfcError nfc_iso14443a_listener_set_col_res_data(

static int32_t nfc_worker_poller(void* context) {
Nfc* instance = context;
furi_assert(instance->callback);
furi_check(instance->callback);

instance->state = NfcStateReady;
NfcCommand command = NfcCommandContinue;
Expand All @@ -196,7 +196,7 @@ static int32_t nfc_worker_poller(void* context) {
}

static void nfc_worker_listener_pass_col_res(Nfc* instance, uint8_t* rx_data, uint16_t rx_bits) {
furi_assert(instance->col_res_status != Iso14443_3aColResStatusDone);
furi_check(instance->col_res_status != Iso14443_3aColResStatusDone);
BitBuffer* tx_buffer = bit_buffer_alloc(NFC_MAX_BUFFER_SIZE);

bool processed = false;
Expand Down Expand Up @@ -255,7 +255,7 @@ static void nfc_worker_listener_pass_col_res(Nfc* instance, uint8_t* rx_data, ui

static int32_t nfc_worker_listener(void* context) {
Nfc* instance = context;
furi_assert(instance->callback);
furi_check(instance->callback);

NfcMessage message = {};

Expand Down Expand Up @@ -295,17 +295,17 @@ static int32_t nfc_worker_listener(void* context) {
}

void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
furi_assert(instance);
furi_assert(instance->worker_thread == NULL);
furi_check(instance);
furi_check(instance->worker_thread == NULL);

if(instance->mode == NfcModeListener) {
furi_assert(listener_queue == NULL);
furi_check(listener_queue == NULL);
// Check that poller didn't start
furi_assert(poller_queue == NULL);
furi_check(poller_queue == NULL);
} else {
furi_assert(poller_queue == NULL);
furi_check(poller_queue == NULL);
// Check that poller is started after listener
furi_assert(listener_queue);
furi_check(listener_queue);
}

instance->callback = callback;
Expand Down Expand Up @@ -334,8 +334,8 @@ void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
}

void nfc_stop(Nfc* instance) {
furi_assert(instance);
furi_assert(instance->worker_thread);
furi_check(instance);
furi_check(instance->worker_thread);

if(instance->mode == NfcModeListener) {
NfcMessage message = {.type = NfcMessageTypeAbort};
Expand All @@ -361,10 +361,10 @@ void nfc_stop(Nfc* instance) {
// Called from worker thread

NfcError nfc_listener_tx(Nfc* instance, const BitBuffer* tx_buffer) {
furi_assert(instance);
furi_assert(poller_queue);
furi_assert(listener_queue);
furi_assert(tx_buffer);
furi_check(instance);
furi_check(poller_queue);
furi_check(listener_queue);
furi_check(tx_buffer);

NfcMessage message = {};
message.type = NfcMessageTypeTx;
Expand All @@ -382,11 +382,11 @@ NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer*

NfcError
nfc_poller_trx(Nfc* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) {
furi_assert(instance);
furi_assert(tx_buffer);
furi_assert(rx_buffer);
furi_assert(poller_queue);
furi_assert(listener_queue);
furi_check(instance);
furi_check(tx_buffer);
furi_check(rx_buffer);
furi_check(poller_queue);
furi_check(listener_queue);
UNUSED(fwt);

NfcError error = NfcErrorNone;
Expand All @@ -396,7 +396,7 @@ NfcError
message.data.data_bits = bit_buffer_get_size(tx_buffer);
bit_buffer_write_bytes(tx_buffer, message.data.data, bit_buffer_get_size_bytes(tx_buffer));
// Tx
furi_assert(furi_message_queue_put(listener_queue, &message, FuriWaitForever) == FuriStatusOk);
furi_check(furi_message_queue_put(listener_queue, &message, FuriWaitForever) == FuriStatusOk);
// Rx
FuriStatus status = furi_message_queue_get(poller_queue, &message, 50);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Filetype: Flipper SubGhz RAW File
Version: 1
Frequency: 433920000
Preset: FuriHalSubGhzPresetOok270Async
Protocol: RAW
RAW_Data: 24683 -68 97699 -66 49329 -68 77683 -66 369085 -100 59281 -68 29331 -64 357017 -68 284193 -66 128025 -64 198459 -64 522601 -66 111101 -70 132215 -64 288735 -68 747835 -102 26103 -70 25451 -68 349459 -66 166857 -66 68137 -66 595143 -128 59929 -66 17225 -66 16705 -66 105655 -66 10015 -38916 101 -2318 493 -708 395 -716 505 -734 487 -694 343 -274 339 -260 163 -440 343 -306 319 -268 159 -436 201 -432 157 -438 387 -244 179 -410 379 -234 187 -430 397 -218 183 -436 387 -236 371 -244 179 -414 409 -190 223 -410 193 -416 213 -396 393 -228 199 -406 209 -422 207 -392 387 -240 207 -384 419 -204 219 -394 203 -418 379 -244 395 -202 395 -208 251 -392 205 -380 221 -378 417 -242 215 -392 205 -396 203 -408 417 -204 217 -396 203 -394 389 -246 393 -206 393 -240 217 -396 203 -394 205 -410 191 -418 411 -190 401 -246 389 -206 393 -240 379 -222 187 -400 239 -2198 615 -592 615 -612 605 -614 597 -620 367 -224 411 -214 215 -402 387 -206 407 -226 197 -404 209 -422 205 -394 387 -238 207 -384 417 -204 219 -394 389 -238 205 -388 415 -206 379 -222 227 -400 417 -204 217 -396 203 -394 231 -370 413 -240 217 -394 203 -394 207 -408 393 -240 217 -392 367 -222 225 -400 209 -418 367 -224 413 -214 393 -204 215 -428 207 -394 201 -394 391 -246 213 -368 245 -394 203 -394 385 -240 209 -392 243 -390 395 -226 385 -212 395 -238 219 -392 205 -394 203 -418 223 -412 387 -242 369 -226 393 -210 395 -238 393 -208 217 -394 203 -59252 317 -277080 99 -1690 201 -634 469 -270 1393 -300 97817 -66 55659 -64 628165 -64 110139 -100 61425 -66 59611 -66 6621 -68 18847 -66 468225 -64 99275
4 changes: 2 additions & 2 deletions applications/debug/unit_tests/rpc/rpc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static RpcSessionContext rpc_session[TEST_RPC_SESSIONS];

#define TAG "UnitTestsRpc"
#define MAX_RECEIVE_OUTPUT_TIMEOUT 3000
#define MAX_NAME_LENGTH 255
#define MAX_NAME_LENGTH 254
#define MAX_DATA_SIZE 512u // have to be exact as in rpc_storage.c
#define TEST_DIR TEST_DIR_NAME "/"
#define TEST_DIR_NAME EXT_PATH("unit_tests_tmp")
Expand Down Expand Up @@ -641,7 +641,7 @@ static void test_rpc_storage_list_create_expected_list(

while(!finish) {
FileInfo fileinfo;
char* name = malloc(MAX_NAME_LENGTH + 1);
char* name = malloc(MAX_NAME_LENGTH);
if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {
if(i == COUNT_OF(list->file)) {
list->file_count = i;
Expand Down
8 changes: 8 additions & 0 deletions applications/debug/unit_tests/subghz/subghz_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,13 @@ MU_TEST(subghz_encoder_mastercode_test) {
"Test encoder " SUBGHZ_PROTOCOL_MASTERCODE_NAME " error\r\n");
}

MU_TEST(subghz_decoder_acurite_592txr_test) {
mu_assert(
subghz_decoder_test(
EXT_PATH("unit_tests/subghz/acurite_592txr.sub"), WS_PROTOCOL_ACURITE_592TXR_NAME),
"Test decoder " WS_PROTOCOL_ACURITE_592TXR_NAME " error\r\n");
}

MU_TEST(subghz_random_test) {
mu_assert(subghz_decode_random_test(TEST_RANDOM_DIR_NAME), "Random test error\r\n");
}
Expand Down Expand Up @@ -897,6 +904,7 @@ MU_TEST_SUITE(subghz) {
MU_RUN_TEST(subghz_encoder_holtek_ht12x_test);
MU_RUN_TEST(subghz_encoder_dooya_test);
MU_RUN_TEST(subghz_encoder_mastercode_test);
MU_RUN_TEST(subghz_decoder_acurite_592txr_test);

MU_RUN_TEST(subghz_random_test);
subghz_test_deinit();
Expand Down
3 changes: 3 additions & 0 deletions applications/main/archive/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ App(
requires=["gui"],
stack_size=6 * 1024,
order=0,
sdk_headers=[
"helpers/archive_helpers_ext.h",
],
)
24 changes: 24 additions & 0 deletions applications/main/archive/helpers/archive_helpers_ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <furi.h>
#include <gui/scene_manager.h>
#include <gui/view_dispatcher.h>

#ifdef __cplusplus
extern "C" {
#endif

bool process_favorite_launch(char** p);

typedef struct {
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;
} FavoriteTImeoutCtx;

void favorite_timeout_callback(void* _ctx);

void favorite_timeout_run(ViewDispatcher* view_dispatcher, SceneManager* scene_manager);

#ifdef __cplusplus
}
#endif
32 changes: 32 additions & 0 deletions applications/main/archive/helpers/favorite_timeout.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "archive_helpers_ext.h"
#include <cfw/cfw.h>

bool process_favorite_launch(char** args) {
if(*args && strlen(*args) > 4 && strncmp(*args, "fav/", 4) == 0) {
*args += 3;
return true;
}
return false;
}

void favorite_timeout_callback(void* _ctx) {
FavoriteTImeoutCtx* ctx = _ctx;
while(scene_manager_previous_scene(ctx->scene_manager))
;
view_dispatcher_stop(ctx->view_dispatcher);
}

void favorite_timeout_run(ViewDispatcher* view_dispatcher, SceneManager* scene_manager) {
uint32_t timeout = CFW_SETTINGS()->favorite_timeout;
if(timeout == 0) {
view_dispatcher_run(view_dispatcher);
return;
}

FavoriteTImeoutCtx ctx = {.view_dispatcher = view_dispatcher, .scene_manager = scene_manager};
FuriTimer* timer = furi_timer_alloc(favorite_timeout_callback, FuriTimerTypeOnce, &ctx);
furi_timer_start(timer, timeout * furi_kernel_get_tick_frequency());
view_dispatcher_run(view_dispatcher);
furi_timer_stop(timer);
furi_timer_free(timer);
}
10 changes: 8 additions & 2 deletions applications/main/ibutton/ibutton.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <toolbox/path.h>
#include <dolphin/dolphin.h>
#include <applications/main/archive/helpers/archive_helpers_ext.h>

#define TAG "IButtonApp"

Expand Down Expand Up @@ -266,13 +267,14 @@ void ibutton_widget_callback(GuiButtonType result, InputType type, void* context
}
}

int32_t ibutton_app(void* arg) {
int32_t ibutton_app(char* arg) {
iButton* ibutton = ibutton_alloc();

ibutton_make_app_folder(ibutton);

bool key_loaded = false;

bool is_favorite = process_favorite_launch(&arg);
if((arg != NULL) && (strlen(arg) != 0)) {
if(sscanf(arg, "RPC %lX", (uint32_t*)&ibutton->rpc) == 1) {
FURI_LOG_D(TAG, "Running in RPC mode");
Expand Down Expand Up @@ -303,7 +305,11 @@ int32_t ibutton_app(void* arg) {
}
}

view_dispatcher_run(ibutton->view_dispatcher);
if(is_favorite) {
favorite_timeout_run(ibutton->view_dispatcher, ibutton->scene_manager);
} else {
view_dispatcher_run(ibutton->view_dispatcher);
}

if(ibutton->rpc) {
rpc_system_app_set_callback(ibutton->rpc, NULL, NULL);
Expand Down
3 changes: 3 additions & 0 deletions applications/main/lfrfid/lfrfid.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "lfrfid_i.h"
#include <lfrfid_icons.h>
#include <dolphin/dolphin.h>
#include <applications/main/archive/helpers/archive_helpers_ext.h>

//TODO: use .txt file in resources for passwords.
const uint32_t default_passwords[] = {
Expand Down Expand Up @@ -213,6 +214,7 @@ int32_t lfrfid_app(void* p) {

lfrfid_make_app_folder(app);

bool is_favorite = process_favorite_launch(&args);
if(args && strlen(args)) {
uint32_t rpc_ctx_ptr = 0;
if(sscanf(args, "RPC %lX", &rpc_ctx_ptr) == 1) {
Expand All @@ -228,6 +230,7 @@ int32_t lfrfid_app(void* p) {
if(lfrfid_load_key_data(app, app->file_path, true)) {
view_dispatcher_attach_to_gui(
app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
app->fav_timeout = is_favorite;
scene_manager_next_scene(app->scene_manager, LfRfidSceneEmulate);
dolphin_deed(DolphinDeedRfidEmulate);
} else {
Expand Down
1 change: 1 addition & 0 deletions applications/main/lfrfid/lfrfid_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ struct LfRfid {
uint8_t write_block;
//uint8_t read_page;
//uint8_t read_block;
bool fav_timeout;
};

typedef enum {
Expand Down
9 changes: 7 additions & 2 deletions applications/main/lfrfid/scenes/lfrfid_scene_emulate.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "../lfrfid_i.h"
#include <lfrfid_icons.h>
#include <cfw/cfw.h>

#define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000)

Expand Down Expand Up @@ -35,8 +36,12 @@ void lfrfid_scene_emulate_on_enter(void* context) {
timer_auto_exit =
furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app);

if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug))
furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS);
if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) || app->fav_timeout)
furi_timer_start(
timer_auto_exit,
app->fav_timeout ?
CFW_SETTINGS()->favorite_timeout * furi_kernel_get_tick_frequency() :
LFRFID_EMULATION_TIME_MAX_MS);

view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
}
Expand Down
3 changes: 3 additions & 0 deletions applications/main/nfc/nfc_app.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "nfc_app_i.h"
#include "nfc_icons.h"
#include "helpers/protocol_support/nfc_protocol_support.h"
#include <applications/main/archive/helpers/archive_helpers_ext.h>

#include <dolphin/dolphin.h>

Expand Down Expand Up @@ -494,6 +495,7 @@ int32_t nfc_app(void* p) {
NfcApp* nfc = nfc_app_alloc();
const char* args = p;

bool is_favorite = process_favorite_launch((char**)&args);
if(args && strlen(args)) {
if(sscanf(args, "RPC %p", &nfc->rpc_ctx) == 1) {
rpc_system_app_set_callback(nfc->rpc_ctx, nfc_app_rpc_command_callback, nfc);
Expand All @@ -507,6 +509,7 @@ int32_t nfc_app(void* p) {

furi_string_set(nfc->file_path, args);
if(nfc_load_file(nfc, nfc->file_path, false)) {
nfc->fav_timeout = is_favorite;
nfc_show_initial_scene_for_device(nfc);
} else {
view_dispatcher_stop(nfc->view_dispatcher);
Expand Down
2 changes: 2 additions & 0 deletions applications/main/nfc/nfc_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ struct NfcApp {
FuriString* file_path;
FuriString* file_name;
FuriTimer* timer;

bool fav_timeout;
};

typedef enum {
Expand Down
Loading

0 comments on commit 4f3f47d

Please sign in to comment.