jblanked 9 месяцев назад
Родитель
Сommit
c6f48a6cfb
4 измененных файлов с 29 добавлено и 33 удалено
  1. 25 31
      app.c
  2. 1 1
      application.fam
  3. BIN
      assets/flip-social-main-menu.png
  4. 3 1
      flip_social.h

+ 25 - 31
app.c

@@ -22,43 +22,35 @@ int32_t main_flip_social(void *p)
     }
 
     // check if board is connected (Derek Jamison)
-    uint8_t counter = 10;
-    // initialize the http
-    if (flipper_http_init(flipper_http_rx_callback, app_instance))
+    FlipperHTTP *fhttp = flipper_http_alloc();
+    if (!fhttp)
     {
-        fhttp.state = INACTIVE; // set inactive for the ping
-
-        if (!flipper_http_ping())
-        {
-            FURI_LOG_E(TAG, "Failed to ping the device");
-            return -1;
-        }
-
-        // Try to wait for pong response.
-        while (fhttp.state == INACTIVE && --counter > 0)
-        {
-            FURI_LOG_D(TAG, "Waiting for PONG");
-            furi_delay_ms(100);
-        }
-
-        if (counter == 0)
-        {
-            easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
-        }
-        else
-        {
-            save_char("is_connected", "true");
-        }
+        easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
+        return -1;
+    }
 
-        flipper_http_deinit();
+    if (!flipper_http_send_command(fhttp, HTTP_CMD_PING))
+    {
+        FURI_LOG_E(TAG, "Failed to ping the device");
+        flipper_http_free(fhttp);
+        return -1;
     }
-    else
+
+    // Try to wait for pong response.
+    uint32_t counter = 10;
+    while (fhttp->state == INACTIVE && --counter > 0)
     {
-        easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
+        FURI_LOG_D(TAG, "Waiting for PONG");
+        furi_delay_ms(100);
     }
+    // save app version
+    save_char("app_version", VERSION);
 
-    // if counter is not 0, check notifications
-    if (counter != 0)
+    if (counter == 0)
+    {
+        easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
+    }
+    else
     {
         char is_connected[5];
         char is_logged_in[5];
@@ -75,6 +67,8 @@ int32_t main_flip_social(void *p)
         }
     }
 
+    flipper_http_free(fhttp);
+
     // Run the view dispatcher
     view_dispatcher_run(app_instance->view_dispatcher);
 

+ 1 - 1
application.fam

@@ -9,6 +9,6 @@ App(
     fap_icon_assets="assets",
     fap_author="JBlanked",
     fap_weburl="https://github.com/jblanked/FlipSocial",
-    fap_version="1.0.4",
+    fap_version="1.1",
     fap_description="Social media platform for the Flipper Zero.",
 )

BIN
assets/flip-social-main-menu.png


+ 3 - 1
flip_social.h

@@ -10,7 +10,8 @@
 #include <font/font.h>
 
 #define TAG "FlipSocial"
-#define VERSION_TAG TAG " v1.0.4"
+#define VERSION "1.1"
+#define VERSION_TAG TAG " v" VERSION
 
 #define MAX_PRE_SAVED_MESSAGES 20 // Maximum number of pre-saved messages
 #define MAX_MESSAGE_LENGTH 100    // Maximum length of a message in the feed
@@ -175,6 +176,7 @@ typedef enum
 // Define the application structure
 typedef struct
 {
+    FlipperHTTP *fhttp; // The HTTP client
     View *view_loader;
     Widget *widget_result;
     //