jblanked 1 год назад
Родитель
Сommit
e1df34ca57
6 измененных файлов с 9 добавлено и 11 удалено
  1. BIN
      .DS_Store
  2. 5 5
      app.c
  3. 1 1
      application.fam
  4. 1 3
      flip_weather_callback.h
  5. 1 1
      flip_weather_i.h
  6. 1 1
      flipper_http.h

+ 5 - 5
app.c

@@ -13,16 +13,16 @@ int32_t flip_weather_app(void *p)
     // Initialize the FlipWeather application
     FlipWeatherApp *app = flip_weather_app_alloc();
 
-    // send settings and connect wifi
-    if (!flipper_http_connect_wifi())
+    if (!flipper_http_ping())
     {
-        FURI_LOG_E(TAG, "Failed to connect to WiFi");
+        FURI_LOG_E(TAG, "Failed to ping the device");
         return -1;
     }
 
-    if (!flipper_http_ping())
+    // connect wifi
+    if (!flipper_http_connect_wifi())
     {
-        FURI_LOG_E(TAG, "Failed to ping the device");
+        FURI_LOG_E(TAG, "Failed to connect to WiFi");
         return -1;
     }
 

+ 1 - 1
application.fam

@@ -10,5 +10,5 @@ App(
     fap_description="Use WiFi to get GPS and Weather information on your Flipper Zero.",
     fap_author="JBlanked",
     fap_weburl="https://github.com/jblanked/FlipWeather",
-    fap_version = "1.0",
+    fap_version = "1.1",
 )

+ 1 - 3
flip_weather_callback.h

@@ -74,9 +74,7 @@ static bool send_geo_location_request()
     if (!sent_get_request && fhttp.state == IDLE)
     {
         sent_get_request = true;
-        char payload[256] = {0};
-        snprintf(payload, 256, "{\"ip\": \"%s\"}", ip_address);
-        get_request_success = flipper_http_post_request_with_headers("https://www.flipsocial.net/api/geo-location/", "{\"Content-Type\": \"application/json\"}", payload);
+        get_request_success = flipper_http_get_request_with_headers("https://ipwhois.app/json/", "{\"Content-Type\": \"application/json\"}");
         if (!get_request_success)
         {
             FURI_LOG_E(TAG, "Failed to send GET request");

+ 1 - 1
flip_weather_i.h

@@ -78,7 +78,7 @@ static FlipWeatherApp *flip_weather_app_alloc()
     variable_item_set_current_value_text(app->variable_item_password, "");
 
     // Submenu
-    if (!easy_flipper_set_submenu(&app->submenu, FlipWeatherViewSubmenu, "FlipWeather v1.0", callback_exit_app, &app->view_dispatcher))
+    if (!easy_flipper_set_submenu(&app->submenu, FlipWeatherViewSubmenu, "FlipWeather v1.1", callback_exit_app, &app->view_dispatcher))
     {
         return NULL;
     }

+ 1 - 1
flipper_http.h

@@ -13,7 +13,7 @@
 #define HTTP_TAG "FlipperHTTP"            // change this to your app name
 #define http_tag "flipper_http"           // change this to your app id
 #define UART_CH (FuriHalSerialIdUsart)    // UART channel
-#define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds
+#define TIMEOUT_DURATION_TICKS (5 * 1000) // 2 seconds
 #define BAUDRATE (115200)                 // UART baudrate
 #define RX_BUF_SIZE 128                   // UART RX buffer size
 #define RX_LINE_BUFFER_SIZE 2048          // UART RX line buffer size (increase for large responses)