@@ -28,6 +28,42 @@ static int password_count = 0;
2828// =================================================================
2929// HTML do Portal Cativo e Páginas
3030// =================================================================
31+ //
32+ // Le arquivo como string
33+ static const char * getHtmlBuffer (void ) {
34+ int lineCount = 0 ;
35+ if (sd_count_lines (path , & lineCount ) != 0 | lineCount <= 0 ) {
36+ ESP_LOGE (TAG_ET , "Error to count line of empty file" );
37+ return NULL ;
38+ }
39+
40+ const size_t predictLineSize = 80 ;
41+ site_t predictTotalFileSize = lineCount * PredictLineSize ;
42+
43+ char * buffer = (char * )malloc (predictTotalFileSize );
44+ if (!buffer ) {
45+ ESP_LOGE (TAG_ET , "Error to allocate bytes" );
46+ return NULL ;
47+ }
48+
49+ int result = sd_read_string (path , buffer , sizeof (buffer + 1 ));
50+
51+ if (result != 0 ) {
52+ ESP_LOGE (TAG_ET , "Error to read file <file> codigo: <code>" );
53+ free (buffer );
54+ return NULL ;
55+ }
56+
57+ size_t realSize = strlen (buffer );
58+ char * finalBuffer = (char * )realloc (buffer , realSize + 1 );
59+ if (finalBuffer ) {
60+ buffer = finalBuffer ;
61+ }
62+
63+ ESP_LOGI (TAG_ET , "Success Buffer Retrieved: <tam> bytes" , realSize );
64+ return buffer ;
65+ }
66+
3167static const char * captive_portal_html =
3268 "<!DOCTYPE html><html><head><title>Wi-Fi Login</title><meta "
3369 "name='viewport' content='width=device-width, "
0 commit comments