From 700275a0c35393f4dafb4cd3e5100b6bf82a1716 Mon Sep 17 00:00:00 2001 From: CinderSocket Date: Wed, 17 Jun 2026 16:11:01 -0700 Subject: [PATCH] worker: build virtual credential loop policy --- Makefile | 1 + lib/host_tests/test_runtime_policy.c | 13 +++++++------ runtime_policy.c | 10 ---------- runtime_policy.h | 6 ------ sam_api.c | 1 + seader_worker.c | 6 +++--- worker_loop_policy.c | 11 +++++++++++ worker_loop_policy.h | 11 +++++++++++ 8 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 worker_loop_policy.c create mode 100644 worker_loop_policy.h diff --git a/Makefile b/Makefile index 7ebf7ed..0f62294 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ test-host: sam_startup_ui.c \ ccid_logic.c \ allocation_policy.c \ + worker_loop_policy.c \ credential_sio_label.c \ t_1_logic.c \ t_1.c \ diff --git a/lib/host_tests/test_runtime_policy.c b/lib/host_tests/test_runtime_policy.c index 980d025..3bd9c9b 100644 --- a/lib/host_tests/test_runtime_policy.c +++ b/lib/host_tests/test_runtime_policy.c @@ -5,6 +5,7 @@ #include "allocation_policy.h" #include "runtime_policy.h" #include "seader_hf_read_plan.h" +#include "worker_loop_policy.h" static MunitResult test_reset_cached_sam_metadata_clears_all_fields( const MunitParameter params[], @@ -284,17 +285,17 @@ static MunitResult test_virtual_credential_loop_terminal_policy( (void)fixture; munit_assert_true( - seader_runtime_virtual_credential_should_continue(true, true, false, false, 1U)); + seader_worker_virtual_credential_should_continue(true, true, false, false, 1U)); munit_assert_false( - seader_runtime_virtual_credential_should_continue(false, true, false, false, 1U)); + seader_worker_virtual_credential_should_continue(false, true, false, false, 1U)); munit_assert_false( - seader_runtime_virtual_credential_should_continue(true, false, false, false, 1U)); + seader_worker_virtual_credential_should_continue(true, false, false, false, 1U)); munit_assert_false( - seader_runtime_virtual_credential_should_continue(true, true, true, false, 1U)); + seader_worker_virtual_credential_should_continue(true, true, true, false, 1U)); munit_assert_false( - seader_runtime_virtual_credential_should_continue(true, true, false, true, 1U)); + seader_worker_virtual_credential_should_continue(true, true, false, true, 1U)); munit_assert_false( - seader_runtime_virtual_credential_should_continue(true, true, false, false, 0U)); + seader_worker_virtual_credential_should_continue(true, true, false, false, 0U)); return MUNIT_OK; } diff --git a/runtime_policy.c b/runtime_policy.c index 345dab2..296a769 100644 --- a/runtime_policy.c +++ b/runtime_policy.c @@ -176,13 +176,3 @@ void seader_runtime_cancel_hf_type_prompt( detected_capacity, detected_type_count); } - -bool seader_runtime_virtual_credential_should_continue( - bool processing_ok, - bool worker_active, - bool stage_complete, - bool stage_fail, - uint8_t empty_loops_remaining) { - return processing_ok && worker_active && !stage_complete && !stage_fail && - empty_loops_remaining > 0U; -} diff --git a/runtime_policy.h b/runtime_policy.h index 8cd1728..b531acb 100644 --- a/runtime_policy.h +++ b/runtime_policy.h @@ -56,9 +56,3 @@ void seader_runtime_cancel_hf_type_prompt( SeaderCredentialType detected_types[], size_t detected_capacity, size_t* detected_type_count); -bool seader_runtime_virtual_credential_should_continue( - bool processing_ok, - bool worker_active, - bool stage_complete, - bool stage_fail, - uint8_t empty_loops_remaining); diff --git a/sam_api.c b/sam_api.c index 65b257e..4d6242a 100644 --- a/sam_api.c +++ b/sam_api.c @@ -40,6 +40,7 @@ static void seader_sam_set_state( SeaderSamState state, SeaderSamIntent intent, SamCommand_PR command); +static void seader_snmp_probe_finish(Seader* seader); static const char* seader_snmp_probe_stage_name(SeaderUhfSnmpProbeStage stage) { switch(stage) { diff --git a/seader_worker.c b/seader_worker.c index aa51d70..df0ce17 100644 --- a/seader_worker.c +++ b/seader_worker.c @@ -2,7 +2,7 @@ #include "seader_hf_read_plan.h" #include "hf_read_lifecycle.h" #include "hf_bridge_policy.h" -#include "runtime_policy.h" +#include "worker_loop_policy.h" #include "trace_log.h" #include @@ -499,7 +499,7 @@ void seader_worker_virtual_credential(Seader* seader) { if(dead_loops > 0U) { dead_loops--; } - running = seader_runtime_virtual_credential_should_continue( + running = seader_worker_virtual_credential_should_continue( processing_ok, seader_worker->state == SeaderWorkerStateVirtualCredential, seader_worker->stage == SeaderPollerEventTypeComplete, @@ -509,7 +509,7 @@ void seader_worker_virtual_credential(Seader* seader) { TAG, "Dead loops: %d -> Running: %s", dead_loops, running ? "true" : "false"); if(running) furi_delay_ms(10); // Don't tight loop if empty } - running = seader_runtime_virtual_credential_should_continue( + running = seader_worker_virtual_credential_should_continue( processing_ok, seader_worker->state == SeaderWorkerStateVirtualCredential, seader_worker->stage == SeaderPollerEventTypeComplete, diff --git a/worker_loop_policy.c b/worker_loop_policy.c new file mode 100644 index 0000000..4ab1b93 --- /dev/null +++ b/worker_loop_policy.c @@ -0,0 +1,11 @@ +#include "worker_loop_policy.h" + +bool seader_worker_virtual_credential_should_continue( + bool processing_ok, + bool worker_active, + bool stage_complete, + bool stage_fail, + uint8_t empty_loops_remaining) { + return processing_ok && worker_active && !stage_complete && !stage_fail && + empty_loops_remaining > 0U; +} diff --git a/worker_loop_policy.h b/worker_loop_policy.h new file mode 100644 index 0000000..7d0424b --- /dev/null +++ b/worker_loop_policy.h @@ -0,0 +1,11 @@ +#pragma once + +#include +#include + +bool seader_worker_virtual_credential_should_continue( + bool processing_ok, + bool worker_active, + bool stage_complete, + bool stage_fail, + uint8_t empty_loops_remaining);