Fix SNMP probe transport corruption and label status

This commit is contained in:
CinderSocket
2026-03-27 18:45:55 -07:00
parent e8a71b7daf
commit a137384142
11 changed files with 265 additions and 31 deletions

View File

@@ -6,12 +6,13 @@ static MunitResult test_formats_no_sam(const MunitParameter params[], void* fixt
(void)fixture;
char label[SEADER_SAM_KEY_LABEL_MAX_LEN] = {0};
seader_sam_key_label_format(false, NULL, 0U, label, sizeof(label));
seader_sam_key_label_format(
false, SeaderSamKeyProbeStatusUnknown, NULL, 0U, label, sizeof(label));
munit_assert_string_equal(label, "NO SAM");
return MUNIT_OK;
}
static MunitResult test_formats_standard_key_for_missing_value(
static MunitResult test_formats_unknown_for_missing_value(
const MunitParameter params[],
void* fixture) {
(void)params;
@@ -19,15 +20,17 @@ static MunitResult test_formats_standard_key_for_missing_value(
char label[SEADER_SAM_KEY_LABEL_MAX_LEN] = {0};
const uint8_t zeros[] = {0x00, 0x00, 0x00};
seader_sam_key_label_format(true, NULL, 0U, label, sizeof(label));
munit_assert_string_equal(label, "SAM: Standard Key");
seader_sam_key_label_format(
true, SeaderSamKeyProbeStatusUnknown, NULL, 0U, label, sizeof(label));
munit_assert_string_equal(label, "SAM: Key Unknown");
seader_sam_key_label_format(true, zeros, sizeof(zeros), label, sizeof(label));
munit_assert_string_equal(label, "SAM: Standard Key");
seader_sam_key_label_format(
true, SeaderSamKeyProbeStatusUnknown, zeros, sizeof(zeros), label, sizeof(label));
munit_assert_string_equal(label, "SAM: Key Unknown");
return MUNIT_OK;
}
static MunitResult test_formats_standard_key_for_eight_zero_bytes(
static MunitResult test_formats_standard_key_for_successful_zero_value(
const MunitParameter params[],
void* fixture) {
(void)params;
@@ -35,18 +38,49 @@ static MunitResult test_formats_standard_key_for_eight_zero_bytes(
char label[SEADER_SAM_KEY_LABEL_MAX_LEN] = {0};
const uint8_t zero64[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
seader_sam_key_label_format(true, zero64, sizeof(zero64), label, sizeof(label));
seader_sam_key_label_format(
true,
SeaderSamKeyProbeStatusVerifiedStandard,
zero64,
sizeof(zero64),
label,
sizeof(label));
munit_assert_string_equal(label, "SAM: Standard Key");
return MUNIT_OK;
}
static MunitResult test_probe_failure_never_formats_standard(
const MunitParameter params[],
void* fixture) {
(void)params;
(void)fixture;
char label[SEADER_SAM_KEY_LABEL_MAX_LEN] = {0};
const uint8_t zero64[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
seader_sam_key_label_format(
true, SeaderSamKeyProbeStatusProbeFailed, NULL, 0U, label, sizeof(label));
munit_assert_string_equal(label, "SAM: Probe Failed");
seader_sam_key_label_format(
true,
SeaderSamKeyProbeStatusProbeFailed,
zero64,
sizeof(zero64),
label,
sizeof(label));
munit_assert_string_equal(label, "SAM: Probe Failed");
return MUNIT_OK;
}
static MunitResult test_formats_ascii_ice_value(const MunitParameter params[], void* fixture) {
(void)params;
(void)fixture;
char label[SEADER_SAM_KEY_LABEL_MAX_LEN] = {0};
const uint8_t ice[] = {'I', 'C', 'E', '1', '8', '0', '3'};
seader_sam_key_label_format(true, ice, sizeof(ice), label, sizeof(label));
seader_sam_key_label_format(
true, SeaderSamKeyProbeStatusVerifiedValue, ice, sizeof(ice), label, sizeof(label));
munit_assert_string_equal(label, "SAM: ICE1803");
return MUNIT_OK;
}
@@ -57,15 +91,17 @@ static MunitResult test_sanitizes_non_printable_bytes(const MunitParameter param
char label[SEADER_SAM_KEY_LABEL_MAX_LEN] = {0};
const uint8_t mixed[] = {'A', 0x00, 0x1F, 'Z'};
seader_sam_key_label_format(true, mixed, sizeof(mixed), label, sizeof(label));
seader_sam_key_label_format(
true, SeaderSamKeyProbeStatusVerifiedValue, mixed, sizeof(mixed), label, sizeof(label));
munit_assert_string_equal(label, "SAM: A??Z");
return MUNIT_OK;
}
static MunitTest test_sam_key_label_cases[] = {
{(char*)"/no-sam", test_formats_no_sam, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/standard-key", test_formats_standard_key_for_missing_value, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/standard-key-zero64", test_formats_standard_key_for_eight_zero_bytes, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/unknown", test_formats_unknown_for_missing_value, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/standard-key-zero64", test_formats_standard_key_for_successful_zero_value, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/probe-failed", test_probe_failure_never_formats_standard, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/ascii", test_formats_ascii_ice_value, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/sanitize", test_sanitizes_non_printable_bytes, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{NULL, NULL, NULL, NULL, 0, NULL},

View File

@@ -205,7 +205,7 @@ static MunitResult test_probe_full_sequence_succeeds_with_runtime_sized_buffers(
(void)fixture;
SeaderUhfSnmpProbe probe = {0};
uint8_t message[272] = {0};
uint8_t message[176] = {0};
uint8_t scratch[240] = {0};
uint8_t response[512] = {0};
size_t message_len = 0U;
@@ -252,6 +252,39 @@ static MunitResult test_probe_full_sequence_succeeds_with_runtime_sized_buffers(
return MUNIT_OK;
}
static MunitResult test_get_data_request_fits_bounded_transport_buffer(
const MunitParameter params[],
void* fixture) {
(void)params;
(void)fixture;
uint8_t engine[SEADER_UHF_SNMP_MAX_ID_LEN];
uint8_t username[SEADER_UHF_SNMP_MAX_ID_LEN];
uint8_t scratch[240] = {0};
uint8_t message[176] = {0};
size_t message_len = 0U;
memset(engine, 0xAA, sizeof(engine));
memset(username, 0xBB, sizeof(username));
munit_assert_true(seader_snmp_build_get_data_request(
engine,
sizeof(engine),
username,
sizeof(username),
UINT32_MAX,
UINT32_MAX,
oid_monza4qt_access_key,
sizeof(oid_monza4qt_access_key),
scratch,
sizeof(scratch),
message,
sizeof(message),
&message_len));
munit_assert_size(message_len, <=, sizeof(message));
return MUNIT_OK;
}
static MunitResult test_tag_config_view_extracts_known_entries(const MunitParameter params[], void* fixture) {
(void)params;
(void)fixture;
@@ -295,6 +328,7 @@ static MunitTest test_snmp_cases[] = {
{(char*)"/parse-values", test_parse_ice_and_tag_config_values, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/probe", test_probe_stages, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/probe-runtime-buffers", test_probe_full_sequence_succeeds_with_runtime_sized_buffers, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/bounded-get-data", test_get_data_request_fits_bounded_transport_buffer, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/tag-config", test_tag_config_view_extracts_known_entries, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/malformed-length", test_response_rejects_truncated_length, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{NULL, NULL, NULL, NULL, 0, NULL},

View File

@@ -7,16 +7,35 @@ static MunitResult test_formats_none(const MunitParameter params[], void* fixtur
(void)params;
(void)fixture;
char label[SEADER_UHF_STATUS_LABEL_MAX_LEN] = {0};
seader_uhf_status_label_format(false, false, false, false, label, sizeof(label));
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, false, false, false, false, label, sizeof(label));
munit_assert_string_equal(label, "UHF: none");
return MUNIT_OK;
}
static MunitResult test_formats_probing_and_failed_states(
const MunitParameter params[],
void* fixture) {
(void)params;
(void)fixture;
char label[SEADER_UHF_STATUS_LABEL_MAX_LEN] = {0};
seader_uhf_status_label_format(
SeaderUhfProbeStatusUnknown, false, false, false, false, label, sizeof(label));
munit_assert_string_equal(label, "UHF: probing...");
seader_uhf_status_label_format(
SeaderUhfProbeStatusFailed, true, true, true, true, label, sizeof(label));
munit_assert_string_equal(label, "UHF: probe failed");
return MUNIT_OK;
}
static MunitResult test_formats_supported_key_states(const MunitParameter params[], void* fixture) {
(void)params;
(void)fixture;
char label[SEADER_UHF_STATUS_LABEL_MAX_LEN] = {0};
seader_uhf_status_label_format(true, false, true, true, label, sizeof(label));
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, true, false, true, true, label, sizeof(label));
munit_assert_string_equal(label, "UHF: Monza 4QT [no key]/Higgs 3");
return MUNIT_OK;
}
@@ -28,7 +47,8 @@ static MunitResult test_longest_supported_label_fits_buffer(
(void)fixture;
char label[SEADER_UHF_STATUS_LABEL_MAX_LEN] = {0};
seader_uhf_status_label_format(true, false, true, false, label, sizeof(label));
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, true, false, true, false, label, sizeof(label));
munit_assert_string_equal(label, "UHF: Monza 4QT [no key]/Higgs 3 [no key]");
munit_assert_size(strlen(label), <, sizeof(label));
return MUNIT_OK;
@@ -40,10 +60,12 @@ static MunitResult test_handles_null_and_zero_sized_output(
(void)params;
(void)fixture;
seader_uhf_status_label_format(true, true, false, false, NULL, 0U);
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, true, true, false, false, NULL, 0U);
char label[4] = {'X', 'Y', 'Z', 'W'};
seader_uhf_status_label_format(true, true, false, false, label, 0U);
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, true, true, false, false, label, 0U);
munit_assert_memory_equal(sizeof(label), label, ((char[]){'X', 'Y', 'Z', 'W'}));
return MUNIT_OK;
}
@@ -55,7 +77,8 @@ static MunitResult test_nul_terminates_single_byte_output(
(void)fixture;
char label[1] = {'X'};
seader_uhf_status_label_format(true, false, true, false, label, sizeof(label));
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, true, false, true, false, label, sizeof(label));
munit_assert_char(label[0], ==, '\0');
return MUNIT_OK;
}
@@ -68,7 +91,8 @@ static MunitResult test_truncates_safely_for_small_buffers(
char label[8];
memset(label, 'Z', sizeof(label));
seader_uhf_status_label_format(true, false, true, false, label, sizeof(label));
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, true, false, true, false, label, sizeof(label));
munit_assert_char(label[sizeof(label) - 1], ==, '\0');
munit_assert_char(label[0], ==, 'U');
@@ -82,7 +106,8 @@ static MunitResult test_small_buffer_for_none_is_safe(const MunitParameter param
char label[4];
memset(label, 'Q', sizeof(label));
seader_uhf_status_label_format(false, false, false, false, label, sizeof(label));
seader_uhf_status_label_format(
SeaderUhfProbeStatusSuccess, false, false, false, false, label, sizeof(label));
munit_assert_char(label[sizeof(label) - 1], ==, '\0');
munit_assert_char(label[0], ==, 'U');
@@ -91,6 +116,7 @@ static MunitResult test_small_buffer_for_none_is_safe(const MunitParameter param
static MunitTest test_uhf_status_label_cases[] = {
{(char*)"/none", test_formats_none, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/probing-failed", test_formats_probing_and_failed_states, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/supported-key-states", test_formats_supported_key_states, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/longest-fits", test_longest_supported_label_fits_buffer, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},
{(char*)"/null-zero-output", test_handles_null_and_zero_sized_output, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL},

View File

@@ -18,6 +18,7 @@
#define ASN1_PREFIX 6
#define SEADER_ICLASS_SR_SIO_BASE_BLOCK 10
#define SEADER_SERIAL_FILE_NAME "sam_serial"
#define SEADER_SNMP_MAX_REQUEST_SIZE 176U
const uint8_t picopass_iclass_key[] = {0xaf, 0xa7, 0x85, 0xa7, 0xda, 0xb3, 0x33, 0x78};
const uint8_t seader_oid[] =
@@ -43,6 +44,7 @@ static void seader_update_sam_key_label(Seader* seader, const uint8_t* value, si
seader_sam_key_label_format(
seader->sam_present,
seader->sam_key_probe_status,
value,
value_len,
seader->sam_key_label,
@@ -56,6 +58,7 @@ static void seader_update_uhf_status_label(Seader* seader) {
}
seader_uhf_status_label_format(
seader->uhf_probe_status,
seader->snmp_probe.has_monza4qt,
seader->snmp_probe.monza4qt_key_present,
seader->snmp_probe.has_higgs3,
@@ -69,6 +72,20 @@ static SeaderWorker* seader_get_active_worker(Seader* seader) {
return seader ? seader->worker : NULL;
}
static bool seader_ice_value_is_standard(const uint8_t* value, size_t value_len) {
if(!value || value_len == 0U) {
return false;
}
for(size_t i = 0; i < value_len; i++) {
if(value[i] != 0x00U) {
return false;
}
}
return true;
}
static SeaderUartBridge* seader_require_uart(Seader* seader) {
furi_check(seader);
furi_check(seader->uart);
@@ -88,6 +105,9 @@ static void seader_reset_cached_sam_metadata(Seader* seader) {
return;
}
seader->sam_key_probe_status = SeaderSamKeyProbeStatusUnknown;
seader->uhf_probe_status = SeaderUhfProbeStatusUnknown;
seader_runtime_reset_cached_sam_metadata(
seader->sam_version,
seader->uhf_status_label,
@@ -97,16 +117,16 @@ static void seader_reset_cached_sam_metadata(Seader* seader) {
static bool seader_snmp_probe_send_next_request(Seader* seader) {
SeaderUartBridge* seader_uart = seader_require_uart(seader);
uint8_t scratch[SEADER_UART_RX_BUF_SIZE - MAX_FRAME_HEADERS] = {0};
uint8_t* message = seader_uart->tx_buf;
uint8_t* scratch = seader_uart->tx_buf + MAX_FRAME_HEADERS;
uint8_t message[SEADER_SNMP_MAX_REQUEST_SIZE] = {0};
size_t message_len = 0U;
if(!seader_uhf_snmp_probe_build_next_request(
&seader->snmp_probe,
scratch,
sizeof(scratch),
SEADER_UART_RX_BUF_SIZE - MAX_FRAME_HEADERS,
message,
SEADER_UART_RX_BUF_SIZE,
sizeof(message),
&message_len)) {
return false;
}
@@ -140,6 +160,9 @@ static void seader_start_snmp_probe(Seader* seader) {
seader_snmp_probe_finish(seader);
return;
}
seader->sam_key_probe_status = SeaderSamKeyProbeStatusUnknown;
seader->uhf_probe_status = SeaderUhfProbeStatusUnknown;
seader_update_sam_key_label(seader, NULL, 0U);
seader_update_uhf_status_label(seader);
seader_sam_set_state(
seader,
@@ -148,6 +171,10 @@ static void seader_start_snmp_probe(Seader* seader) {
SamCommand_PR_processSNMPMessage);
if(!seader_snmp_probe_send_next_request(seader)) {
seader->sam_key_probe_status = SeaderSamKeyProbeStatusProbeFailed;
seader->uhf_probe_status = SeaderUhfProbeStatusFailed;
seader_update_sam_key_label(seader, NULL, 0U);
seader_update_uhf_status_label(seader);
seader_snmp_probe_finish(seader);
}
}
@@ -692,6 +719,7 @@ void seader_worker_send_version(Seader* seader) {
samCommand.present = SamCommand_PR_version;
seader_reset_cached_sam_metadata(seader);
seader->sam_present = true;
seader->sam_key_probe_status = SeaderSamKeyProbeStatusUnknown;
seader_update_sam_key_label(seader, NULL, 0U);
seader_sam_set_state(
seader, SeaderSamStateVersionPending, SeaderSamIntentMaintenance, samCommand.present);
@@ -1085,12 +1113,24 @@ bool seader_parse_sam_response(Seader* seader, SamResponse_t* samResponse) {
FURI_LOG_I(TAG, "samResponse processSNMPMessage");
if(!seader_uhf_snmp_probe_consume_response(
&seader->snmp_probe, samResponse->buf, samResponse->size)) {
seader->sam_key_probe_status = SeaderSamKeyProbeStatusProbeFailed;
seader->uhf_probe_status = SeaderUhfProbeStatusFailed;
seader_update_sam_key_label(seader, NULL, 0U);
seader_update_uhf_status_label(seader);
seader_snmp_probe_finish(seader);
break;
}
if(seader->snmp_probe.ice_value_len > 0U) {
seader->sam_key_probe_status =
seader_ice_value_is_standard(
seader->snmp_probe.ice_value_storage, seader->snmp_probe.ice_value_len) ?
SeaderSamKeyProbeStatusVerifiedStandard :
SeaderSamKeyProbeStatusVerifiedValue;
}
if(seader->snmp_probe.stage >= SeaderUhfSnmpProbeStageReadTagConfig) {
seader->uhf_probe_status = SeaderUhfProbeStatusSuccess;
seader_update_sam_key_label(
seader, seader->snmp_probe.ice_value_storage, seader->snmp_probe.ice_value_len);
seader_update_uhf_status_label(seader);
@@ -1101,6 +1141,10 @@ bool seader_parse_sam_response(Seader* seader, SamResponse_t* samResponse) {
} else if(
seader->snmp_probe.stage == SeaderUhfSnmpProbeStageFailed ||
!seader_snmp_probe_send_next_request(seader)) {
seader->sam_key_probe_status = SeaderSamKeyProbeStatusProbeFailed;
seader->uhf_probe_status = SeaderUhfProbeStatusFailed;
seader_update_sam_key_label(seader, NULL, 0U);
seader_update_uhf_status_label(seader);
seader_snmp_probe_finish(seader);
}
break;
@@ -1670,13 +1714,35 @@ bool seader_worker_state_machine(
ErrorResponse_t* err = &payload->choice.errorResponse;
if(seader_uhf_snmp_probe_consume_error(
&seader->snmp_probe, err->errorCode, err->data.buf, err->data.size)) {
if(seader->snmp_probe.ice_value_len > 0U) {
seader->sam_key_probe_status = seader_ice_value_is_standard(
seader->snmp_probe.ice_value_storage,
seader->snmp_probe.ice_value_len) ?
SeaderSamKeyProbeStatusVerifiedStandard :
SeaderSamKeyProbeStatusVerifiedValue;
}
if(seader->snmp_probe.stage >= SeaderUhfSnmpProbeStageReadTagConfig) {
seader->uhf_probe_status = SeaderUhfProbeStatusSuccess;
}
seader_update_sam_key_label(
seader,
seader->snmp_probe.ice_value_storage,
seader->snmp_probe.ice_value_len);
seader_update_uhf_status_label(seader);
if(seader->snmp_probe.stage == SeaderUhfSnmpProbeStageDone) {
seader_snmp_probe_finish(seader);
} else if(!seader_snmp_probe_send_next_request(seader)) {
seader->sam_key_probe_status = SeaderSamKeyProbeStatusProbeFailed;
seader->uhf_probe_status = SeaderUhfProbeStatusFailed;
seader_update_sam_key_label(seader, NULL, 0U);
seader_update_uhf_status_label(seader);
seader_snmp_probe_finish(seader);
}
} else {
seader->sam_key_probe_status = SeaderSamKeyProbeStatusProbeFailed;
seader->uhf_probe_status = SeaderUhfProbeStatusFailed;
seader_update_sam_key_label(seader, NULL, 0U);
seader_update_uhf_status_label(seader);
seader_snmp_probe_finish(seader);
}
} else {

View File

@@ -20,6 +20,7 @@ static bool seader_sam_key_label_is_missing(const uint8_t* value, size_t value_l
void seader_sam_key_label_format(
bool sam_present,
SeaderSamKeyProbeStatus probe_status,
const uint8_t* elite_ice_value,
size_t elite_ice_value_len,
char* out,
@@ -35,11 +36,26 @@ void seader_sam_key_label_format(
return;
}
if(seader_sam_key_label_is_missing(elite_ice_value, elite_ice_value_len)) {
if(probe_status == SeaderSamKeyProbeStatusUnknown) {
snprintf(out, out_size, "SAM: Key Unknown");
return;
}
if(probe_status == SeaderSamKeyProbeStatusProbeFailed) {
snprintf(out, out_size, "SAM: Probe Failed");
return;
}
if(probe_status == SeaderSamKeyProbeStatusVerifiedStandard) {
snprintf(out, out_size, "SAM: Standard Key");
return;
}
if(seader_sam_key_label_is_missing(elite_ice_value, elite_ice_value_len)) {
snprintf(out, out_size, "SAM: Probe Failed");
return;
}
size_t pos = 0U;
pos += (size_t)snprintf(out + pos, out_size - pos, "SAM: ");
if(pos >= out_size) {

View File

@@ -6,8 +6,16 @@
#define SEADER_SAM_KEY_LABEL_MAX_LEN 32U
typedef enum {
SeaderSamKeyProbeStatusUnknown = 0,
SeaderSamKeyProbeStatusVerifiedStandard,
SeaderSamKeyProbeStatusVerifiedValue,
SeaderSamKeyProbeStatusProbeFailed,
} SeaderSamKeyProbeStatus;
void seader_sam_key_label_format(
bool sam_present,
SeaderSamKeyProbeStatus probe_status,
const uint8_t* elite_ice_value,
size_t elite_ice_value_len,
char* out,

View File

@@ -102,7 +102,12 @@ bool seader_scene_start_on_event(void* context, SceneManagerEvent event) {
&seader->board_auto_recover_read_type);
seader->sam_present = false;
seader_sam_key_label_format(
false, NULL, 0U, seader->sam_key_label, sizeof(seader->sam_key_label));
false,
SeaderSamKeyProbeStatusUnknown,
NULL,
0U,
seader->sam_key_label,
sizeof(seader->sam_key_label));
scene_manager_next_scene(seader->scene_manager, SeaderSceneSamMissing);
consumed = true;
} else if(event.event == SeaderWorkerEventSamWrong) {
@@ -113,7 +118,12 @@ bool seader_scene_start_on_event(void* context, SceneManagerEvent event) {
&seader->board_auto_recover_read_type);
seader->sam_present = false;
seader_sam_key_label_format(
false, NULL, 0U, seader->sam_key_label, sizeof(seader->sam_key_label));
false,
SeaderSamKeyProbeStatusUnknown,
NULL,
0U,
seader->sam_key_label,
sizeof(seader->sam_key_label));
scene_manager_next_scene(seader->scene_manager, SeaderSceneSamWrong);
consumed = true;
}

View File

@@ -47,7 +47,12 @@ static void seader_board_prepare_missing_state(Seader* seader, SeaderBoardStatus
seader->board_status = status;
seader->sam_present = false;
seader_sam_key_label_format(
false, NULL, 0U, seader->sam_key_label, sizeof(seader->sam_key_label));
false,
SeaderSamKeyProbeStatusUnknown,
NULL,
0U,
seader->sam_key_label,
sizeof(seader->sam_key_label));
}
static bool seader_board_auto_recover_begin(Seader* seader) {
@@ -815,10 +820,23 @@ Seader* seader_alloc() {
seader->sam_intent = SeaderSamIntentNone;
seader->sam_present = false;
memset(seader->sam_version, 0, sizeof(seader->sam_version));
seader->sam_key_probe_status = SeaderSamKeyProbeStatusUnknown;
seader->uhf_probe_status = SeaderUhfProbeStatusUnknown;
seader_sam_key_label_format(
false, NULL, 0U, seader->sam_key_label, sizeof(seader->sam_key_label));
false,
seader->sam_key_probe_status,
NULL,
0U,
seader->sam_key_label,
sizeof(seader->sam_key_label));
seader_uhf_status_label_format(
false, false, false, false, seader->uhf_status_label, sizeof(seader->uhf_status_label));
seader->uhf_probe_status,
false,
false,
false,
false,
seader->uhf_status_label,
sizeof(seader->uhf_status_label));
seader_uhf_snmp_probe_init(&seader->snmp_probe);
seader->nfc = nfc_alloc();
seader->nfc_device = seader->nfc ? nfc_device_alloc() : NULL;

View File

@@ -166,6 +166,8 @@ struct Seader {
uint8_t sam_version[2];
uint8_t ATR[SEADER_MAX_ATR_SIZE];
size_t ATR_len;
SeaderSamKeyProbeStatus sam_key_probe_status;
SeaderUhfProbeStatus uhf_probe_status;
char sam_key_label[SEADER_SAM_KEY_LABEL_MAX_LEN];
char uhf_status_label[SEADER_UHF_STATUS_LABEL_MAX_LEN];
SeaderUhfSnmpProbe snmp_probe;

View File

@@ -44,6 +44,7 @@ static size_t seader_uhf_append_family(
}
void seader_uhf_status_label_format(
SeaderUhfProbeStatus probe_status,
bool has_monza4qt,
bool monza4qt_key_present,
bool has_higgs3,
@@ -59,6 +60,16 @@ void seader_uhf_status_label_format(
out[0] = '\0';
if(probe_status == SeaderUhfProbeStatusUnknown) {
snprintf(out, out_size, "UHF: probing...");
return;
}
if(probe_status == SeaderUhfProbeStatusFailed) {
snprintf(out, out_size, "UHF: probe failed");
return;
}
if(has_monza4qt) {
pos = seader_uhf_append_family(
out, out_size, pos, &wrote_any, "Monza 4QT", monza4qt_key_present);

View File

@@ -5,7 +5,14 @@
#define SEADER_UHF_STATUS_LABEL_MAX_LEN 48U
typedef enum {
SeaderUhfProbeStatusUnknown = 0,
SeaderUhfProbeStatusSuccess,
SeaderUhfProbeStatusFailed,
} SeaderUhfProbeStatus;
void seader_uhf_status_label_format(
SeaderUhfProbeStatus probe_status,
bool has_monza4qt,
bool monza4qt_key_present,
bool has_higgs3,