Merge pull request #57 from Hoggormino/unknown-tag-guards

Guard unknown-profile targets and a full target list
This commit is contained in:
I12BP8
2026-09-17 17:14:15 +02:00
committed by GitHub
4 changed files with 53 additions and 5 deletions
+23 -4
View File
@@ -6,7 +6,8 @@
static void unsupported_tag_back_cb(GuiButtonType type, InputType input_type, void* ctx) {
UNUSED(type);
UNUSED(input_type);
/* Widget buttons report press, short and release alike; act once. */
if(input_type != InputTypeShort) return;
TagTinkerApp* app = ctx;
scene_manager_previous_scene(app->scene_manager);
}
@@ -60,12 +61,30 @@ bool tagtinker_scene_barcode_input_on_event(void* ctx, SceneManagerEvent event)
app->selected_target = tagtinker_ensure_target(app, app->barcode);
int8_t idx = tagtinker_ensure_target(app, app->barcode);
if(app->selected_target >= 0) {
tagtinker_select_target(app, (uint8_t)app->selected_target);
if(idx < 0) {
/* The barcode already passed validation, so the only way left to fail
* is a full target list. Do not open the target actions with index -1. */
widget_reset(app->widget);
widget_add_string_element(
app->widget, 64, 10, AlignCenter, AlignTop, FontPrimary, "Target List Full");
widget_add_string_multiline_element(
app->widget,
64,
30,
AlignCenter,
AlignTop,
FontSecondary,
"Delete a saved tag\nto add a new one.");
widget_add_button_element(
app->widget, GuiButtonTypeLeft, "Back", unsupported_tag_back_cb, app);
view_dispatcher_switch_to_view(app->view_dispatcher, TagTinkerViewWidget);
return true;
}
tagtinker_select_target(app, (uint8_t)idx);
uint32_t target_scene = scene_manager_get_scene_state(
app->scene_manager, TagTinkerSceneBarcodeInput);
scene_manager_next_scene(app->scene_manager, target_scene);
+21
View File
@@ -29,6 +29,27 @@ static void show_target_details(TagTinkerApp* app, const TagTinkerTarget* target
text_box_set_focus(app->text_box, TextBoxFocusStart);
static char details_buf[256];
if(!target->profile.known) {
/* No table entry: size and colour are unknown, not 0x0 and Mono. */
snprintf(
details_buf,
sizeof(details_buf),
"--- Tag Info ---\n"
"Model: Unknown\n"
"Type: %u\n"
"Not in the profile table,\n"
"so Set Text, Set Image\n"
"and WiFi Plugins are\n"
"hidden for this tag.\n"
"Barcode:\n%s",
target->profile.type_code,
target->barcode);
text_box_set_text(app->text_box, details_buf);
scene_manager_next_scene(app->scene_manager, TagTinkerSceneTextBox);
return;
}
uint16_t size_w = target->profile.width;
uint16_t size_h = target->profile.height;
tagtinker_profile_glass_size(&target->profile, &size_w, &size_h);
+5
View File
@@ -457,6 +457,11 @@ static bool tx_send_color26_text(TagTinkerApp* app) {
}
static bool tx_stream_text_image(TagTinkerApp* app) {
/* A target without a table profile has no dimensions. Refuse here: both
* text paths below would otherwise call malloc(0), which the firmware
* treats as a fatal error. */
if(app->image_tx_job.width == 0U || app->image_tx_job.height == 0U) return false;
if(tx_is_color26(app)) {
return tx_send_color26_text(app);
}
+4 -1
View File
@@ -289,7 +289,10 @@ bool tagtinker_delete_target(TagTinkerApp* app, uint8_t index) {
bool tagtinker_target_supports_graphics(const TagTinkerTarget* target) {
if(!target) return false;
return target->profile.kind != TagTinkerTagKindSegment;
/* Only profile-table entries have real dimensions. A type code missing
* from the table leaves a zeroed profile (0x0, kind Unknown), so the app
* has no known display size to render text or images for. */
return target->profile.known && target->profile.kind == TagTinkerTagKindDotMatrix;
}
bool tagtinker_target_supports_accent(const TagTinkerTarget* target) {