mirror of
https://github.com/bettse/seader.git
synced 2026-10-29 20:43:23 +00:00
worker: build virtual credential loop policy
This commit is contained in:
8 files changed
+34
-25
No files matched your search
@@ -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 \
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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) {
|
||||
|
||||
+3
-3
@@ -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 <flipper_format/flipper_format.h>
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.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);
|
||||
Reference in new issue
Block a user