Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Mar 10, 2023
2 parents 119c7fe + 0190a16 commit dec00fe
Show file tree
Hide file tree
Showing 343 changed files with 8,087 additions and 5,058 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ jobs:
echo random_hash=$(openssl rand -base64 40 | shasum -a 256 | awk '{print $1}') >> $GITHUB_OUTPUT
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
- name: 'Check API versions'
run: |
set -e
N_API_HEADER_SIGNATURES=`ls -1 firmware/targets/f*/api_symbols.csv | xargs -I {} sh -c "head -n2 {} | md5sum" | sort -u | wc -l`
if [ $N_API_HEADER_SIGNATURES != 1 ] ; then
echo API versions aren\'t matching for available targets. Please update!
head -n2 firmware/targets/f*/api_symbols.csv
exit 1
fi
- name: 'Make artifacts directory'
run: |
rm -rf artifacts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
*.swp
*.swo
*.gdb_history
Expand Down
3 changes: 3 additions & 0 deletions .pvsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@

# Functions that always return the same error code
//-V:picopass_device_decrypt:1048

# Examples
//V_EXCLUDE_PATH applications/examples/
54 changes: 28 additions & 26 deletions applications/debug/keypad_test/keypad_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef struct {
uint16_t left;
uint16_t right;
uint16_t ok;
FuriMutex* mutex;
} KeypadTestState;

