forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v6.5: Preparing to support EP html over serial when Marauder FW chang…
…es merge (#41) * First pass at sending EP index.html * trying to make browseable - not working? * Fixup, run format * fix line endings * Update version
- Loading branch information
1 parent
b13649b
commit fce6038
Showing
11 changed files
with
102 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "wifi_marauder_ep.h" | ||
|
||
// returns success (if true, then caller needs to free(the_html)) | ||
bool wifi_marauder_ep_read_html_file(WifiMarauderApp* app, uint8_t** the_html, size_t* html_size) { | ||
// browse for files | ||
FuriString* predefined_filepath = furi_string_alloc_set_str(MARAUDER_APP_FOLDER_HTML); | ||
FuriString* selected_filepath = furi_string_alloc(); | ||
DialogsFileBrowserOptions browser_options; | ||
dialog_file_browser_set_basic_options(&browser_options, ".html", &I_Text_10x10); | ||
if(!dialog_file_browser_show( | ||
app->dialogs, selected_filepath, predefined_filepath, &browser_options)) { | ||
return false; | ||
} | ||
|
||
File* index_html = storage_file_alloc(app->storage); | ||
if(!storage_file_open( | ||
index_html, furi_string_get_cstr(selected_filepath), FSAM_READ, FSOM_OPEN_EXISTING)) { | ||
dialog_message_show_storage_error(app->dialogs, "Cannot open file"); | ||
return false; | ||
} | ||
|
||
uint64_t size = storage_file_size(index_html); | ||
|
||
*the_html = malloc(size); // to be freed by caller | ||
uint8_t* buf_ptr = *the_html; | ||
size_t read = 0; | ||
while(read < size) { | ||
size_t to_read = size - read; | ||
if(to_read > UINT16_MAX) to_read = UINT16_MAX; | ||
uint16_t now_read = storage_file_read(index_html, buf_ptr, (uint16_t)to_read); | ||
read += now_read; | ||
buf_ptr += now_read; | ||
} | ||
|
||
*html_size = read; | ||
|
||
storage_file_close(index_html); | ||
storage_file_free(index_html); | ||
|
||
furi_string_free(selected_filepath); | ||
furi_string_free(predefined_filepath); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// evil portal helper | ||
#pragma once | ||
|
||
#include "wifi_marauder_app_i.h" | ||
|
||
bool wifi_marauder_ep_read_html_file(WifiMarauderApp* app, uint8_t** the_html, size_t* html_size); |