jblanked 1 год назад
Родитель
Сommit
e542ab4f23
4 измененных файлов с 58 добавлено и 0 удалено
  1. 20 0
      assets/FlipperHTTP/flipper_http.h
  2. 9 0
      assets/FlipperHTTP/flipper_http.js
  3. 9 0
      assets/FlipperHTTP/flipper_http.py
  4. 20 0
      flipper_http.h

+ 20 - 0
assets/FlipperHTTP/flipper_http.h

@@ -33,6 +33,7 @@ bool flipper_http_disconnect_wifi();
 bool flipper_http_ping();
 bool flipper_http_ping();
 bool flipper_http_scan_wifi();
 bool flipper_http_scan_wifi();
 bool flipper_http_save_wifi(const char *ssid, const char *password);
 bool flipper_http_save_wifi(const char *ssid, const char *password);
+bool flipper_http_ip_address();
 //---
 //---
 bool flipper_http_list_commands();
 bool flipper_http_list_commands();
 bool flipper_http_led_on();
 bool flipper_http_led_on();
@@ -610,6 +611,25 @@ bool flipper_http_save_wifi(const char *ssid, const char *password)
     return true;
     return true;
 }
 }
 
 
+// Function to get IP address
+/**
+ * @brief      Send a command to get the IP address.
+ * @return     true if the request was successful, false otherwise.
+ * @note       The received data will be handled asynchronously via the callback.
+ */
+bool flipper_http_ip_address()
+{
+    const char *command = "[IP/ADDRESS]";
+    if (!flipper_http_send_data(command))
+    {
+        FURI_LOG_E("FlipperHTTP", "Failed to send IP address command.");
+        return false;
+    }
+
+    // The response will be handled asynchronously via the callback
+    return true;
+}
+
 // Function to disconnect from WiFi (returns true if successful)
 // Function to disconnect from WiFi (returns true if successful)
 /**
 /**
  * @brief      Send a command to disconnect from WiFi.
  * @brief      Send a command to disconnect from WiFi.

+ 9 - 0
assets/FlipperHTTP/flipper_http.js

@@ -152,6 +152,15 @@ let fhttp = {
             return false;
             return false;
         }
         }
     },
     },
+    // get IP address
+    ip_address: function () {
+        serial.write("[IP/ADDRESS]");
+        let response = this.read_data(500);
+        if (response === undefined) {
+            return "";
+        }
+        return this.to_string(response);
+    },
     // Send a GET request to the board
     // Send a GET request to the board
     // I reduced this to return the first line of the response that isnt undefined
     // I reduced this to return the first line of the response that isnt undefined
     // You'll also get 'out of memory' errors if you try to read/return too much data
     // You'll also get 'out of memory' errors if you try to read/return too much data

+ 9 - 0
assets/FlipperHTTP/flipper_http.py

@@ -134,6 +134,7 @@ def flipper_http_led_off():
 def flipper_http_parse_json(key: str, json_data: str) -> str:
 def flipper_http_parse_json(key: str, json_data: str) -> str:
     """Parse JSON data"""
     """Parse JSON data"""
     flipper_http_send_data('[PARSE]{"key":"' + key + '","json":' + json_data + "}")
     flipper_http_send_data('[PARSE]{"key":"' + key + '","json":' + json_data + "}")
+
     data = flipper_http_read_data(500)
     data = flipper_http_read_data(500)
     clear_buffer()
     clear_buffer()
     return data
     return data
@@ -175,6 +176,14 @@ def flipper_http_save_wifi(ssid: str, password: str) -> bool:
     return "[SUCCESS]" in data
     return "[SUCCESS]" in data
 
 
 
 
+def flipper_http_ip_address() -> str:
+    """Get the IP address of the WiFi Devboard"""
+    flipper_http_send_data("[IP/ADDRESS]")
+    data = flipper_http_read_data()
+    clear_buffer()
+    return data
+
+
 def flipper_http_get_request(url: str) -> str:
 def flipper_http_get_request(url: str) -> str:
     """Send a GET request to the specified URL"""
     """Send a GET request to the specified URL"""
     if url is None:
     if url is None:

+ 20 - 0
flipper_http.h

@@ -33,6 +33,7 @@ bool flipper_http_disconnect_wifi();
 bool flipper_http_ping();
 bool flipper_http_ping();
 bool flipper_http_scan_wifi();
 bool flipper_http_scan_wifi();
 bool flipper_http_save_wifi(const char *ssid, const char *password);
 bool flipper_http_save_wifi(const char *ssid, const char *password);
+bool flipper_http_ip_address();
 //---
 //---
 bool flipper_http_list_commands();
 bool flipper_http_list_commands();
 bool flipper_http_led_on();
 bool flipper_http_led_on();
@@ -610,6 +611,25 @@ bool flipper_http_save_wifi(const char *ssid, const char *password)
     return true;
     return true;
 }
 }
 
 
+// Function to get IP address
+/**
+ * @brief      Send a command to get the IP address.
+ * @return     true if the request was successful, false otherwise.
+ * @note       The received data will be handled asynchronously via the callback.
+ */
+bool flipper_http_ip_address()
+{
+    const char *command = "[IP/ADDRESS]";
+    if (!flipper_http_send_data(command))
+    {
+        FURI_LOG_E("FlipperHTTP", "Failed to send IP address command.");
+        return false;
+    }
+
+    // The response will be handled asynchronously via the callback
+    return true;
+}
+
 // Function to disconnect from WiFi (returns true if successful)
 // Function to disconnect from WiFi (returns true if successful)
 /**
 /**
  * @brief      Send a command to disconnect from WiFi.
  * @brief      Send a command to disconnect from WiFi.