static void keypad_test_reset_state(KeypadTestState* state) {
Expand All @@ -22,7 +23,8 @@ static void keypad_test_reset_state(KeypadTestState* state) {
}

static void keypad_test_render_callback(Canvas* canvas, void* ctx) {
KeypadTestState* state = (KeypadTestState*)acquire_mutex((ValueMutex*)ctx, 25);
KeypadTestState* state = ctx;
furi_mutex_acquire(state->mutex, FuriWaitForever);
canvas_clear(canvas);
char strings[5][20];

Expand Down Expand Up @@ -51,7 +53,7 @@ static void keypad_test_render_callback(Canvas* canvas, void* ctx) {

canvas_draw_str(canvas, 10, 63, "[back] - reset, hold to exit");

release_mutex((ValueMutex*)ctx, state);
furi_mutex_release(state->mutex);
}

static void keypad_test_input_callback(InputEvent* input_event, void* ctx) {
Expand All @@ -64,17 +66,17 @@ int32_t keypad_test_app(void* p) {
FuriMessageQueue* event_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
furi_check(event_queue);

KeypadTestState _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0};
KeypadTestState state = {{false, false, false, false, false}, 0, 0, 0, 0, 0, NULL};
state.mutex = furi_mutex_alloc(FuriMutexTypeNormal);

ValueMutex state_mutex;
if(!init_mutex(&state_mutex, &_state, sizeof(KeypadTestState))) {
if(!state.mutex) {
FURI_LOG_E(TAG, "cannot create mutex");
return 0;
}

ViewPort* view_port = view_port_alloc();

view_port_draw_callback_set(view_port, keypad_test_render_callback, &state_mutex);
view_port_draw_callback_set(view_port, keypad_test_render_callback, &state);
view_port_input_callback_set(view_port, keypad_test_input_callback, event_queue);

// Open GUI and register view_port
Expand All @@ -83,7 +85,7 @@ int32_t keypad_test_app(void* p) {

InputEvent event;
while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
KeypadTestState* state = (KeypadTestState*)acquire_mutex_block(&state_mutex);
furi_mutex_acquire(state.mutex, FuriWaitForever);
FURI_LOG_I(
TAG,
"key: %s type: %s",
Expand All @@ -92,62 +94,62 @@ int32_t keypad_test_app(void* p) {

if(event.key == InputKeyRight) {
if(event.type == InputTypePress) {
state->press[0] = true;
state.press[0] = true;
} else if(event.type == InputTypeRelease) {
state->press[0] = false;
state.press[0] = false;
} else if(event.type == InputTypeShort) {
++state->right;
++state.right;
}
} else if(event.key == InputKeyLeft) {
if(event.type == InputTypePress) {
state->press[1] = true;
state.press[1] = true;
} else if(event.type == InputTypeRelease) {
state->press[1] = false;
state.press[1] = false;
} else if(event.type == InputTypeShort) {
++state->left;
++state.left;
}
} else if(event.key == InputKeyUp) {
if(event.type == InputTypePress) {
state->press[2] = true;
state.press[2] = true;
} else if(event.type == InputTypeRelease) {
state->press[2] = false;
state.press[2] = false;
} else if(event.type == InputTypeShort) {
++state->up;
++state.up;
}
} else if(event.key == InputKeyDown) {
if(event.type == InputTypePress) {
state->press[3] = true;
state.press[3] = true;
} else if(event.type == InputTypeRelease) {
state->press[3] = false;
state.press[3] = false;
} else if(event.type == InputTypeShort) {
++state->down;
++state.down;
}
} else if(event.key == InputKeyOk) {
if(event.type == InputTypePress) {
state->press[4] = true;
state.press[4] = true;
} else if(event.type == InputTypeRelease) {
state->press[4] = false;
state.press[4] = false;
} else if(event.type == InputTypeShort) {
++state->ok;
++state.ok;
}
} else if(event.key == InputKeyBack) {
if(event.type == InputTypeLong) {
release_mutex(&state_mutex, state);
furi_mutex_release(state.mutex);
break;
} else if(event.type == InputTypeShort) {
keypad_test_reset_state(state);
keypad_test_reset_state(&state);
}
}

release_mutex(&state_mutex, state);
furi_mutex_release(state.mutex);
view_port_update(view_port);
}

// remove & free all stuff created by app
gui_remove_view_port(gui, view_port);
view_port_free(view_port);
furi_message_queue_free(event_queue);
delete_mutex(&state_mutex);
furi_mutex_free(state.mutex);

furi_record_close(RECORD_GUI);

Expand Down
30 changes: 16 additions & 14 deletions applications/debug/text_box_test/text_box_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ static void (*text_box_test_render[])(Canvas* canvas) = {

typedef struct {
uint32_t idx;
FuriMutex* mutex;
} TextBoxTestState;

static void text_box_test_render_callback(Canvas* canvas, void* ctx) {
TextBoxTestState* state = acquire_mutex((ValueMutex*)ctx, 25);
TextBoxTestState* state = ctx;
furi_mutex_acquire(state->mutex, FuriWaitForever);
canvas_clear(canvas);

text_box_test_render[state->idx](canvas);

release_mutex((ValueMutex*)ctx, state);
furi_mutex_release(state->mutex);
}

static void text_box_test_input_callback(InputEvent* input_event, void* ctx) {
Expand All @@ -74,17 +76,17 @@ int32_t text_box_test_app(void* p) {
FuriMessageQueue* event_queue = furi_message_queue_alloc(32, sizeof(InputEvent));
furi_check(event_queue);

TextBoxTestState _state = {.idx = 0};
TextBoxTestState state = {.idx = 0, .mutex = NULL};
state.mutex = furi_mutex_alloc(FuriMutexTypeNormal);

ValueMutex state_mutex;
if(!init_mutex(&state_mutex, &_state, sizeof(TextBoxTestState))) {
if(!state.mutex) {
FURI_LOG_E(TAG, "Cannot create mutex");
return 0;
}

ViewPort* view_port = view_port_alloc();

view_port_draw_callback_set(view_port, text_box_test_render_callback, &state_mutex);
view_port_draw_callback_set(view_port, text_box_test_render_callback, &state);
view_port_input_callback_set(view_port, text_box_test_input_callback, event_queue);

// Open GUI and register view_port
Expand All @@ -94,32 +96,32 @@ int32_t text_box_test_app(void* p) {
uint32_t test_renders_num = COUNT_OF(text_box_test_render);
InputEvent event;
while(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk) {
TextBoxTestState* state = acquire_mutex_block(&state_mutex);
furi_mutex_acquire(state.mutex, FuriWaitForever);

if(event.type == InputTypeShort) {
if(event.key == InputKeyRight) {
if(state->idx < test_renders_num - 1) {
state->idx++;
if(state.idx < test_renders_num - 1) {
state.idx++;
}
} else if(event.key == InputKeyLeft) {
if(state->idx > 0) {
state->idx--;
if(state.idx > 0) {
state.idx--;
}
} else if(event.key == InputKeyBack) {
release_mutex(&state_mutex, state);
furi_mutex_release(state.mutex);
break;
}
}

release_mutex(&state_mutex, state);
furi_mutex_release(state.mutex);
view_port_update(view_port);
}

// remove & free all stuff created by app
gui_remove_view_port(gui, view_port);
view_port_free(view_port);
furi_message_queue_free(event_queue);
delete_mutex(&state_mutex);
furi_mutex_free(state.mutex);

furi_record_close(RECORD_GUI);

Expand Down
6 changes: 0 additions & 6 deletions applications/debug/unit_tests/furi/furi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

// v2 tests
void test_furi_create_open();
void test_furi_valuemutex();
void test_furi_concurrent_access();
void test_furi_pubsub();

Expand All @@ -30,10 +29,6 @@ MU_TEST(mu_test_furi_create_open) {
test_furi_create_open();
}

MU_TEST(mu_test_furi_valuemutex) {
test_furi_valuemutex();
}

MU_TEST(mu_test_furi_pubsub) {
test_furi_pubsub();
}
Expand All @@ -51,7 +46,6 @@ MU_TEST_SUITE(test_suite) {

// v2 tests
MU_RUN_TEST(mu_test_furi_create_open);
MU_RUN_TEST(mu_test_furi_valuemutex);
MU_RUN_TEST(mu_test_furi_pubsub);
MU_RUN_TEST(mu_test_furi_memmgr);
}
Expand Down
41 changes: 0 additions & 41 deletions applications/debug/unit_tests/furi/furi_valuemutex_test.c

This file was deleted.

9 changes: 4 additions & 5 deletions applications/debug/unit_tests/rpc/rpc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static void clean_directory(Storage* fs_api, const char* clean_dir) {
size_t size = strlen(clean_dir) + strlen(name) + 1 + 1;
char* fullname = malloc(size);
snprintf(fullname, size, "%s/%s", clean_dir, name);
if(fileinfo.flags & FSF_DIRECTORY) {
if(file_info_is_dir(&fileinfo)) {
clean_directory(fs_api, fullname);
}
FS_Error error = storage_common_remove(fs_api, fullname);
Expand Down Expand Up @@ -608,9 +608,8 @@ static void test_rpc_storage_list_create_expected_list(
}

if(path_contains_only_ascii(name)) {
list->file[i].type = (fileinfo.flags & FSF_DIRECTORY) ?
PB_Storage_File_FileType_DIR :
PB_Storage_File_FileType_FILE;
list->file[i].type = file_info_is_dir(&fileinfo) ? PB_Storage_File_FileType_DIR :
PB_Storage_File_FileType_FILE;
list->file[i].size = fileinfo.size;
list->file[i].data = NULL;
/* memory free inside rpc_encode_and_send() -> pb_release() */
Expand Down Expand Up @@ -873,7 +872,7 @@ static void test_rpc_storage_stat_run(const char* path, uint32_t command_id) {
if(error == FSE_OK) {
response->which_content = PB_Main_storage_stat_response_tag;
response->content.storage_stat_response.has_file = true;
response->content.storage_stat_response.file.type = (fileinfo.flags & FSF_DIRECTORY) ?
response->content.storage_stat_response.file.type = file_info_is_dir(&fileinfo) ?
PB_Storage_File_FileType_DIR :
PB_Storage_File_FileType_FILE;
response->content.storage_stat_response.file.size = fileinfo.size;
Expand Down
8 changes: 4 additions & 4 deletions applications/debug/unit_tests/storage/dirwalk_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ MU_TEST_1(test_dirwalk_full, Storage* storage) {

while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
mu_check(storage_test_paths_mark(paths, path, file_info_is_dir(&fileinfo)));
}

dir_walk_free(dir_walk);
Expand All @@ -204,7 +204,7 @@ MU_TEST_1(test_dirwalk_no_recursive, Storage* storage) {

while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
mu_check(storage_test_paths_mark(paths, path, file_info_is_dir(&fileinfo)));
}

dir_walk_free(dir_walk);
Expand All @@ -219,7 +219,7 @@ static bool test_dirwalk_filter_no_folder_ext(const char* name, FileInfo* filein
UNUSED(ctx);

// only files
if(!(fileinfo->flags & FSF_DIRECTORY)) {
if(!file_info_is_dir(fileinfo)) {
// with ".test" in name
if(strstr(name, ".test") != NULL) {
return true;
Expand All @@ -243,7 +243,7 @@ MU_TEST_1(test_dirwalk_filter, Storage* storage) {

while(dir_walk_read(dir_walk, path, &fileinfo) == DirWalkOK) {
furi_string_right(path, strlen(EXT_PATH("dirwalk/")));
mu_check(storage_test_paths_mark(paths, path, (fileinfo.flags & FSF_DIRECTORY)));
mu_check(storage_test_paths_mark(paths, path, file_info_is_dir(&fileinfo)));
}

dir_walk_free(dir_walk);
Expand Down
Loading

0 comments on commit dec00fe

Please sign in to comment.