FlipperHTTP
HTTP library for the Flipper Zero. Compatible with the WiFi Developer Board, Raspberry Pi, and other ESP32 devices
FlipperHTTP brings internet access directly to your Flipper. It can be used to download apps, communicate with other Flipper devices, Web Crawl a website, and more.
The following apps have integrated FlipperHTTP to enhance their functionalities:
- FlipWorld - An open-world multiplayer game.
- FlipStore - A marketplace for downloading and managing apps and software on your Flipper Zero.
- FlipSocial - Social media platform for the Flipper Zero.
- FlipLibrary - A Flipper Zero app with a dictionary, random facts, and more.
- Web Crawler - Allows your Flipper Zero to crawl and interact with websites directly.
- FlipWeather - Use WiFi to get GPS and Weather information on your Flipper Zero.
- FlipTrader - Use WiFi to get the price of stocks and currency pairs on your Flipper Zero.
- FlipWiFi - FlipperHTTP companion app. Scan and save WiFi networks on your Flipper Zero.
Before you begin, ensure you have met the following requirements:
- Flipper Zero
- WiFi Developer Board or Raspberry Pi Pico W
Download Files
Download the flipper_http_bootloader.bin, flipper_http_firmware_a.bin, and flipper_http_partitions.bin files.
WiFi Devboard Installation
- Install the ESP Flasher app on your Flipper Zero from the Apps catalog: ESP Flasher App.
- Download the three bin files listed above.
- Disconnect your WiFi Developer Board and connect your Flipper Zero to your computer.
- Open qFlipper and click on the File manager.
- Navigate to
SD Card/apps_data/esp_flasher/
. If the folder doesn’t exist, create it or run the ESP Flasher app once. - Drag all three bin files into the directory.
- Disconnect your Flipper, then turn it off.
- Connect your WiFi Developer Board to the Flipper and turn on the Flipper. (Optionally, turn on your Flipper first. Then, hold the BOOT button while connecting your WiFi Developer Board. If you do this, when you get to step 11, you can skip the Reset Board and Enter Bootloader steps.)
- Open the ESP Flasher app on your Flipper, located under Apps→GPIO from the main menu.
- Select the following options in the ESP Flasher app:
- Reset Board: Wait a few seconds, then go back.
- Enter Bootloader: Wait until the 'waiting for download' message appears, then go back.
- If you do not see Flash ESP at the top, click Manual Flash.
- Select the following:
- Bootloader (0x1000): Choose the
flipper_http_bootloader.bin
. - Part Table (0x8000): Choose the
flipper_http_partitions.bin
. - FirmwareA (0x10000): Choose the
flipper_http_firmware_a.bin
.
- Bootloader (0x1000): Choose the
- Click on FLASH - fast. If successful, the Developer Board LED will flash GREEN three times.
- Press the RESET button once on the Developer Board.
Click here to view a video tutorial.
Raspberry Pi Pico W Installation (C++)
- Download the flipper_http_pico_c++.uf2 file.
- Press and hold the BOOT button on your Pico W for 2 seconds.
- While holding the BOOT button, connect the Pico W to your computer using a USB cable.
- Drag and drop the downloaded file onto the Pico W. It will automatically reboot and start running the FlipperHTTP firmware.
Raspberry Pi Pico W Installation (MicroPython)
- Download the flipper_http_pico_micro_python.uf2 file.
- Press and hold the BOOT button on your Pico W for 2 seconds.
- While holding the BOOT button, connect the Pico W to your computer using a USB cable.
- Drag and drop the downloaded file onto the Pico W. It will automatically reboot and start running the FlipperHTTP firmware.
Usage in C
(flipper_http.h and flipper_http.c)
Function Name | Return Value | Parameters | Description |
---|---|---|---|
flipper_http_alloc |
FlipperHTTP* |
None | Allocates and initializes the HTTP module. Returns a FlipperHTTP context if successful, otherwise NULL . |
flipper_http_free |
void |
FlipperHTTP *fhttp |
Deinitializes the HTTP module, stops asynchronous RX, releases the serial handle, and frees resources. |
flipper_http_connect_wifi |
bool |
FlipperHTTP *fhttp |
Sends a command to connect to WiFi using the provided FlipperHTTP context. Returns true if successful. |
flipper_http_disconnect_wifi |
bool |
FlipperHTTP *fhttp |
Sends a command to disconnect from the current WiFi network. Returns true if successful. |
flipper_http_ping |
bool |
FlipperHTTP *fhttp |
Sends a PING request to check if the WiFi Dev Board is connected. Returns true if successful. |
flipper_http_scan_wifi |
bool |
FlipperHTTP *fhttp |
Sends a command to scan for nearby WiFi networks. Returns true if the request was successful. |
flipper_http_save_wifi |
bool |
FlipperHTTP *fhttp , const char *ssid , const char *password |
Saves WiFi credentials for future connections. Returns true if successful. |
flipper_http_ip_wifi |
bool |
FlipperHTTP *fhttp |
Retrieves the IP address of the connected WiFi network. Returns true if successful. |
flipper_http_ip_address |
bool |
FlipperHTTP *fhttp |
Retrieves the IP address of the WiFi Devboard. Returns true if successful. |
flipper_http_list_commands |
bool |
FlipperHTTP *fhttp |
Sends a command to list all available commands. Returns true if successful. |
flipper_http_led_on |
bool |
FlipperHTTP *fhttp |
Enables the LED display while processing. Returns true if successful. |
flipper_http_led_off |
bool |
FlipperHTTP *fhttp |
Disables the LED display while processing. Returns true if successful. |
flipper_http_parse_json |
bool |
FlipperHTTP *fhttp , const char *key , const char *json_data |
Parses JSON data for a specified key. Returns true if parsing was successful. |
flipper_http_parse_json_array |
bool |
FlipperHTTP *fhttp , const char *key , int index , const char *json_data |
Parses an array within JSON data for a specified key and index. Returns true if successful. |
flipper_http_send_data |
bool |
FlipperHTTP *fhttp , const char *data |
Sends the specified data to the server with newline termination. Returns true if successful. |
flipper_http_rx_callback |
void |
const char *line , void *context |
Callback function for handling received data asynchronously. Handles the state of the UART. |
flipper_http_get_request |
bool |
FlipperHTTP *fhttp , const char *url |
Sends a GET request to the specified URL. Returns true if the request was successful. |
flipper_http_get_request_with_headers |
bool |
FlipperHTTP *fhttp , const char *url , const char *headers |
Sends a GET request with custom headers to the specified URL. Returns true if successful. |
flipper_http_get_request_bytes |
bool |
FlipperHTTP *fhttp , const char *url , const char *headers |
Sends a GET request with custom headers and retrieves raw bytes. Returns true if successful. |
flipper_http_post_request_with_headers |
bool |
FlipperHTTP *fhttp , const char *url , const char *headers , const char *payload |
Sends a POST request with custom headers and a payload to the specified URL. Returns true if successful. |
flipper_http_post_request_bytes |
bool |
FlipperHTTP *fhttp , const char *url , const char *headers , const char *payload |
Sends a POST request with custom headers and a payload, retrieving raw bytes. Returns true if successful. |
flipper_http_put_request_with_headers |
bool |
FlipperHTTP *fhttp , const char *url , const char *headers , const char *payload |
Sends a PUT request with custom headers and a payload to the specified URL. Returns true if successful. |
flipper_http_delete_request_with_headers |
bool |
FlipperHTTP *fhttp , const char *url , const char *headers , const char *payload |
Sends a DELETE request with custom headers and a payload to the specified URL. Returns true if successful. |
flipper_http_append_to_file |
bool |
const void *data , size_t data_size , bool start_new_file , char *file_path |
Appends received data to a file. Initializes the file path before calling. Returns true if successful. |
flipper_http_load_from_file |
FuriString* |
char *file_path |
Loads data from the specified file. Returns a FuriString containing the file data. |
flipper_http_load_from_file_with_limit |
FuriString* |
char *file_path , size_t limit |
Loads data from the specified file with a size limit. Returns a FuriString containing the file data up to the limit. |
flipper_http_worker |
int32_t |
void *context |
Worker thread to handle UART data asynchronously. Returns 0 upon completion. |
get_timeout_timer_callback |
void |
void *context |
Callback function invoked when a GET request times out. |
_flipper_http_rx_callback |
void |
FuriHalSerialHandle *handle , FuriHalSerialRxEvent event , void *context |
Private callback function to handle received UART data asynchronously. |
flipper_http_process_response_async |
bool |
FlipperHTTP *fhttp , bool (*http_request)(void) , bool (*parse_json)(void) |
Processes requests and parses JSON data asynchronously. Returns true if successful. |
flipper_http_loading_task |
void |
FlipperHTTP *fhttp , bool (*http_request)(void) , bool (*parse_response)(void) , uint32_t success_view_id , uint32_t failure_view_id , ViewDispatcher **view_dispatcher |
Performs a task while displaying a loading screen, handling success and failure views accordingly. |
flipper_http_websocket_start |
bool |
FlipperHTTP *fhttp , const char *url , uint16_t port , const char *headers |
Sends a request to start a WebSocket connection to the specified URL and port using the provided headers. Returns true if successful. |
flipper_http_websocket_stop |
bool |
FlipperHTTP *fhttp |
Sends a request to stop the WebSocket connection. Returns true if successful. |
In C, fhttp->last_response
holds the received data. Ensure that the FlipperHTTP *fhttp
context is properly allocated using flipper_http_alloc()
before invoking these functions and deallocated using flipper_http_free()
when done.
Usage in JavaScript
(flipper_http.js)
Function Name | Return Value | Parameters | Description |
---|---|---|---|
fhttp.init |
void |
None | Initializes the serial connection with the correct settings. |
fhttp.deinit |
void |
None | Deinitializes and ends the serial connection. |
fhttp.connect_wifi |
bool |
None | Sends a command to connect to WiFi and returns whether the connection was successful. |
fhttp.disconnect_wifi |
bool |
None | Sends a command to disconnect from WiFi and returns whether the disconnection was successful. |
fhttp.ping |
bool |
None | Sends a ping request to test connectivity and returns whether a response was received. |
fhttp.scan_wifi |
string |
None | Scans for nearby WiFi access points and returns a string with each access point separated by a comma. |
fhttp.save_wifi |
bool |
ssid: string , password: string |
Saves WiFi credentials and returns whether the save operation was successful. |
fhttp.ip_wifi |
string |
None | Gets the IP address of the connected WiFi network and returns it as a string. |
fhttp.ip_address |
string |
None | Gets the IP address of the WiFi Devboard and returns it as a string. |
fhttp.list_commands |
string |
None | Lists all available commands and returns them as a string. |
fhttp.led_on |
void |
None | Sends a command to allow the LED to display while processing. |
fhttp.led_off |
void |
None | Sends a command to disable the LED from displaying while processing. |
fhttp.parse_json |
string |
key: string , data: string |
Parses JSON data for a specified key and returns the corresponding value as a string. |
fhttp.parse_json_array |
string |
key: string , index: number , data: string |
Parses an array within JSON data for a specified key and index, returning the corresponding value. |
fhttp.send_data |
void |
data: string |
Sends the specified data to the serial port. |
fhttp.read_data |
string |
delay_ms: number |
Reads data from the serial port with a specified delay and returns the response received. |
fhttp.get_request |
string |
url: string |
Sends a GET request to the specified URL and returns the response. |
fhttp.get_request_with_headers |
string |
url: string , headers: string |
Sends a GET request with headers and returns the response. |
fhttp.post_request_with_headers |
string |
url: string , headers: string , payload: string |
Sends a POST request with headers and payload, and returns the response. |
fhttp.put_request_with_headers |
string |
url: string , headers: string , payload: string |
Sends a PUT request with headers and payload, and returns the response. |
fhttp.delete_request_with_headers |
string |
url: string , headers: string , payload: string |
Sends a DELETE request with headers and payload, and returns the response. |
fhttp.websocket_start |
bool |
url: string , port: number , headers: string |
Sends a command to start a WebSocket connection using the specified URL, port, and headers. Returns true if successful. |
fhttp.websocket_stop |
bool |
None | Sends a command to stop the WebSocket connection. Returns true if executed successfully. |
Usage in Python
(flipper_http.py)
Function Name | Return Value | Parameters | Description |
---|---|---|---|
flipper_http_connect_wifi |
bool |
None | Sends a command to connect to WiFi and returns whether the connection was successful. |
flipper_http_disconnect_wifi |
bool |
None | Sends a command to disconnect from WiFi and returns whether the disconnection was successful. |
flipper_http_ping |
bool |
None | Sends a ping request to test connectivity and returns whether a response was received. |
flipper_http_scan_wifi |
str |
None | Scans for nearby WiFi access points and returns a string listing each access point separated by commas. |
flipper_http_save_wifi |
bool |
ssid: str , password: str |
Saves WiFi credentials and returns whether the save operation was successful. |
flipper_http_ip_wifi |
str |
None | Gets the IP address of the connected WiFi network and returns it as a string. |
flipper_http_ip_address |
str |
None | Gets the IP address of the WiFi Devboard and returns it as a string. |
flipper_http_list_commands |
str |
None | Lists all available commands and returns them as a string. |
flipper_http_led_on |
void |
None | Sends a command to allow the LED to display while processing. |
flipper_http_led_off |
void |
None | Sends a command to disable the LED from displaying while processing. |
flipper_http_parse_json |
str |
key: str , json_data: str |
Parses JSON data for a specified key and returns the corresponding value as a string. |
flipper_http_parse_json_array |
str |
key: str , index: int , json_data: str |
Parses an array within JSON data for a specified key and index, returning the corresponding value. |
flipper_http_send_data |
void |
data: str |
Sends the specified data to the serial port. |
flipper_http_read_data |
str |
sleep_ms: int |
Reads data from the serial port with a specified delay and returns the response received. |
flipper_http_get_request |
str |
url: str |
Sends a GET request to the specified URL and returns the response. |
flipper_http_get_request_with_headers |
str |
url: str , headers: str |
Sends a GET request with headers and returns the response. |
flipper_http_post_request_with_headers |
str |
url: str , headers: str , data: str |
Sends a POST request with headers and data, and returns the response. |
flipper_http_put_request_with_headers |
str |
url: str , headers: str , data: str |
Sends a PUT request with headers and data, and returns the response. |
flipper_http_delete_request_with_headers |
str |
url: str , headers: str , data: str |
Sends a DELETE request with headers and data, and returns the response. |
flipper_http_websocket_start |
str |
url: str , port: int , headers: str |
Starts a WebSocket connection to the specified URL and port with headers. Returns the response data if successful, or an empty string if not. |
flipper_http_websocket_stop |
void |
None | Stops the WebSocket connection. |
Example in C
#define TAG "Example"
int32_t main(void *p)
{
// Suppress unused parameter warning
UNUSED(p);
// Initialize the FlipperHTTP application
FlipperHTTP *fhttp = flipper_http_alloc();
if (!fhttp)
{
FURI_LOG_E(TAG, "Failed to allocate memory for FlipperHTTP");
return -1;
}
if (!flipper_http_ping(fhttp))
{
FURI_LOG_E(TAG, "Failed to ping the device");
return -1;
}
// Try to wait for pong response.
uint8_t counter = 10;
while (fhttp.state == INACTIVE && --counter > 0)
{
FURI_LOG_D(TAG, "Waiting for PONG");
furi_delay_ms(100);
}
if (counter == 0)
{
FURI_LOG_E(TAG, "Failed to receive PONG response");
return -1;
}
// Deinitialize UART
flipper_http_free(fhttp);
return 0;
}
Example in JavaScript
// declarations
let eventLoop = require("event_loop");
let gui = require("gui");
let dialogView = require("gui/dialog");
let textBoxView = require("gui/text_box");
let dialog = dialogView.make();
let url = "https://catfact.ninja/fact";
dialog.set("header", "FlipperHTTP");
dialog.set("text", "JavaScript Example");
gui.viewDispatcher.switchTo(dialog);
delay(2000);
// Initialize
fhttp.init();
dialog.set("text", "Initialized!");
delay(500);
// Ping
let response = fhttp.ping();
// Connect to WiFi and get a random cat fact from catfact.ninja
if (response) {
dialog.set("text", "Saving wifi settings...");
delay(500);
let success = fhttp.save_wifi("your_ssid", "your_password");
if (success) {
dialog.set("text", "Sending GET request...");
delay(500);
let data = fhttp.get_request_with_headers(url, '{"Content-Type":"application/json"}');
if (data !== undefined && data !== "") {
let textBox = textBoxView.makeWith({
text: data,
});
gui.viewDispatcher.switchTo(textBox);
delay(10000); // delay for user to read
gui.viewDispatcher.switchTo(dialog);
fhttp.disconnect_wifi();
}
else {
dialog.set("text", "Failed to get data.");
fhttp.disconnect_wifi();
delay(1000);
}
}
else {
dialog.set("text", "Failed to save wifi settings.");
delay(1000);
}
}
else {
dialog.set("text", "Ping failed.");
delay(1000);
}
fhttp.deinit();
dialog.set("text", "Goodbye!");
delay(5000);
Example in Python
flipper_print("Starting HTTP example")
clear_buffer() # Clear the buffer before starting
time.sleep(1)
if flipper_http_ping() and flipper_http_save_wifi("your_ssid", "your_pass"):
flipper_print("WiFi saved successfully!")
time.sleep(2)
if flipper_http_connect_wifi():
flipper_print("WiFi connected successfully!")
time.sleep(2)
flipper_print(
flipper_http_get_request_with_headers(
"https://httpbin.org/get", "{Content-Type: application/json}"
)
)
time.sleep(2)
if flipper_http_disconnect_wifi():
flipper_print("WiFi disconnected successfully!")
time.sleep(2)
else:
flipper_print("Failed to save WiFi credentials")
time.sleep(2)
flipper_print("Exiting...")
time.sleep(2)