Просмотр исходного кода

Fix API world loading

- we may need to increase the RX_LINE_BUFFER_SIZE again if the data is too big. alternatively, we can write as bytes and have the API send the data as a .json file
jblanked 1 год назад
Родитель
Сommit
139a8c37c5
2 измененных файлов с 13 добавлено и 1 удалено
  1. 1 1
      flipper_http/flipper_http.h
  2. 12 0
      game/world.c

+ 1 - 1
flipper_http/flipper_http.h

@@ -23,7 +23,7 @@
 #define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds
 #define BAUDRATE (115200)                 // UART baudrate
 #define RX_BUF_SIZE 2048                  // UART RX buffer size
-#define RX_LINE_BUFFER_SIZE 2048          // UART RX line buffer size (increase for large responses)
+#define RX_LINE_BUFFER_SIZE 4096          // UART RX line buffer size (increase for large responses)
 #define MAX_FILE_SHOW 3000                // Maximum data from file to show
 #define FILE_BUFFER_SIZE 512              // File buffer size
 

+ 12 - 0
game/world.c

@@ -25,6 +25,16 @@ bool draw_json_world(Level *level, const char *json_data)
         char *horizontal = get_json_value("horizontal", data);
         if (icon == NULL || x == NULL || y == NULL || width == NULL || height == NULL || amount == NULL || horizontal == NULL)
         {
+            FURI_LOG_E("Failed Data: ", data);
+            free(data);
+            free(icon);
+            free(x);
+            free(y);
+            free(width);
+            free(height);
+            free(amount);
+            free(horizontal);
+            level_clear(level);
             return false;
         }
         // if amount is less than 2, we spawn a single icon
@@ -71,6 +81,7 @@ bool draw_json_world_furi(Level *level, FuriString *json_data)
         FuriString *horizontal = get_json_value_furi("horizontal", data);
         if (!icon || !x || !y || !width || !height || !amount || !horizontal)
         {
+            FURI_LOG_E("Failed Data: ", furi_string_get_cstr(data));
             furi_string_free(data);
             furi_string_free(icon);
             furi_string_free(x);
@@ -79,6 +90,7 @@ bool draw_json_world_furi(Level *level, FuriString *json_data)
             furi_string_free(height);
             furi_string_free(amount);
             furi_string_free(horizontal);
+            level_clear(level);
             return false;
         }
         // if amount is less than 2, we spawn a single icon