|
|
@@ -4,13 +4,16 @@ void wifi_marauder_console_output_handle_rx_data_cb(uint8_t *buf, size_t len, vo
|
|
|
furi_assert(context);
|
|
|
WifiMarauderApp* app = context;
|
|
|
|
|
|
- // Copy buf to string
|
|
|
- char str_buf[RX_BUF_SIZE+1];
|
|
|
- memcpy(str_buf, buf, len);
|
|
|
- str_buf[len] = '\0';
|
|
|
+ // If text box store gets too big, then truncate it
|
|
|
+ app->text_box_store_strlen += len;
|
|
|
+ if (app->text_box_store_strlen >= WIFI_MARAUDER_TEXT_BOX_STORE_SIZE - 1) {
|
|
|
+ string_right(app->text_box_store, app->text_box_store_strlen / 2);
|
|
|
+ app->text_box_store_strlen = string_size(app->text_box_store);
|
|
|
+ }
|
|
|
|
|
|
- // Append string to text box store
|
|
|
- string_cat_printf(app->text_box_store, "%s", str_buf);
|
|
|
+ // Null-terminate buf and append to text box store
|
|
|
+ buf[len] = '\0';
|
|
|
+ string_cat_printf(app->text_box_store, "%s", buf);
|
|
|
|
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventRefreshConsoleOutput);
|
|
|
}
|
|
|
@@ -26,6 +29,7 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
|
|
|
text_box_set_focus(text_box, TextBoxFocusEnd);
|
|
|
}
|
|
|
string_reset(app->text_box_store);
|
|
|
+ app->text_box_store_strlen = 0;
|
|
|
|
|
|
scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneConsoleOutput, 0);
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
|
|
|
@@ -66,4 +70,5 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {
|
|
|
|
|
|
text_box_reset(app->text_box);
|
|
|
string_reset(app->text_box_store);
|
|
|
+ app->text_box_store_strlen = 0;
|
|
|
}
|