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

Update application.fam and FlipperHTTP

jblanked 1 год назад
Родитель
Сommit
cef5af0b1a
3 измененных файлов с 19 добавлено и 9 удалено
  1. BIN
      .DS_Store
  2. 4 5
      application.fam
  3. 15 4
      flipper_http.h

+ 4 - 5
application.fam

@@ -1,15 +1,14 @@
 App(
     appid="flip_social",
-    name="Flip Social",
+    name="FlipSocial",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="main_flip_social",
     stack_size=4 * 1024,
-    requires=[
-        "gui",
-    ],
-    order=10,
     fap_icon="app.png",
     fap_category="GPIO",
     fap_icon_assets="assets",
+    fap_author="jblanked",
+    fap_weburl="https://github.com/jblanked/FlipSocial",
+    fap_version="0.1",
     fap_description="Social media platform for the Flipper Zero.",
 )

+ 15 - 4
flipper_http.h

@@ -15,7 +15,8 @@
 #define UART_CH (FuriHalSerialIdUsart)    // UART channel
 #define TIMEOUT_DURATION_TICKS (2 * 1000) // 2 seconds
 #define BAUDRATE (115200)                 // UART baudrate
-#define RX_BUF_SIZE 1024                  // UART RX buffer size
+#define RX_BUF_SIZE 128                   // UART RX buffer size
+#define RX_LINE_BUFFER_SIZE 2048          // UART RX line buffer size (increase for large responses)
 
 // Forward declaration for callback
 typedef void (*FlipperHTTP_Callback)(const char *line, void *context);
@@ -161,7 +162,14 @@ static int32_t flipper_http_worker(void *context)
 {
     UNUSED(context);
     size_t rx_line_pos = 0;
-    char rx_line_buffer[256]; // Buffer to collect a line
+    char *rx_line_buffer = (char *)malloc(RX_LINE_BUFFER_SIZE);
+
+    if (!rx_line_buffer)
+    {
+        // Handle malloc failure
+        FURI_LOG_E(HTTP_TAG, "Failed to allocate memory for rx_line_buffer");
+        return -1;
+    }
 
     while (1)
     {
@@ -170,11 +178,11 @@ static int32_t flipper_http_worker(void *context)
             break;
         if (events & WorkerEvtRxDone)
         {
-            size_t len = furi_stream_buffer_receive(fhttp.flipper_http_stream, fhttp.rx_buf, RX_BUF_SIZE * 10, 0);
+            size_t len = furi_stream_buffer_receive(fhttp.flipper_http_stream, fhttp.rx_buf, RX_BUF_SIZE, 0);
             for (size_t i = 0; i < len; i++)
             {
                 char c = fhttp.rx_buf[i];
-                if (c == '\n' || rx_line_pos >= sizeof(rx_line_buffer) - 1)
+                if (c == '\n' || rx_line_pos >= RX_LINE_BUFFER_SIZE - 1)
                 {
                     rx_line_buffer[rx_line_pos] = '\0';
                     // Invoke the callback with the complete line
@@ -193,6 +201,9 @@ static int32_t flipper_http_worker(void *context)
         }
     }
 
+    // Free the allocated memory before exiting the thread
+    free(rx_line_buffer);
+
     return 0;
 }