Browse Source

Revert all formatting of FlipperHTTP apps

Willy-JL 1 year ago
parent
commit
fae750dea4
62 changed files with 5166 additions and 4143 deletions
  1. 1 1
      flip_library/application.fam
  2. 217 136
      flip_library/jsmn/jsmn.c
  3. 49 48
      flip_library/jsmn/jsmn.h
  4. 1 1
      flip_social/alloc/free.c
  5. 2 0
      flip_social/easy_flipper/easy_flipper.h
  6. 93 59
      flip_social/flip_social.c
  7. 171 196
      flip_social/flip_social.h
  8. 4 4
      flip_store/callback/flip_store_callback.c
  9. 23 12
      flip_store/flip_store.c
  10. 52 49
      flip_store/flip_store.h
  11. 56 116
      flip_trader/alloc/flip_trader_alloc.c
  12. 2 2
      flip_trader/alloc/flip_trader_alloc.h
  13. 15 9
      flip_trader/app.c
  14. 1 1
      flip_trader/application.fam
  15. 275 207
      flip_trader/callback/flip_trader_callback.c
  16. 25 29
      flip_trader/callback/flip_trader_callback.h
  17. 198 139
      flip_trader/easy_flipper/easy_flipper.c
  18. 61 61
      flip_trader/easy_flipper/easy_flipper.h
  19. 32 20
      flip_trader/flip_storage/flip_trader_storage.c
  20. 9 3
      flip_trader/flip_storage/flip_trader_storage.h
  21. 35 20
      flip_trader/flip_trader.c
  22. 38 35
      flip_trader/flip_trader.h
  23. 294 166
      flip_trader/flipper_http/flipper_http.c
  24. 62 59
      flip_trader/flipper_http/flipper_http.h
  25. 217 136
      flip_trader/jsmn/jsmn.c
  26. 49 48
      flip_trader/jsmn/jsmn.h
  27. 50 104
      flip_weather/alloc/flip_weather_alloc.c
  28. 2 2
      flip_weather/alloc/flip_weather_alloc.h
  29. 15 9
      flip_weather/app.c
  30. 1 1
      flip_weather/application.fam
  31. 266 210
      flip_weather/callback/flip_weather_callback.c
  32. 15 22
      flip_weather/callback/flip_weather_callback.h
  33. 198 139
      flip_weather/easy_flipper/easy_flipper.c
  34. 61 61
      flip_weather/easy_flipper/easy_flipper.h
  35. 32 20
      flip_weather/flip_storage/flip_weather_storage.c
  36. 9 3
      flip_weather/flip_storage/flip_weather_storage.h
  37. 37 21
      flip_weather/flip_weather.c
  38. 36 33
      flip_weather/flip_weather.h
  39. 291 165
      flip_weather/flipper_http/flipper_http.c
  40. 67 65
      flip_weather/flipper_http/flipper_http.h
  41. 217 136
      flip_weather/jsmn/jsmn.c
  42. 49 48
      flip_weather/jsmn/jsmn.h
  43. 67 74
      flip_weather/parse/flip_weather_parse.c
  44. 16 13
      flip_weather/parse/flip_weather_parse.h
  45. 3 3
      flip_wifi/callback/flip_wifi_callback.c
  46. 1 0
      flip_wifi/easy_flipper/easy_flipper.h
  47. 176 272
      web_crawler/alloc/web_crawler_alloc.c
  48. 1 1
      web_crawler/alloc/web_crawler_alloc.h
  49. 15 9
      web_crawler/app.c
  50. 1 1
      web_crawler/application.fam
  51. 275 245
      web_crawler/callback/web_crawler_callback.c
  52. 45 49
      web_crawler/callback/web_crawler_callback.h
  53. 198 139
      web_crawler/easy_flipper/easy_flipper.c
  54. 61 61
      web_crawler/easy_flipper/easy_flipper.h
  55. 127 98
      web_crawler/flip_storage/web_crawler_storage.c
  56. 21 27
      web_crawler/flip_storage/web_crawler_storage.h
  57. 291 165
      web_crawler/flipper_http/flipper_http.c
  58. 62 59
      web_crawler/flipper_http/flipper_http.h
  59. 217 136
      web_crawler/jsmn/jsmn.c
  60. 49 48
      web_crawler/jsmn/jsmn.h
  61. 127 65
      web_crawler/web_crawler.c
  62. 85 82
      web_crawler/web_crawler.h

+ 1 - 1
flip_library/application.fam

@@ -10,5 +10,5 @@ App(
     fap_description="Utilize WiFi to retrieve data from 20 different APIs",
     fap_author="JBlanked",
     fap_weburl="https://github.com/jblanked/FlipLibrary",
-    fap_version="1.4",
+    fap_version = "1.4",
 )

+ 217 - 136
flip_library/jsmn/jsmn.c

@@ -13,11 +13,13 @@
 /**
  * Allocates a fresh unused token from the token pool.
  */
-static jsmntok_t*
-    jsmn_alloc_token(jsmn_parser* parser, jsmntok_t* tokens, const size_t num_tokens) {
-    jsmntok_t* tok;
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
+                                   const size_t num_tokens)
+{
+    jsmntok_t *tok;
 
-    if(parser->toknext >= num_tokens) {
+    if (parser->toknext >= num_tokens)
+    {
         return NULL;
     }
     tok = &tokens[parser->toknext++];
@@ -32,8 +34,9 @@ static jsmntok_t*
 /**
  * Fills token type and boundaries.
  */
-static void
-    jsmn_fill_token(jsmntok_t* token, const jsmntype_t type, const int start, const int end) {
+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
+                            const int start, const int end)
+{
     token->type = type;
     token->start = start;
     token->end = end;
@@ -43,19 +46,19 @@ static void
 /**
  * Fills next available token with JSON primitive.
  */
-static int jsmn_parse_primitive(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+                                const size_t len, jsmntok_t *tokens,
+                                const size_t num_tokens)
+{
+    jsmntok_t *token;
     int start;
 
     start = parser->pos;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-        switch(js[parser->pos]) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
+        switch (js[parser->pos])
+        {
 #ifndef JSMN_STRICT
         /* In strict mode primitive must be followed by "," or "}" or "]" */
         case ':':
@@ -72,7 +75,8 @@ static int jsmn_parse_primitive(
             /* to quiet a warning from gcc*/
             break;
         }
-        if(js[parser->pos] < 32 || js[parser->pos] >= 127) {
+        if (js[parser->pos] < 32 || js[parser->pos] >= 127)
+        {
             parser->pos = start;
             return JSMN_ERROR_INVAL;
         }
@@ -84,12 +88,14 @@ static int jsmn_parse_primitive(
 #endif
 
 found:
-    if(tokens == NULL) {
+    if (tokens == NULL)
+    {
         parser->pos--;
         return 0;
     }
     token = jsmn_alloc_token(parser, tokens, num_tokens);
-    if(token == NULL) {
+    if (token == NULL)
+    {
         parser->pos = start;
         return JSMN_ERROR_NOMEM;
     }
@@ -104,29 +110,31 @@ found:
 /**
  * Fills next token with JSON string.
  */
-static int jsmn_parse_string(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+                             const size_t len, jsmntok_t *tokens,
+                             const size_t num_tokens)
+{
+    jsmntok_t *token;
 
     int start = parser->pos;
 
     /* Skip starting quote */
     parser->pos++;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c = js[parser->pos];
 
         /* Quote: end of string */
-        if(c == '\"') {
-            if(tokens == NULL) {
+        if (c == '\"')
+        {
+            if (tokens == NULL)
+            {
                 return 0;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 parser->pos = start;
                 return JSMN_ERROR_NOMEM;
             }
@@ -138,10 +146,12 @@ static int jsmn_parse_string(
         }
 
         /* Backslash: Quoted symbol expected */
-        if(c == '\\' && parser->pos + 1 < len) {
+        if (c == '\\' && parser->pos + 1 < len)
+        {
             int i;
             parser->pos++;
-            switch(js[parser->pos]) {
+            switch (js[parser->pos])
+            {
             /* Allowed escaped symbols */
             case '\"':
             case '/':
@@ -155,11 +165,13 @@ static int jsmn_parse_string(
             /* Allows escaped symbol \uXXXX */
             case 'u':
                 parser->pos++;
-                for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+                for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++)
+                {
                     /* If it isn't a hex character we have an error */
-                    if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                         (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                         (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+                    if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+                          (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+                          (js[parser->pos] >= 97 && js[parser->pos] <= 102)))
+                    { /* a-f */
                         parser->pos = start;
                         return JSMN_ERROR_INVAL;
                     }
@@ -181,7 +193,8 @@ static int jsmn_parse_string(
 /**
  * Create JSON parser over an array of tokens
  */
-void jsmn_init(jsmn_parser* parser) {
+void jsmn_init(jsmn_parser *parser)
+{
     parser->pos = 0;
     parser->toknext = 0;
     parser->toksuper = -1;
@@ -190,38 +203,41 @@ void jsmn_init(jsmn_parser* parser) {
 /**
  * Parse JSON string and fill tokens.
  */
-int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens) {
+int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+               jsmntok_t *tokens, const unsigned int num_tokens)
+{
     int r;
     int i;
-    jsmntok_t* token;
+    jsmntok_t *token;
     int count = parser->toknext;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c;
         jsmntype_t type;
 
         c = js[parser->pos];
-        switch(c) {
+        switch (c)
+        {
         case '{':
         case '[':
             count++;
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 return JSMN_ERROR_NOMEM;
             }
-            if(parser->toksuper != -1) {
-                jsmntok_t* t = &tokens[parser->toksuper];
+            if (parser->toksuper != -1)
+            {
+                jsmntok_t *t = &tokens[parser->toksuper];
 #ifdef JSMN_STRICT
                 /* In strict mode an object or array can't become a key */
-                if(t->type == JSMN_OBJECT) {
+                if (t->type == JSMN_OBJECT)
+                {
                     return JSMN_ERROR_INVAL;
                 }
 #endif
@@ -236,26 +252,33 @@ int jsmn_parse(
             break;
         case '}':
         case ']':
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
 #ifdef JSMN_PARENT_LINKS
-            if(parser->toknext < 1) {
+            if (parser->toknext < 1)
+            {
                 return JSMN_ERROR_INVAL;
             }
             token = &tokens[parser->toknext - 1];
-            for(;;) {
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+            for (;;)
+            {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     token->end = parser->pos + 1;
                     parser->toksuper = token->parent;
                     break;
                 }
-                if(token->parent == -1) {
-                    if(token->type != type || parser->toksuper == -1) {
+                if (token->parent == -1)
+                {
+                    if (token->type != type || parser->toksuper == -1)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     break;
@@ -263,10 +286,13 @@ int jsmn_parse(
                 token = &tokens[token->parent];
             }
 #else
-            for(i = parser->toknext - 1; i >= 0; i--) {
+            for (i = parser->toknext - 1; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     parser->toksuper = -1;
@@ -275,12 +301,15 @@ int jsmn_parse(
                 }
             }
             /* Error if unmatched closing bracket */
-            if(i == -1) {
+            if (i == -1)
+            {
                 return JSMN_ERROR_INVAL;
             }
-            for(; i >= 0; i--) {
+            for (; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
+                if (token->start != -1 && token->end == -1)
+                {
                     parser->toksuper = i;
                     break;
                 }
@@ -289,11 +318,13 @@ int jsmn_parse(
             break;
         case '\"':
             r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -306,15 +337,19 @@ int jsmn_parse(
             parser->toksuper = parser->toknext - 1;
             break;
         case ',':
-            if(tokens != NULL && parser->toksuper != -1 &&
-               tokens[parser->toksuper].type != JSMN_ARRAY &&
-               tokens[parser->toksuper].type != JSMN_OBJECT) {
+            if (tokens != NULL && parser->toksuper != -1 &&
+                tokens[parser->toksuper].type != JSMN_ARRAY &&
+                tokens[parser->toksuper].type != JSMN_OBJECT)
+            {
 #ifdef JSMN_PARENT_LINKS
                 parser->toksuper = tokens[parser->toksuper].parent;
 #else
-                for(i = parser->toknext - 1; i >= 0; i--) {
-                    if(tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
-                        if(tokens[i].start != -1 && tokens[i].end == -1) {
+                for (i = parser->toknext - 1; i >= 0; i--)
+                {
+                    if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT)
+                    {
+                        if (tokens[i].start != -1 && tokens[i].end == -1)
+                        {
                             parser->toksuper = i;
                             break;
                         }
@@ -340,9 +375,12 @@ int jsmn_parse(
         case 'f':
         case 'n':
             /* And they must not be keys of the object */
-            if(tokens != NULL && parser->toksuper != -1) {
-                const jsmntok_t* t = &tokens[parser->toksuper];
-                if(t->type == JSMN_OBJECT || (t->type == JSMN_STRING && t->size != 0)) {
+            if (tokens != NULL && parser->toksuper != -1)
+            {
+                const jsmntok_t *t = &tokens[parser->toksuper];
+                if (t->type == JSMN_OBJECT ||
+                    (t->type == JSMN_STRING && t->size != 0))
+                {
                     return JSMN_ERROR_INVAL;
                 }
             }
@@ -351,11 +389,13 @@ int jsmn_parse(
         default:
 #endif
             r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -368,10 +408,13 @@ int jsmn_parse(
         }
     }
 
-    if(tokens != NULL) {
-        for(i = parser->toknext - 1; i >= 0; i--) {
+    if (tokens != NULL)
+    {
+        for (i = parser->toknext - 1; i >= 0; i--)
+        {
             /* Unmatched opened object or array */
-            if(tokens[i].start != -1 && tokens[i].end == -1) {
+            if (tokens[i].start != -1 && tokens[i].end == -1)
+            {
                 return JSMN_ERROR_PART;
             }
         }
@@ -381,10 +424,12 @@ int jsmn_parse(
 }
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value) {
-    int length = strlen(key) + strlen(value) + 8; // Calculate required length
-    char* result = (char*)malloc(length * sizeof(char)); // Allocate memory
-    if(result == NULL) {
+char *jsmn(const char *key, const char *value)
+{
+    int length = strlen(key) + strlen(value) + 8;         // Calculate required length
+    char *result = (char *)malloc(length * sizeof(char)); // Allocate memory
+    if (result == NULL)
+    {
         return NULL; // Handle memory allocation failure
     }
     snprintf(result, length, "{\"%s\":\"%s\"}", key, value);
@@ -392,30 +437,36 @@ char* jsmn(const char* key, const char* value) {
 }
 
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s) {
-    if(tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
-       strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+    if (tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
+        strncmp(json + tok->start, s, tok->end - tok->start) == 0)
+    {
         return 0;
     }
     return -1;
 }
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens)
+{
     // Parse the JSON feed
-    if(json_data != NULL) {
+    if (json_data != NULL)
+    {
         jsmn_parser parser;
         jsmn_init(&parser);
 
         // Allocate tokens array on the heap
-        jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-        if(tokens == NULL) {
+        jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+        if (tokens == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
             return NULL;
         }
 
         int ret = jsmn_parse(&parser, json_data, strlen(json_data), tokens, max_tokens);
-        if(ret < 0) {
+        if (ret < 0)
+        {
             // Handle parsing errors
             FURI_LOG_E("JSMM.H", "Failed to parse JSON: %d", ret);
             free(tokens);
@@ -423,19 +474,23 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
         }
 
         // Ensure that the root element is an object
-        if(ret < 1 || tokens[0].type != JSMN_OBJECT) {
+        if (ret < 1 || tokens[0].type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Root element is not an object.");
             free(tokens);
             return NULL;
         }
 
         // Loop through the tokens to find the key
-        for(int i = 1; i < ret; i++) {
-            if(jsoneq(json_data, &tokens[i], key) == 0) {
+        for (int i = 1; i < ret; i++)
+        {
+            if (jsoneq(json_data, &tokens[i], key) == 0)
+            {
                 // We found the key. Now, return the associated value.
                 int length = tokens[i + 1].end - tokens[i + 1].start;
-                char* value = malloc(length + 1);
-                if(value == NULL) {
+                char *value = malloc(length + 1);
+                if (value == NULL)
+                {
                     FURI_LOG_E("JSMM.H", "Failed to allocate memory for value.");
                     free(tokens);
                     return NULL;
@@ -450,7 +505,9 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 
         // Free the token array if key was not found
         free(tokens);
-    } else {
+    }
+    else
+    {
         FURI_LOG_E("JSMM.H", "JSON data is NULL");
     }
     FURI_LOG_E("JSMM.H", "Failed to find the key in the JSON.");
@@ -458,10 +515,12 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 }
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens) {
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -471,8 +530,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -480,7 +540,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -488,7 +549,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Ensure the root element is an array
-    if(ret < 1 || tokens[0].type != JSMN_ARRAY) {
+    if (ret < 1 || tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -496,12 +558,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Check if the index is within bounds
-    if(index >= (uint32_t)tokens[0].size) {
-        FURI_LOG_E(
-            "JSMM.H",
-            "Index %lu out of bounds for array with size %d.",
-            (unsigned long)index,
-            tokens[0].size);
+    if (index >= (uint32_t)tokens[0].size)
+    {
+        FURI_LOG_E("JSMM.H", "Index %lu out of bounds for array with size %d.", (unsigned long)index, tokens[0].size);
         free(tokens);
         free(array_str);
         return NULL;
@@ -509,20 +568,27 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Locate the token corresponding to the desired array element
     int current_token = 1; // Start after the array token
-    for(uint32_t i = 0; i < index; i++) {
-        if(tokens[current_token].type == JSMN_OBJECT) {
+    for (uint32_t i = 0; i < index; i++)
+    {
+        if (tokens[current_token].type == JSMN_OBJECT)
+        {
             // For objects, skip all key-value pairs
             current_token += 1 + 2 * tokens[current_token].size;
-        } else if(tokens[current_token].type == JSMN_ARRAY) {
+        }
+        else if (tokens[current_token].type == JSMN_ARRAY)
+        {
             // For nested arrays, skip all elements
             current_token += 1 + tokens[current_token].size;
-        } else {
+        }
+        else
+        {
             // For primitive types, simply move to the next token
             current_token += 1;
         }
 
         // Safety check to prevent out-of-bounds
-        if(current_token >= ret) {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             free(tokens);
             free(array_str);
@@ -533,8 +599,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     // Extract the array element
     jsmntok_t element = tokens[current_token];
     int length = element.end - element.start;
-    char* value = malloc(length + 1);
-    if(value == NULL) {
+    char *value = malloc(length + 1);
+    if (value == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
         free(tokens);
         free(array_str);
@@ -553,10 +620,12 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 }
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values) {
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -566,8 +635,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -575,7 +645,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -583,7 +654,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     }
 
     // Ensure the root element is an array
-    if(tokens[0].type != JSMN_ARRAY) {
+    if (tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -592,8 +664,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Allocate memory for the array of values (maximum possible)
     int array_size = tokens[0].size;
-    char** values = malloc(array_size * sizeof(char*));
-    if(values == NULL) {
+    char **values = malloc(array_size * sizeof(char *));
+    if (values == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array of values.");
         free(tokens);
         free(array_str);
@@ -604,15 +677,18 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Traverse the array and extract all object values
     int current_token = 1; // Start after the array token
-    for(int i = 0; i < array_size; i++) {
-        if(current_token >= ret) {
+    for (int i = 0; i < array_size; i++)
+    {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             break;
         }
 
         jsmntok_t element = tokens[current_token];
 
-        if(element.type != JSMN_OBJECT) {
+        if (element.type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Array element %d is not an object, skipping.", i);
             // Skip this element
             current_token += 1;
@@ -622,10 +698,12 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
         int length = element.end - element.start;
 
         // Allocate a new string for the value and copy the data
-        char* value = malloc(length + 1);
-        if(value == NULL) {
+        char *value = malloc(length + 1);
+        if (value == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
-            for(int j = 0; j < actual_num_values; j++) {
+            for (int j = 0; j < actual_num_values; j++)
+            {
                 free(values[j]);
             }
             free(values);
@@ -647,14 +725,17 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     *num_values = actual_num_values;
 
     // Reallocate the values array to actual_num_values if necessary
-    if(actual_num_values < array_size) {
-        char** reduced_values = realloc(values, actual_num_values * sizeof(char*));
-        if(reduced_values != NULL) {
+    if (actual_num_values < array_size)
+    {
+        char **reduced_values = realloc(values, actual_num_values * sizeof(char *));
+        if (reduced_values != NULL)
+        {
             values = reduced_values;
         }
 
         // Free the remaining values
-        for(int i = actual_num_values; i < array_size; i++) {
+        for (int i = actual_num_values; i < array_size; i++)
+        {
             free(values[i]);
         }
     }

+ 49 - 48
flip_library/jsmn/jsmn.h

@@ -19,7 +19,8 @@
 #include <stddef.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
 #ifdef JSMN_STATIC
@@ -28,71 +29,71 @@ extern "C" {
 #define JSMN_API extern
 #endif
 
-/**
+    /**
      * JSON type identifier. Basic types are:
      * 	o Object
      * 	o Array
      * 	o String
      * 	o Other primitive: number, boolean (true/false) or null
      */
-typedef enum {
-    JSMN_UNDEFINED = 0,
-    JSMN_OBJECT = 1 << 0,
-    JSMN_ARRAY = 1 << 1,
-    JSMN_STRING = 1 << 2,
-    JSMN_PRIMITIVE = 1 << 3
-} jsmntype_t;
-
-enum jsmnerr {
-    /* Not enough tokens were provided */
-    JSMN_ERROR_NOMEM = -1,
-    /* Invalid character inside JSON string */
-    JSMN_ERROR_INVAL = -2,
-    /* The string is not a full JSON packet, more bytes expected */
-    JSMN_ERROR_PART = -3
-};
-
-/**
+    typedef enum
+    {
+        JSMN_UNDEFINED = 0,
+        JSMN_OBJECT = 1 << 0,
+        JSMN_ARRAY = 1 << 1,
+        JSMN_STRING = 1 << 2,
+        JSMN_PRIMITIVE = 1 << 3
+    } jsmntype_t;
+
+    enum jsmnerr
+    {
+        /* Not enough tokens were provided */
+        JSMN_ERROR_NOMEM = -1,
+        /* Invalid character inside JSON string */
+        JSMN_ERROR_INVAL = -2,
+        /* The string is not a full JSON packet, more bytes expected */
+        JSMN_ERROR_PART = -3
+    };
+
+    /**
      * JSON token description.
      * type		type (object, array, string etc.)
      * start	start position in JSON data string
      * end		end position in JSON data string
      */
-typedef struct {
-    jsmntype_t type;
-    int start;
-    int end;
-    int size;
+    typedef struct
+    {
+        jsmntype_t type;
+        int start;
+        int end;
+        int size;
 #ifdef JSMN_PARENT_LINKS
-    int parent;
+        int parent;
 #endif
-} jsmntok_t;
+    } jsmntok_t;
 
-/**
+    /**
      * JSON parser. Contains an array of token blocks available. Also stores
      * the string being parsed now and current position in that string.
      */
-typedef struct {
-    unsigned int pos; /* offset in the JSON string */
-    unsigned int toknext; /* next token to allocate */
-    int toksuper; /* superior token node, e.g. parent object or array */
-} jsmn_parser;
-
-/**
+    typedef struct
+    {
+        unsigned int pos;     /* offset in the JSON string */
+        unsigned int toknext; /* next token to allocate */
+        int toksuper;         /* superior token node, e.g. parent object or array */
+    } jsmn_parser;
+
+    /**
      * Create JSON parser over an array of tokens
      */
-JSMN_API void jsmn_init(jsmn_parser* parser);
+    JSMN_API void jsmn_init(jsmn_parser *parser);
 
-/**
+    /**
      * Run JSON parser. It parses a JSON data string into and array of tokens, each
      * describing a single JSON object.
      */
-JSMN_API int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens);
+    JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+                            jsmntok_t *tokens, const unsigned int num_tokens);
 
 #ifndef JSMN_HEADER
 /* Implementation has been moved to jsmn.c */
@@ -116,16 +117,16 @@ JSMN_API int jsmn_parse(
 #include <furi.h>
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value);
+char *jsmn(const char *key, const char *value);
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s);
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens);
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens);
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values);
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values);
 #endif /* JB_JSMN_EDIT */

+ 1 - 1
flip_social/alloc/free.c

@@ -33,7 +33,7 @@ void free_text_input()
 {
     if (app_instance->text_input)
     {
-        uart_text_input_free(app_instance->text_input);
+        text_input_free(app_instance->text_input);
         app_instance->text_input = NULL;
         view_dispatcher_remove_view(app_instance->view_dispatcher, FlipSocialViewTextInput);
     }

+ 2 - 0
flip_social/easy_flipper/easy_flipper.h

@@ -16,6 +16,8 @@
 #include <gui/modules/text_box.h>
 #include <gui/modules/variable_item_list.h>
 #include <gui/modules/dialog_ex.h>
+#include <notification/notification.h>
+#include <dialogs/dialogs.h>
 #include <gui/modules/popup.h>
 #include <gui/modules/loading.h>
 #include <stdio.h>

+ 93 - 59
flip_social/flip_social.c

@@ -1,14 +1,12 @@
 #include "flip_social.h"
 
-FlipSocialModel* flip_social_friends = NULL; // Store the friends
-FlipSocialModel2* flip_social_message_users =
-    NULL; // Store the users that have sent messages to the logged in user
-FlipSocialModel* flip_social_explore = NULL; // Store the users to explore
-FlipSocialMessage* flip_social_messages =
-    NULL; // Store the messages between the logged in user and the selected user
-FlipSocialFeedMini* flip_feed_info = NULL; // Store the feed info
-FlipSocialFeedItem* flip_feed_item = NULL; // Store a feed item
-FlipSocialApp* app_instance = NULL;
+FlipSocialModel *flip_social_friends = NULL;        // Store the friends
+FlipSocialModel2 *flip_social_message_users = NULL; // Store the users that have sent messages to the logged in user
+FlipSocialModel *flip_social_explore = NULL;        // Store the users to explore
+FlipSocialMessage *flip_social_messages = NULL;     // Store the messages between the logged in user and the selected user
+FlipSocialFeedMini *flip_feed_info = NULL;          // Store the feed info
+FlipSocialFeedItem *flip_feed_item = NULL;          // Store a feed item
+FlipSocialApp *app_instance = NULL;
 
 bool flip_social_sent_login_request = false;
 bool flip_social_sent_register_request = false;
@@ -17,15 +15,15 @@ bool flip_social_register_success = false;
 bool flip_social_dialog_shown = false;
 bool flip_social_dialog_stop = false;
 bool flip_social_send_message = false;
-char* selected_message = NULL;
+char *selected_message = NULL;
 
 char auth_headers[256] = {0};
-char* flip_social_feed_type[] = {"Global", "Friends"};
+char *flip_social_feed_type[] = {"Global", "Friends"};
 uint8_t flip_social_feed_type_index = 0;
-char* flip_social_notification_type[] = {"OFF", "ON"};
+char *flip_social_notification_type[] = {"OFF", "ON"};
 uint8_t flip_social_notification_type_index = 0;
 
-void flip_social_loader_free_model(View* view);
+void flip_social_loader_free_model(View *view);
 
 /**
  * @brief Function to free the resources used by FlipSocialApp.
@@ -33,89 +31,125 @@ void flip_social_loader_free_model(View* view);
  * @param app The FlipSocialApp object to free.
  * @return void
  */
-void flip_social_app_free(FlipSocialApp* app) {
-    if(!app) {
+void flip_social_app_free(FlipSocialApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipSocialApp is NULL");
         return;
     }
-    if(!app->view_dispatcher) {
+    if (!app->view_dispatcher)
+    {
         FURI_LOG_E(TAG, "ViewDispatcher is NULL");
         return;
     }
 
     // Free Submenu(s)
-    if(app->submenu_logged_out) {
+    if (app->submenu_logged_out)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipSocialViewLoggedOutSubmenu);
         submenu_free(app->submenu_logged_out);
     }
-    if(app->submenu_logged_in) {
+    if (app->submenu_logged_in)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipSocialViewLoggedInSubmenu);
         submenu_free(app->submenu_logged_in);
     }
     //
 
     // Free Widget(s)
-    if(app->widget_result) {
+    if (app->widget_result)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipSocialViewWidgetResult);
         widget_free(app->widget_result);
     }
 
     // Free View(s)
-    if(app->view_loader) {
+    if (app->view_loader)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipSocialViewLoader);
         flip_social_loader_free_model(app->view_loader);
         view_free(app->view_loader);
     }
 
-    if(app->view_dispatcher) view_dispatcher_free(app->view_dispatcher);
+    if (app->view_dispatcher)
+        view_dispatcher_free(app->view_dispatcher);
 
     // Free the app structure members
-    if(app->wifi_ssid_logged_out) free(app->wifi_ssid_logged_out);
-    if(app->wifi_ssid_logged_out_temp_buffer) free(app->wifi_ssid_logged_out_temp_buffer);
-    if(app->wifi_password_logged_out) free(app->wifi_password_logged_out);
-    if(app->wifi_password_logged_out_temp_buffer) free(app->wifi_password_logged_out_temp_buffer);
-    if(app->login_username_logged_out) free(app->login_username_logged_out);
-    if(app->login_username_logged_out_temp_buffer)
+    if (app->wifi_ssid_logged_out)
+        free(app->wifi_ssid_logged_out);
+    if (app->wifi_ssid_logged_out_temp_buffer)
+        free(app->wifi_ssid_logged_out_temp_buffer);
+    if (app->wifi_password_logged_out)
+        free(app->wifi_password_logged_out);
+    if (app->wifi_password_logged_out_temp_buffer)
+        free(app->wifi_password_logged_out_temp_buffer);
+    if (app->login_username_logged_out)
+        free(app->login_username_logged_out);
+    if (app->login_username_logged_out_temp_buffer)
         free(app->login_username_logged_out_temp_buffer);
-    if(app->login_password_logged_out) free(app->login_password_logged_out);
-    if(app->login_password_logged_out_temp_buffer)
+    if (app->login_password_logged_out)
+        free(app->login_password_logged_out);
+    if (app->login_password_logged_out_temp_buffer)
         free(app->login_password_logged_out_temp_buffer);
-    if(app->register_username_logged_out) free(app->register_username_logged_out);
-    if(app->register_username_logged_out_temp_buffer)
+    if (app->register_username_logged_out)
+        free(app->register_username_logged_out);
+    if (app->register_username_logged_out_temp_buffer)
         free(app->register_username_logged_out_temp_buffer);
-    if(app->register_password_logged_out) free(app->register_password_logged_out);
-    if(app->register_password_logged_out_temp_buffer)
+    if (app->register_password_logged_out)
+        free(app->register_password_logged_out);
+    if (app->register_password_logged_out_temp_buffer)
         free(app->register_password_logged_out_temp_buffer);
-    if(app->register_password_2_logged_out) free(app->register_password_2_logged_out);
-    if(app->register_password_2_logged_out_temp_buffer)
+    if (app->register_password_2_logged_out)
+        free(app->register_password_2_logged_out);
+    if (app->register_password_2_logged_out_temp_buffer)
         free(app->register_password_2_logged_out_temp_buffer);
-    if(app->change_password_logged_in) free(app->change_password_logged_in);
-    if(app->change_password_logged_in_temp_buffer)
+    if (app->change_password_logged_in)
+        free(app->change_password_logged_in);
+    if (app->change_password_logged_in_temp_buffer)
         free(app->change_password_logged_in_temp_buffer);
-    if(app->change_bio_logged_in) free(app->change_bio_logged_in);
-    if(app->compose_pre_save_logged_in) free(app->compose_pre_save_logged_in);
-    if(app->compose_pre_save_logged_in_temp_buffer)
+    if (app->change_bio_logged_in)
+        free(app->change_bio_logged_in);
+    if (app->compose_pre_save_logged_in)
+        free(app->compose_pre_save_logged_in);
+    if (app->compose_pre_save_logged_in_temp_buffer)
         free(app->compose_pre_save_logged_in_temp_buffer);
-    if(app->explore_logged_in) free(app->explore_logged_in);
-    if(app->explore_logged_in_temp_buffer) free(app->explore_logged_in_temp_buffer);
-    if(app->message_users_logged_in) free(app->message_users_logged_in);
-    if(app->message_users_logged_in_temp_buffer) free(app->message_users_logged_in_temp_buffer);
-    if(app->wifi_ssid_logged_in) free(app->wifi_ssid_logged_in);
-    if(app->wifi_ssid_logged_in_temp_buffer) free(app->wifi_ssid_logged_in_temp_buffer);
-    if(app->wifi_password_logged_in) free(app->wifi_password_logged_in);
-    if(app->wifi_password_logged_in_temp_buffer) free(app->wifi_password_logged_in_temp_buffer);
-    if(app->is_logged_in) free(app->is_logged_in);
-    if(app->login_username_logged_in) free(app->login_username_logged_in);
-    if(app->login_username_logged_in_temp_buffer) free(app->login_username_logged_in_temp_buffer);
-    if(app->messages_new_message_logged_in) free(app->messages_new_message_logged_in);
-    if(app->messages_new_message_logged_in_temp_buffer)
+    if (app->explore_logged_in)
+        free(app->explore_logged_in);
+    if (app->explore_logged_in_temp_buffer)
+        free(app->explore_logged_in_temp_buffer);
+    if (app->message_users_logged_in)
+        free(app->message_users_logged_in);
+    if (app->message_users_logged_in_temp_buffer)
+        free(app->message_users_logged_in_temp_buffer);
+    if (app->wifi_ssid_logged_in)
+        free(app->wifi_ssid_logged_in);
+    if (app->wifi_ssid_logged_in_temp_buffer)
+        free(app->wifi_ssid_logged_in_temp_buffer);
+    if (app->wifi_password_logged_in)
+        free(app->wifi_password_logged_in);
+    if (app->wifi_password_logged_in_temp_buffer)
+        free(app->wifi_password_logged_in_temp_buffer);
+    if (app->is_logged_in)
+        free(app->is_logged_in);
+    if (app->login_username_logged_in)
+        free(app->login_username_logged_in);
+    if (app->login_username_logged_in_temp_buffer)
+        free(app->login_username_logged_in_temp_buffer);
+    if (app->messages_new_message_logged_in)
+        free(app->messages_new_message_logged_in);
+    if (app->messages_new_message_logged_in_temp_buffer)
         free(app->messages_new_message_logged_in_temp_buffer);
-    if(app->message_user_choice_logged_in) free(app->message_user_choice_logged_in);
-    if(app->message_user_choice_logged_in_temp_buffer)
+    if (app->message_user_choice_logged_in)
+        free(app->message_user_choice_logged_in);
+    if (app->message_user_choice_logged_in_temp_buffer)
         free(app->message_user_choice_logged_in_temp_buffer);
-    if(selected_message) free(selected_message);
-    if(app->explore_user_bio) free(app->explore_user_bio);
+    if (selected_message)
+        free(selected_message);
+    if (app->explore_user_bio)
+        free(app->explore_user_bio);
 
     // Free the app structure
-    if(app_instance) free(app_instance);
-}
+    if (app_instance)
+        free(app_instance);
+}

+ 171 - 196
flip_social/flip_social.h

@@ -9,48 +9,47 @@
 #include <flip_social_icons.h>
 #include <font/font.h>
 
-#define TAG         "FlipSocial"
+#define TAG "FlipSocial"
 #define VERSION_TAG TAG " v1.0.2"
 
 #define MAX_PRE_SAVED_MESSAGES 20 // Maximum number of pre-saved messages
-#define MAX_MESSAGE_LENGTH     100 // Maximum length of a message in the feed
-#define MAX_EXPLORE_USERS      50 // Maximum number of users to explore
-#define MAX_USER_LENGTH        32 // Maximum length of a username
-#define MAX_FRIENDS            50 // Maximum number of friends
-#define MAX_FEED_ITEMS         20 // Maximum number of feed items
-#define MAX_LINE_LENGTH        27
-#define MAX_MESSAGE_USERS      40 // Maximum number of users to display in the submenu
-#define MAX_MESSAGES           20 // Maximum number of meesages between each user
+#define MAX_MESSAGE_LENGTH 100    // Maximum length of a message in the feed
+#define MAX_EXPLORE_USERS 50      // Maximum number of users to explore
+#define MAX_USER_LENGTH 32        // Maximum length of a username
+#define MAX_FRIENDS 50            // Maximum number of friends
+#define MAX_FEED_ITEMS 20         // Maximum number of feed items
+#define MAX_LINE_LENGTH 27
+#define MAX_MESSAGE_USERS 40 // Maximum number of users to display in the submenu
+#define MAX_MESSAGES 20      // Maximum number of meesages between each user
 
 #define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/settings.bin"
-#define PRE_SAVED_MESSAGES_PATH \
-    STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/pre_saved_messages.txt"
+#define PRE_SAVED_MESSAGES_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_social/pre_saved_messages.txt"
 
 // Define the submenu items for our Hello World application
-typedef enum {
-    FlipSocialSubmenuLoggedOutIndexLogin, // click to go to the login screen
+typedef enum
+{
+    FlipSocialSubmenuLoggedOutIndexLogin,    // click to go to the login screen
     FlipSocialSubmenuLoggedOutIndexRegister, // click to go to the register screen
     //
-    FlipSocialSubmenuLoggedOutIndexAbout, // click to go to the about screen
+    FlipSocialSubmenuLoggedOutIndexAbout,        // click to go to the about screen
     FlipSocialSubmenuLoggedOutIndexWifiSettings, // click to go to the wifi settings screen
-    FlipSocialSubmenuLoggedInIndexUserSettings, // click to go to the user settings screen
+    FlipSocialSubmenuLoggedInIndexUserSettings,  // click to go to the user settings screen
     //
-    FlipSocialSubmenuLoggedInIndexAbout, // click to go to the about screen
+    FlipSocialSubmenuLoggedInIndexAbout,        // click to go to the about screen
     FlipSocialSubmenuLoggedInIndexWifiSettings, // click to go to the wifi settings screen
     //
-    FlipSocialSubmenuLoggedInIndexProfile, // click to go to the profile screen
-    FlipSocialSubmenuExploreIndex, // click to go to the explore
-    FlipSocialSubmenuLoggedInIndexFeed, // click to go to the feed screen
+    FlipSocialSubmenuLoggedInIndexProfile,  // click to go to the profile screen
+    FlipSocialSubmenuExploreIndex,          // click to go to the explore
+    FlipSocialSubmenuLoggedInIndexFeed,     // click to go to the feed screen
     FlipSocialSubmenuLoggedInIndexMessages, // click to go to the messages screen
-    FlipSocialSubmenuLoggedInIndexCompose, // click to go to the compose screen
+    FlipSocialSubmenuLoggedInIndexCompose,  // click to go to the compose screen
     FlipSocialSubmenuLoggedInIndexSettings, // click to go to the settings screen
     FlipSocialSubmenuLoggedInSignOutButton, // click to sign out
     //
     FlipSocialSubmenuLoggedInIndexMessagesNewMessage, // click to add a new message
     //
-    FlipSocialSubmenuComposeIndexAddPreSave, // click to add a pre-saved message
-    FlipSocialSubemnuComposeIndexStartIndex =
-        100, // starting index for the first pre saved message
+    FlipSocialSubmenuComposeIndexAddPreSave,       // click to add a pre-saved message
+    FlipSocialSubemnuComposeIndexStartIndex = 100, // starting index for the first pre saved message
     //
     FlipSocialSubmenuExploreIndexStartIndex = 200, // starting index for the users to explore
     //
@@ -58,19 +57,20 @@ typedef enum {
     //
     FlipSocialSubmenuLoggedInIndexMessagesUsersStart = 600, // starting index for the messages
     //
-    FlipSocialSubmenuLoggedInIndexMessagesUserChoicesIndexStart =
-        800, // click to select a user to message
+    FlipSocialSubmenuLoggedInIndexMessagesUserChoicesIndexStart = 800, // click to select a user to message
 } FlipSocialSubmenuIndex;
 
 // Define the ScriptPlaylist structure
-typedef struct {
+typedef struct
+{
     char messages[MAX_PRE_SAVED_MESSAGES][MAX_MESSAGE_LENGTH];
     size_t count;
     size_t index;
 } PreSavedPlaylist;
 
 // Define a FlipSocialFeed individual item
-typedef struct {
+typedef struct
+{
     char username[MAX_USER_LENGTH];
     char message[MAX_MESSAGE_LENGTH];
     char date_created[MAX_LINE_LENGTH];
@@ -79,26 +79,30 @@ typedef struct {
     int flips;
 } FlipSocialFeedItem;
 
-typedef struct {
+typedef struct
+{
     int ids[MAX_FEED_ITEMS];
     size_t count;
     size_t index;
     int series_index;
 } FlipSocialFeedMini;
 
-typedef struct {
+typedef struct
+{
     char usernames[MAX_EXPLORE_USERS][MAX_USER_LENGTH];
     int count;
     int index;
 } FlipSocialModel;
 
-typedef struct {
+typedef struct
+{
     char usernames[MAX_MESSAGE_USERS][MAX_USER_LENGTH];
     int count;
     int index;
 } FlipSocialModel2;
 
-typedef struct {
+typedef struct
+{
     char usernames[MAX_MESSAGES][MAX_USER_LENGTH];
     char messages[MAX_MESSAGES][MAX_MESSAGE_LENGTH];
     int count;
@@ -106,60 +110,61 @@ typedef struct {
 } FlipSocialMessage;
 
 // Define views for our Hello World application
-typedef enum {
-    FlipSocialViewLoggedOutSubmenu, // The menu if the user is not logged in
-    FlipSocialViewLoggedOutLogin, // The login screen
-    FlipSocialViewLoggedOutRegister, // The register screen
-    FlipSocialViewLoggedOutAbout, // The about screen
+typedef enum
+{
+    FlipSocialViewLoggedOutSubmenu,      // The menu if the user is not logged in
+    FlipSocialViewLoggedOutLogin,        // The login screen
+    FlipSocialViewLoggedOutRegister,     // The register screen
+    FlipSocialViewLoggedOutAbout,        // The about screen
     FlipSocialViewLoggedOutWifiSettings, // The wifi settings screen
     //
-    FlipSocialViewLoggedOutLoginUsernameInput, // Text input screen for username input on login screen
-    FlipSocialViewLoggedOutLoginPasswordInput, // Text input screen for password input on login screen
-    FlipSocialViewLoggedOutRegisterUsernameInput, // Text input screen for username input on register screen
-    FlipSocialViewLoggedOutRegisterPasswordInput, // Text input screen for password input on register screen
-    FlipSocialViewLoggedOutRegisterPassword2Input, // Text input screen for password 2 input on register screen
-    FlipSocialViewLoggedOutWifiSettingsSSIDInput, // Text input screen for SSID input on wifi screen
+    FlipSocialViewLoggedOutLoginUsernameInput,        // Text input screen for username input on login screen
+    FlipSocialViewLoggedOutLoginPasswordInput,        // Text input screen for password input on login screen
+    FlipSocialViewLoggedOutRegisterUsernameInput,     // Text input screen for username input on register screen
+    FlipSocialViewLoggedOutRegisterPasswordInput,     // Text input screen for password input on register screen
+    FlipSocialViewLoggedOutRegisterPassword2Input,    // Text input screen for password 2 input on register screen
+    FlipSocialViewLoggedOutWifiSettingsSSIDInput,     // Text input screen for SSID input on wifi screen
     FlipSocialViewLoggedOutWifiSettingsPasswordInput, // Text input screen for Password input on wifi screen
-    FlipSocialViewLoggedOutProcessLogin, // The screen displayed after clicking login
-    FlipSocialViewLoggedOutProcessRegister, // The screen displayed after clicking register
+    FlipSocialViewLoggedOutProcessLogin,              // The screen displayed after clicking login
+    FlipSocialViewLoggedOutProcessRegister,           // The screen displayed after clicking register
     //
-    FlipSocialViewLoggedInSubmenu, // The menu if the user is logged in
-    FlipSocialViewLoggedInProfile, // The profile screen
-    FlipSocialViewLoggedInFeed, // The feed screen
-    FlipSocialViewLoggedInCompose, // The compose screen
+    FlipSocialViewLoggedInSubmenu,  // The menu if the user is logged in
+    FlipSocialViewLoggedInProfile,  // The profile screen
+    FlipSocialViewLoggedInFeed,     // The feed screen
+    FlipSocialViewLoggedInCompose,  // The compose screen
     FlipSocialViewLoggedInSettings, // The settings screen
     //
-    FlipSocialViewLoggedInChangeBioInput, // Text input screen for bio input on profile screen
-    FlipSocialViewLoggedInChangePasswordInput, // Text input screen for password input on change password screen
+    FlipSocialViewLoggedInChangeBioInput,         // Text input screen for bio input on profile screen
+    FlipSocialViewLoggedInChangePasswordInput,    // Text input screen for password input on change password screen
     FlipSocialViewLoggedInComposeAddPreSaveInput, // Text input screen for add text input on compose screen
     //
-    FlipSocialViewLoggedInMessagesNewMessageInput, // Text input screen for new message input on messages screen
+    FlipSocialViewLoggedInMessagesNewMessageInput,            // Text input screen for new message input on messages screen
     FlipSocialViewLoggedInMessagesNewMessageUserChoicesInput, // Text input screen for new message input on messages screen
-    FlipSocialViewLoggedInMessagesUserChoices, // the view after clicking [New Message] - select a user to message, then direct to input view
-    FlipSocialViewLoggedInExploreInput, // Text input screen for explore input on explore screen
+    FlipSocialViewLoggedInMessagesUserChoices,                // the view after clicking [New Message] - select a user to message, then direct to input view
+    FlipSocialViewLoggedInExploreInput,                       // Text input screen for explore input on explore screen
     FlipSocialViewLoggedInMessageUsersInput,
     //
-    FlipSocialViewLoggedInSettingsAbout, // The about screen
-    FlipSocialViewLoggedInSettingsWifi, // The wifi settings screen
-    FlipSocialViewLoggedInSettingsUser, // The user settings screen
-    FlipSocialViewLoggedInWifiSettingsSSIDInput, // Text input screen for SSID input on wifi screen
+    FlipSocialViewLoggedInSettingsAbout,             // The about screen
+    FlipSocialViewLoggedInSettingsWifi,              // The wifi settings screen
+    FlipSocialViewLoggedInSettingsUser,              // The user settings screen
+    FlipSocialViewLoggedInWifiSettingsSSIDInput,     // Text input screen for SSID input on wifi screen
     FlipSocialViewLoggedInWifiSettingsPasswordInput, // Text input screen for Password input on wifi screen
     //
     FlipSocialViewLoggedInSignOut, // The view after clicking the sign out button
     //
-    FlipSocialViewLoggedInExploreSubmenu, // The view after clicking the explore button
-    FlipSocialViewLoggedInFriendsSubmenu, // The view after clicking the friends button on the profile screen
+    FlipSocialViewLoggedInExploreSubmenu,  // The view after clicking the explore button
+    FlipSocialViewLoggedInFriendsSubmenu,  // The view after clicking the friends button on the profile screen
     FlipSocialViewLoggedInMessagesSubmenu, // The view after clicking the messages button on the profile screen
     //
     FlipSocialViewLoading, // The loading screen
     //
     FlipSocialViewWidgetResult, // The text box that displays the random fact
-    FlipSocialViewLoader, // The loader screen retrieves data from the internet
+    FlipSocialViewLoader,       // The loader screen retrieves data from the internet
     //
-    FlipSocialViewExploreDialog, // The dialog for the explore screen
-    FlipSocialViewFriendsDialog, // The dialog for the friends screen
+    FlipSocialViewExploreDialog,  // The dialog for the explore screen
+    FlipSocialViewFriendsDialog,  // The dialog for the friends screen
     FlipSocialViewMessagesDialog, // The dialog for the messages screen
-    FlipSocialViewComposeDialog, // The dialog for the compose screen
+    FlipSocialViewComposeDialog,  // The dialog for the compose screen
     //
     FlipSocialViewTextInput, // The text input screen
     FlipSocialViewVariableItemList,
@@ -168,172 +173,142 @@ typedef enum {
 } FlipSocialView;
 
 // Define the application structure
-typedef struct {
-    View* view_loader;
-    Widget* widget_result;
-    //
-    ViewDispatcher* view_dispatcher; // Switches between our views
-    Submenu* submenu_logged_out; // The application submenu (logged out)
-    Submenu* submenu_logged_in; // The application submenu (logged in)
-    //
-    Submenu* submenu;
-    //
-    Widget* widget_logged_out_about; // The about screen (logged out)
-    Widget* widget_logged_in_about; // The about screen (logged in)
-
-    VariableItemList* variable_item_list; // The main menu
-
-    TextInput* text_input; // The text input
-
-    VariableItem*
-        variable_item_logged_out_wifi_settings_ssid; // Reference to the ssid configuration item
-    VariableItem*
-        variable_item_logged_out_wifi_settings_password; // Reference to the password configuration item
-    VariableItem*
-        variable_item_logged_out_login_username; // Reference to the username configuration item
-    VariableItem*
-        variable_item_logged_out_login_password; // Reference to the password configuration item
-    VariableItem*
-        variable_item_logged_out_login_button; // Reference to the login button configuration item
-    VariableItem*
-        variable_item_logged_out_register_username; // Reference to the username configuration item
-    VariableItem*
-        variable_item_logged_out_register_password; // Reference to the password configuration item
-    VariableItem*
-        variable_item_logged_out_register_password_2; // Reference to the password 2 configuration item
-    VariableItem*
-        variable_item_logged_out_register_button; // Reference to the register button configuration item
-    //
-    VariableItem*
-        variable_item_logged_in_profile_username; // Reference to the username configuration item
-    VariableItem*
-        variable_item_logged_in_profile_change_password; // Reference to the change password configuration item
-    VariableItem*
-        variable_item_logged_in_profile_change_bio; // Reference to the change bio configuration item
-    //
-    VariableItem*
-        variable_item_logged_in_settings_about; // Reference to the about configuration item
-    VariableItem*
-        variable_item_logged_in_settings_wifi; // Reference to the wifi settings configuration item
-    VariableItem*
-        variable_item_logged_in_settings_user; // Reference to the user settings configuration item
-    VariableItem*
-        variable_item_logged_in_user_settings_feed_type; // Reference to the feed type configuration item
-    VariableItem*
-        variable_item_logged_in_user_settings_notifications; // Reference to the notifications configuration item
-    VariableItem*
-        variable_item_logged_in_wifi_settings_ssid; // Reference to the ssid configuration item
-    VariableItem*
-        variable_item_logged_in_wifi_settings_password; // Reference to the password configuration item
-    //
-    VariableItem*
-        variable_item_logged_in_profile_friends; // Reference to the friends configuration item
+typedef struct
+{
+    View *view_loader;
+    Widget *widget_result;
+    //
+    ViewDispatcher *view_dispatcher; // Switches between our views
+    Submenu *submenu_logged_out;     // The application submenu (logged out)
+    Submenu *submenu_logged_in;      // The application submenu (logged in)
+    //
+    Submenu *submenu;
+    //
+    Widget *widget_logged_out_about; // The about screen (logged out)
+    Widget *widget_logged_in_about;  // The about screen (logged in)
+
+    VariableItemList *variable_item_list; // The main menu
+
+    TextInput *text_input; // The text input
+
+    VariableItem *variable_item_logged_out_wifi_settings_ssid;     // Reference to the ssid configuration item
+    VariableItem *variable_item_logged_out_wifi_settings_password; // Reference to the password configuration item
+    VariableItem *variable_item_logged_out_login_username;         // Reference to the username configuration item
+    VariableItem *variable_item_logged_out_login_password;         // Reference to the password configuration item
+    VariableItem *variable_item_logged_out_login_button;           // Reference to the login button configuration item
+    VariableItem *variable_item_logged_out_register_username;      // Reference to the username configuration item
+    VariableItem *variable_item_logged_out_register_password;      // Reference to the password configuration item
+    VariableItem *variable_item_logged_out_register_password_2;    // Reference to the password 2 configuration item
+    VariableItem *variable_item_logged_out_register_button;        // Reference to the register button configuration item
+    //
+    VariableItem *variable_item_logged_in_profile_username;        // Reference to the username configuration item
+    VariableItem *variable_item_logged_in_profile_change_password; // Reference to the change password configuration item
+    VariableItem *variable_item_logged_in_profile_change_bio;      // Reference to the change bio configuration item
+    //
+    VariableItem *variable_item_logged_in_settings_about;              // Reference to the about configuration item
+    VariableItem *variable_item_logged_in_settings_wifi;               // Reference to the wifi settings configuration item
+    VariableItem *variable_item_logged_in_settings_user;               // Reference to the user settings configuration item
+    VariableItem *variable_item_logged_in_user_settings_feed_type;     // Reference to the feed type configuration item
+    VariableItem *variable_item_logged_in_user_settings_notifications; // Reference to the notifications configuration item
+    VariableItem *variable_item_logged_in_wifi_settings_ssid;          // Reference to the ssid configuration item
+    VariableItem *variable_item_logged_in_wifi_settings_password;      // Reference to the password configuration item
+    //
+    VariableItem *variable_item_logged_in_profile_friends; // Reference to the friends configuration item
     //
     PreSavedPlaylist pre_saved_messages; // Pre-saved messages for the feed screen
 
-    char* is_logged_in; // Store the login status
+    char *is_logged_in;         // Store the login status
     uint32_t is_logged_in_size; // Size of the login status buffer
 
-    char* login_username_logged_in; // Store the entered login username
-    char* login_username_logged_in_temp_buffer; // Temporary buffer for login username text input
-    uint32_t
-        login_username_logged_in_temp_buffer_size; // Size of the login username temporary buffer
+    char *login_username_logged_in;                     // Store the entered login username
+    char *login_username_logged_in_temp_buffer;         // Temporary buffer for login username text input
+    uint32_t login_username_logged_in_temp_buffer_size; // Size of the login username temporary buffer
 
-    char* change_bio_logged_in; // Store the entered bio
-    char* change_bio_logged_in_temp_buffer; // Temporary buffer for bio text input
+    char *change_bio_logged_in;                     // Store the entered bio
+    char *change_bio_logged_in_temp_buffer;         // Temporary buffer for bio text input
     uint32_t change_bio_logged_in_temp_buffer_size; // Size of the bio temporary buffer
     //
-    char* wifi_ssid_logged_out; // Store the entered wifi ssid
-    char* wifi_ssid_logged_out_temp_buffer; // Temporary buffer for wifi ssid text input
+    char *wifi_ssid_logged_out;                     // Store the entered wifi ssid
+    char *wifi_ssid_logged_out_temp_buffer;         // Temporary buffer for wifi ssid text input
     uint32_t wifi_ssid_logged_out_temp_buffer_size; // Size of the wifi ssid temporary buffer
 
-    char* wifi_password_logged_out; // Store the entered wifi password
-    char* wifi_password_logged_out_temp_buffer; // Temporary buffer for wifi_password text input
+    char *wifi_password_logged_out;                     // Store the entered wifi password
+    char *wifi_password_logged_out_temp_buffer;         // Temporary buffer for wifi_password text input
     uint32_t wifi_password_logged_out_temp_buffer_size; // Size of the wifi_password temporary buffer
 
-    char* login_username_logged_out; // Store the entered login username
-    char* login_username_logged_out_temp_buffer; // Temporary buffer for login username text input
-    uint32_t
-        login_username_logged_out_temp_buffer_size; // Size of the login username temporary buffer
+    char *login_username_logged_out;                     // Store the entered login username
+    char *login_username_logged_out_temp_buffer;         // Temporary buffer for login username text input
+    uint32_t login_username_logged_out_temp_buffer_size; // Size of the login username temporary buffer
 
-    char* login_password_logged_out; // Store the entered login password
-    char* login_password_logged_out_temp_buffer; // Temporary buffer for login password text input
-    uint32_t
-        login_password_logged_out_temp_buffer_size; // Size of the login password temporary buffer
+    char *login_password_logged_out;                     // Store the entered login password
+    char *login_password_logged_out_temp_buffer;         // Temporary buffer for login password text input
+    uint32_t login_password_logged_out_temp_buffer_size; // Size of the login password temporary buffer
 
-    char* register_username_logged_out; // Store the entered register username
-    char* register_username_logged_out_temp_buffer; // Temporary buffer for register username text input
-    uint32_t
-        register_username_logged_out_temp_buffer_size; // Size of the register username temporary buffer
+    char *register_username_logged_out;                     // Store the entered register username
+    char *register_username_logged_out_temp_buffer;         // Temporary buffer for register username text input
+    uint32_t register_username_logged_out_temp_buffer_size; // Size of the register username temporary buffer
 
-    char* register_password_logged_out; // Store the entered register password
-    char* register_password_logged_out_temp_buffer; // Temporary buffer for register password text input
-    uint32_t
-        register_password_logged_out_temp_buffer_size; // Size of the register password temporary buffer
+    char *register_password_logged_out;                     // Store the entered register password
+    char *register_password_logged_out_temp_buffer;         // Temporary buffer for register password text input
+    uint32_t register_password_logged_out_temp_buffer_size; // Size of the register password temporary buffer
 
-    char* register_password_2_logged_out; // Store the entered register password 2
-    char* register_password_2_logged_out_temp_buffer; // Temporary buffer for register password 2 text input
-    uint32_t
-        register_password_2_logged_out_temp_buffer_size; // Size of the register password 2 temporary buffer
+    char *register_password_2_logged_out;                     // Store the entered register password 2
+    char *register_password_2_logged_out_temp_buffer;         // Temporary buffer for register password 2 text input
+    uint32_t register_password_2_logged_out_temp_buffer_size; // Size of the register password 2 temporary buffer
 
     //
-    char* change_password_logged_in; // Store the entered change password
-    char* change_password_logged_in_temp_buffer; // Temporary buffer for change password text input
-    uint32_t
-        change_password_logged_in_temp_buffer_size; // Size of the change password temporary buffer
+    char *change_password_logged_in;                     // Store the entered change password
+    char *change_password_logged_in_temp_buffer;         // Temporary buffer for change password text input
+    uint32_t change_password_logged_in_temp_buffer_size; // Size of the change password temporary buffer
 
-    char* compose_pre_save_logged_in; // Store the entered add text
-    char* compose_pre_save_logged_in_temp_buffer; // Temporary buffer for add text text input
+    char *compose_pre_save_logged_in;                     // Store the entered add text
+    char *compose_pre_save_logged_in_temp_buffer;         // Temporary buffer for add text text input
     uint32_t compose_pre_save_logged_in_temp_buffer_size; // Size of the add text temporary buffer
 
-    char* wifi_ssid_logged_in; // Store the entered wifi ssid
-    char* wifi_ssid_logged_in_temp_buffer; // Temporary buffer for wifi ssid text input
+    char *wifi_ssid_logged_in;                     // Store the entered wifi ssid
+    char *wifi_ssid_logged_in_temp_buffer;         // Temporary buffer for wifi ssid text input
     uint32_t wifi_ssid_logged_in_temp_buffer_size; // Size of the wifi ssid temporary buffer
 
-    char* wifi_password_logged_in; // Store the entered wifi password
-    char* wifi_password_logged_in_temp_buffer; // Temporary buffer for wifi_password text input
+    char *wifi_password_logged_in;                     // Store the entered wifi password
+    char *wifi_password_logged_in_temp_buffer;         // Temporary buffer for wifi_password text input
     uint32_t wifi_password_logged_in_temp_buffer_size; // Size of the wifi_password temporary buffer
 
     //
-    char* messages_new_message_logged_in; // Store the entered new message
-    char* messages_new_message_logged_in_temp_buffer; // Temporary buffer for new message text input
-    uint32_t
-        messages_new_message_logged_in_temp_buffer_size; // Size of the new message temporary buffer
+    char *messages_new_message_logged_in;                     // Store the entered new message
+    char *messages_new_message_logged_in_temp_buffer;         // Temporary buffer for new message text input
+    uint32_t messages_new_message_logged_in_temp_buffer_size; // Size of the new message temporary buffer
 
-    char* message_user_choice_logged_in; // Store the entered message to send to the selected user
-    char* message_user_choice_logged_in_temp_buffer; // Temporary buffer for message to send to the selected user
-    uint32_t
-        message_user_choice_logged_in_temp_buffer_size; // Size of the message to send to the selected user temporary buffer
+    char *message_user_choice_logged_in;                     // Store the entered message to send to the selected user
+    char *message_user_choice_logged_in_temp_buffer;         // Temporary buffer for message to send to the selected user
+    uint32_t message_user_choice_logged_in_temp_buffer_size; // Size of the message to send to the selected user temporary buffer
     //
-    char* explore_logged_in; // Store the entered explore
-    char* explore_logged_in_temp_buffer; // Temporary buffer for explore text input
+    char *explore_logged_in;                     // Store the entered explore
+    char *explore_logged_in_temp_buffer;         // Temporary buffer for explore text input
     uint32_t explore_logged_in_temp_buffer_size; // Size of the explore temporary buffer
 
-    char* message_users_logged_in; // Store the entered message users
-    char* message_users_logged_in_temp_buffer; // Temporary buffer for message users text input
+    char *message_users_logged_in;                     // Store the entered message users
+    char *message_users_logged_in_temp_buffer;         // Temporary buffer for message users text input
     uint32_t message_users_logged_in_temp_buffer_size; // Size of the message users temporary buffer
 
-    DialogEx* dialog_explore;
-    DialogEx* dialog_friends;
-    DialogEx* dialog_messages;
-    DialogEx* dialog_compose;
+    DialogEx *dialog_explore;
+    DialogEx *dialog_friends;
+    DialogEx *dialog_messages;
+    DialogEx *dialog_compose;
 
-    View* view_feed;
+    View *view_feed;
 
-    char* explore_user_bio; // Store the bio of the selected user
+    char *explore_user_bio; // Store the bio of the selected user
 } FlipSocialApp;
 
-void flip_social_app_free(FlipSocialApp* app);
+void flip_social_app_free(FlipSocialApp *app);
 
-extern FlipSocialModel* flip_social_friends; // Store the friends
-extern FlipSocialModel2*
-    flip_social_message_users; // Store the users that have sent messages to the logged in user
-extern FlipSocialModel* flip_social_explore; // Store the users to explore
-extern FlipSocialMessage*
-    flip_social_messages; // Store the messages between the logged in user and the selected user
-extern FlipSocialFeedMini* flip_feed_info; // Store the feed info
-extern FlipSocialFeedItem* flip_feed_item; // Store a feed item
-extern FlipSocialApp* app_instance;
+extern FlipSocialModel *flip_social_friends;        // Store the friends
+extern FlipSocialModel2 *flip_social_message_users; // Store the users that have sent messages to the logged in user
+extern FlipSocialModel *flip_social_explore;        // Store the users to explore
+extern FlipSocialMessage *flip_social_messages;     // Store the messages between the logged in user and the selected user
+extern FlipSocialFeedMini *flip_feed_info;          // Store the feed info
+extern FlipSocialFeedItem *flip_feed_item;          // Store a feed item
+extern FlipSocialApp *app_instance;
 
 extern bool flip_social_sent_login_request;
 extern bool flip_social_sent_register_request;
@@ -342,12 +317,12 @@ extern bool flip_social_register_success;
 extern bool flip_social_dialog_shown;
 extern bool flip_social_dialog_stop;
 extern bool flip_social_send_message;
-extern char* selected_message;
+extern char *selected_message;
 extern char auth_headers[256];
 //
-extern char* flip_social_feed_type[];
+extern char *flip_social_feed_type[];
 extern uint8_t flip_social_feed_type_index;
 //
-extern char* flip_social_notification_type[];
+extern char *flip_social_notification_type[];
 extern uint8_t flip_social_notification_type_index;
-#endif
+#endif

+ 4 - 4
flip_store/callback/flip_store_callback.c

@@ -389,14 +389,14 @@ static void flip_store_text_updated_author(void *context)
     save_char("Github-Author", app->uart_text_input_buffer);
 
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSubmenu);
-    uart_text_input_reset(app->uart_text_input);
-    uart_text_input_set_header_text(app->uart_text_input, "Repository");
+    text_input_reset(app->uart_text_input);
+    text_input_set_header_text(app->uart_text_input, "Repository");
     app->uart_text_input_buffer_size = 64;
     free(app->uart_text_input_buffer);
     free(app->uart_text_input_temp_buffer);
     easy_flipper_set_buffer(&app->uart_text_input_buffer, app->uart_text_input_buffer_size);
     easy_flipper_set_buffer(&app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-    uart_text_input_set_result_callback(app->uart_text_input, flip_store_text_updated_repo, app, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size, false);
+    text_input_set_result_callback(app->uart_text_input, flip_store_text_updated_repo, app, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size, false);
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewTextInput);
 }
 
@@ -707,7 +707,7 @@ static void free_text_input_view(FlipStoreApp *app)
     if (app->uart_text_input)
     {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewTextInput);
-        uart_text_input_free(app->uart_text_input);
+        text_input_free(app->uart_text_input);
         app->uart_text_input = NULL;
     }
     if (app->uart_text_input_buffer)

+ 23 - 12
flip_store/flip_store.c

@@ -2,43 +2,52 @@
 #include <apps/flip_store_apps.h>
 
 // Function to free the resources used by FlipStoreApp
-void flip_store_app_free(FlipStoreApp* app) {
-    if(!app) {
+void flip_store_app_free(FlipStoreApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipStoreApp is NULL");
         return;
     }
 
     // Free Widget(s)
-    if(app->widget_result) {
+    if (app->widget_result)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewWidgetResult);
         widget_free(app->widget_result);
     }
 
     // Free View(s)
-    if(app->view_loader) {
+    if (app->view_loader)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewLoader);
         flip_store_loader_free_model(app->view_loader);
         view_free(app->view_loader);
     }
 
     // Free Submenu(s)
-    if(app->submenu_main) {
+    if (app->submenu_main)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSubmenu);
         submenu_free(app->submenu_main);
     }
-    if(app->submenu_options) {
+    if (app->submenu_options)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSubmenuOptions);
         submenu_free(app->submenu_options);
     }
-    if(app->submenu_app_list) {
+    if (app->submenu_app_list)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAppList);
         submenu_free(app->submenu_app_list);
     }
-    if(app->submenu_firmwares) {
+    if (app->submenu_firmwares)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewFirmwares);
         submenu_free(app->submenu_firmwares);
     }
-    if(app->submenu_vgm_firmwares) {
+    if (app->submenu_vgm_firmwares)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewVGMFirmwares);
         submenu_free(app->submenu_vgm_firmwares);
     }
@@ -46,11 +55,13 @@ void flip_store_app_free(FlipStoreApp* app) {
     free_all_views(app, true);
 
     // free the view dispatcher
-    if(app->view_dispatcher) view_dispatcher_free(app->view_dispatcher);
+    if (app->view_dispatcher)
+        view_dispatcher_free(app->view_dispatcher);
 
     // close the gui
     furi_record_close(RECORD_GUI);
 
     // free the app
-    if(app) free(app);
-}
+    if (app)
+        free(app);
+}

+ 52 - 49
flip_store/flip_store.h

@@ -14,7 +14,7 @@
 #include <jsmn/jsmn_furi.h>
 #include <flip_store_icons.h>
 
-#define TAG         "FlipStore"
+#define TAG "FlipStore"
 #define VERSION_TAG "FlipStore v0.8"
 
 #define FIRMWARE_COUNT 3
@@ -26,17 +26,18 @@
 #define MAX_GITHUB_FILES 30
 
 // Define the submenu items for our FlipStore application
-typedef enum {
+typedef enum
+{
     FlipStoreSubmenuIndexMain, // Click to start downloading the selected app
     FlipStoreSubmenuIndexAbout,
     FlipStoreSubmenuIndexSettings,
     //
     FlipStoreSubmenuIndexOptions, // Click to view the options
     //
-    FlipStoreSubmenuIndexAppList, // Click to view the app list
-    FlipStoreSubmenuIndexFirmwares, // Click to view the ESP32 firmwares
+    FlipStoreSubmenuIndexAppList,      // Click to view the app list
+    FlipStoreSubmenuIndexFirmwares,    // Click to view the ESP32 firmwares
     FlipStoreSubmenuIndexVGMFirmwares, // Click to view the VGM firmwares
-    FlipStoreSubmenuIndexGitHub, // Click to view the GitHub repository view
+    FlipStoreSubmenuIndexGitHub,       // Click to view the GitHub repository view
     //
     FlipStoreSubmenuIndexAppListBluetooth,
     FlipStoreSubmenuIndexAppListGames,
@@ -57,61 +58,63 @@ typedef enum {
 } FlipStoreSubmenuIndex;
 
 // Define a single view for our FlipStore application
-typedef enum {
+typedef enum
+{
     //
-    FlipStoreViewSubmenu, // The submenu
-    FlipStoreViewSubmenuOptions, // The submenu options
-        //
-    FlipStoreViewAbout, // The about screen
-    FlipStoreViewSettings, // The settings screen
-    FlipStoreViewTextInput, // The text input screen
-        //
-    FlipStoreViewAppList, // The app list screen
-    FlipStoreViewFirmwares, // The firmwares screen (submenu)
-    FlipStoreViewVGMFirmwares, // The VGM firmwares screen (submenu)
-    FlipStoreViewAGithub, // The GitHub repository screen
-        //
-    FlipStoreViewFirmwareDialog, // The firmware view (DialogEx) of the selected firmware
-        //
-    FlipStoreViewAppInfo, // The app info screen (widget) of the selected app
-    FlipStoreViewAppDownload, // The app download screen (widget) of the selected app
-    FlipStoreViewAppDelete, // The app delete screen (DialogEx) of the selected app
-        //
+    FlipStoreViewSubmenu,         // The submenu
+    FlipStoreViewSubmenuOptions,  // The submenu options
+                                  //
+    FlipStoreViewAbout,           // The about screen
+    FlipStoreViewSettings,        // The settings screen
+    FlipStoreViewTextInput,       // The text input screen
+                                  //
+    FlipStoreViewAppList,         // The app list screen
+    FlipStoreViewFirmwares,       // The firmwares screen (submenu)
+    FlipStoreViewVGMFirmwares,    // The VGM firmwares screen (submenu)
+    FlipStoreViewAGithub,         // The GitHub repository screen
+                                  //
+    FlipStoreViewFirmwareDialog,  // The firmware view (DialogEx) of the selected firmware
+                                  //
+    FlipStoreViewAppInfo,         // The app info screen (widget) of the selected app
+    FlipStoreViewAppDownload,     // The app download screen (widget) of the selected app
+    FlipStoreViewAppDelete,       // The app delete screen (DialogEx) of the selected app
+                                  //
     FlipStoreViewAppListCategory, // the app list screen for each category
-        //
-        //
-    FlipStoreViewWidgetResult, // The text box that displays the random fact
-    FlipStoreViewLoader, // The loader screen retrieves data from the internet
+                                  //
+                                  //
+    FlipStoreViewWidgetResult,    // The text box that displays the random fact
+    FlipStoreViewLoader,          // The loader screen retrieves data from the internet
 } FlipStoreView;
 
 // Each screen will have its own view
-typedef struct {
-    View* view_loader;
-    Widget* widget_result;
+typedef struct
+{
+    View *view_loader;
+    Widget *widget_result;
     //
-    ViewDispatcher* view_dispatcher; // Switches between our views
-    View* view_app_info; // The app info screen (view) of the selected app
+    ViewDispatcher *view_dispatcher; // Switches between our views
+    View *view_app_info;             // The app info screen (view) of the selected app
     //
-    DialogEx* dialog_firmware; // The dialog for installing a firmware
+    DialogEx *dialog_firmware; // The dialog for installing a firmware
     //
-    Submenu* submenu_main; // The submenu (main)
+    Submenu *submenu_main; // The submenu (main)
     //
-    Submenu* submenu_options; // The submenu (options)
-    Submenu* submenu_app_list; // The submenu (app list) for the selected category
-    Submenu* submenu_firmwares; // The submenu (firmwares)
-    Submenu* submenu_vgm_firmwares; // The submenu (VGM firmwares)
-    Submenu* submenu_app_list_category; // The submenu (app list) for each category
-    Widget* widget_about; // The widget
-    VariableItemList* variable_item_list; // The variable item list (settngs)
-    VariableItem* variable_item_ssid; // The variable item
-    VariableItem* variable_item_pass; // The variable item
+    Submenu *submenu_options;             // The submenu (options)
+    Submenu *submenu_app_list;            // The submenu (app list) for the selected category
+    Submenu *submenu_firmwares;           // The submenu (firmwares)
+    Submenu *submenu_vgm_firmwares;       // The submenu (VGM firmwares)
+    Submenu *submenu_app_list_category;   // The submenu (app list) for each category
+    Widget *widget_about;                 // The widget
+    VariableItemList *variable_item_list; // The variable item list (settngs)
+    VariableItem *variable_item_ssid;     // The variable item
+    VariableItem *variable_item_pass;     // The variable item
     //
-    TextInput* uart_text_input; // The text input
-    char* uart_text_input_buffer; // Buffer for the text input
-    char* uart_text_input_temp_buffer; // Temporary buffer for the text input
+    TextInput *uart_text_input;      // The text input
+    char *uart_text_input_buffer;         // Buffer for the text input
+    char *uart_text_input_temp_buffer;    // Temporary buffer for the text input
     uint32_t uart_text_input_buffer_size; // Size of the text input buffer
 } FlipStoreApp;
 
-void flip_store_app_free(FlipStoreApp* app);
+void flip_store_app_free(FlipStoreApp *app);
 
-#endif // FLIP_STORE_E_H
+#endif // FLIP_STORE_E_H

+ 56 - 116
flip_trader/alloc/flip_trader_alloc.c

@@ -1,13 +1,15 @@
 #include "alloc/flip_trader_alloc.h"
 
 // Function to allocate resources for the FlipTraderApp
-FlipTraderApp* flip_trader_app_alloc() {
-    FlipTraderApp* app = (FlipTraderApp*)malloc(sizeof(FlipTraderApp));
+FlipTraderApp *flip_trader_app_alloc()
+{
+    FlipTraderApp *app = (FlipTraderApp *)malloc(sizeof(FlipTraderApp));
 
-    Gui* gui = furi_record_open(RECORD_GUI);
+    Gui *gui = furi_record_open(RECORD_GUI);
 
     // initialize uart
-    if(!flipper_http_init(flipper_http_rx_callback, app)) {
+    if (!flipper_http_init(flipper_http_rx_callback, app))
+    {
         FURI_LOG_E(TAG, "Failed to initialize flipper http");
         return NULL;
     }
@@ -15,170 +17,108 @@ FlipTraderApp* flip_trader_app_alloc() {
     // Allocate the text input buffer
     app->uart_text_input_buffer_size_ssid = 64;
     app->uart_text_input_buffer_size_password = 64;
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_temp_buffer_password,
-           app->uart_text_input_buffer_size_password)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_size_password))
+    {
         return NULL;
     }
 
     asset_names = asset_names_alloc();
-    if(!asset_names) {
+    if (!asset_names)
+    {
         return NULL;
     }
 
     // Allocate ViewDispatcher
-    if(!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app)) {
+    if (!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app))
+    {
         return NULL;
     }
-    view_dispatcher_set_custom_event_callback(
-        app->view_dispatcher, flip_trader_custom_event_callback);
+    view_dispatcher_set_custom_event_callback(app->view_dispatcher, flip_trader_custom_event_callback);
     // Main view
-    if(!easy_flipper_set_view(
-           &app->view_loader,
-           FlipTraderViewLoader,
-           flip_trader_loader_draw_callback,
-           NULL,
-           callback_to_assets_submenu,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_view(&app->view_loader, FlipTraderViewLoader, flip_trader_loader_draw_callback, NULL, callback_to_assets_submenu, &app->view_dispatcher, app))
+    {
         return NULL;
     }
     flip_trader_loader_init(app->view_loader);
 
     // Widget
-    if(!easy_flipper_set_widget(
-           &app->widget_about,
-           FlipTraderViewAbout,
-           "FlipTrader v1.2\n-----\nUse WiFi to get the price of\nstocks and currency pairs.\n-----\nwww.github.com/jblanked",
-           callback_to_submenu,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_about, FlipTraderViewAbout, "FlipTrader v1.2\n-----\nUse WiFi to get the price of\nstocks and currency pairs.\n-----\nwww.github.com/jblanked", callback_to_submenu, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_widget(
-           &app->widget_result,
-           FlipTraderViewWidgetResult,
-           "Error, try again.",
-           callback_to_assets_submenu,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_result, FlipTraderViewWidgetResult, "Error, try again.", callback_to_assets_submenu, &app->view_dispatcher))
+    {
         return NULL;
     }
 
     // Text Input
-    if(!easy_flipper_set_uart_text_input(
-           &app->uart_text_input_ssid,
-           FlipTraderViewTextInputSSID,
-           "Enter SSID",
-           app->uart_text_input_temp_buffer_ssid,
-           app->uart_text_input_buffer_size_ssid,
-           text_updated_ssid,
-           callback_to_wifi_settings,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_uart_text_input(&app->uart_text_input_ssid, FlipTraderViewTextInputSSID, "Enter SSID", app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid, text_updated_ssid, callback_to_wifi_settings, &app->view_dispatcher, app))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_uart_text_input(
-           &app->uart_text_input_password,
-           FlipTraderViewTextInputPassword,
-           "Enter password",
-           app->uart_text_input_temp_buffer_password,
-           app->uart_text_input_buffer_size_password,
-           text_updated_password,
-           callback_to_wifi_settings,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_uart_text_input(&app->uart_text_input_password, FlipTraderViewTextInputPassword, "Enter password", app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_size_password, text_updated_password, callback_to_wifi_settings, &app->view_dispatcher, app))
+    {
         return NULL;
     }
 
     // Variable Item List
-    if(!easy_flipper_set_variable_item_list(
-           &app->variable_item_list_wifi,
-           FlipTraderViewWiFiSettings,
-           settings_item_selected,
-           callback_to_submenu,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_variable_item_list(&app->variable_item_list_wifi, FlipTraderViewWiFiSettings, settings_item_selected, callback_to_submenu, &app->view_dispatcher, app))
+    {
         return NULL;
     }
-    app->variable_item_ssid =
-        variable_item_list_add(app->variable_item_list_wifi, "SSID", 0, NULL, NULL);
-    app->variable_item_password =
-        variable_item_list_add(app->variable_item_list_wifi, "Password", 0, NULL, NULL);
+    app->variable_item_ssid = variable_item_list_add(app->variable_item_list_wifi, "SSID", 0, NULL, NULL);
+    app->variable_item_password = variable_item_list_add(app->variable_item_list_wifi, "Password", 0, NULL, NULL);
     variable_item_set_current_value_text(app->variable_item_ssid, "");
     variable_item_set_current_value_text(app->variable_item_password, "");
 
     // Submenu
-    if(!easy_flipper_set_submenu(
-           &app->submenu_main,
-           FlipTraderViewMainSubmenu,
-           "FlipTrader v1.2",
-           easy_flipper_callback_exit_app,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_submenu(&app->submenu_main, FlipTraderViewMainSubmenu, "FlipTrader v1.2", easy_flipper_callback_exit_app, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_submenu(
-           &app->submenu_assets,
-           FlipTraderViewAssetsSubmenu,
-           "Assets",
-           callback_to_submenu,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_submenu(&app->submenu_assets, FlipTraderViewAssetsSubmenu, "Assets", callback_to_submenu, &app->view_dispatcher))
+    {
         return NULL;
     }
-    submenu_add_item(
-        app->submenu_main, "Assets", FlipTradeSubmenuIndexAssets, callback_submenu_choices, app);
-    submenu_add_item(
-        app->submenu_main, "About", FlipTraderSubmenuIndexAbout, callback_submenu_choices, app);
-    submenu_add_item(
-        app->submenu_main, "WiFi", FlipTraderSubmenuIndexSettings, callback_submenu_choices, app);
+    submenu_add_item(app->submenu_main, "Assets", FlipTradeSubmenuIndexAssets, callback_submenu_choices, app);
+    submenu_add_item(app->submenu_main, "About", FlipTraderSubmenuIndexAbout, callback_submenu_choices, app);
+    submenu_add_item(app->submenu_main, "WiFi", FlipTraderSubmenuIndexSettings, callback_submenu_choices, app);
     // add the assets
-    for(uint32_t i = 0; i < ASSET_COUNT; i++) {
-        submenu_add_item(
-            app->submenu_assets,
-            asset_names[i],
-            FlipTraderSubmenuIndexAssetStartIndex + i,
-            callback_submenu_choices,
-            app);
+    for (uint32_t i = 0; i < ASSET_COUNT; i++)
+    {
+        submenu_add_item(app->submenu_assets, asset_names[i], FlipTraderSubmenuIndexAssetStartIndex + i, callback_submenu_choices, app);
     }
 
     // load settings
-    if(load_settings(
-           app->uart_text_input_buffer_ssid,
-           app->uart_text_input_buffer_size_ssid,
-           app->uart_text_input_buffer_password,
-           app->uart_text_input_buffer_size_password)) {
+    if (load_settings(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid, app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password))
+    {
         // Update variable items
-        if(app->variable_item_ssid)
-            variable_item_set_current_value_text(
-                app->variable_item_ssid, app->uart_text_input_buffer_ssid);
+        if (app->variable_item_ssid)
+            variable_item_set_current_value_text(app->variable_item_ssid, app->uart_text_input_buffer_ssid);
         // dont show password
 
         // Copy items into their temp buffers with safety checks
-        if(app->uart_text_input_buffer_ssid && app->uart_text_input_temp_buffer_ssid) {
-            strncpy(
-                app->uart_text_input_temp_buffer_ssid,
-                app->uart_text_input_buffer_ssid,
-                app->uart_text_input_buffer_size_ssid - 1);
-            app->uart_text_input_temp_buffer_ssid[app->uart_text_input_buffer_size_ssid - 1] =
-                '\0';
+        if (app->uart_text_input_buffer_ssid && app->uart_text_input_temp_buffer_ssid)
+        {
+            strncpy(app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid - 1);
+            app->uart_text_input_temp_buffer_ssid[app->uart_text_input_buffer_size_ssid - 1] = '\0';
         }
-        if(app->uart_text_input_buffer_password && app->uart_text_input_temp_buffer_password) {
-            strncpy(
-                app->uart_text_input_temp_buffer_password,
-                app->uart_text_input_buffer_password,
-                app->uart_text_input_buffer_size_password - 1);
-            app->uart_text_input_temp_buffer_password[app->uart_text_input_buffer_size_password - 1] =
-                '\0';
+        if (app->uart_text_input_buffer_password && app->uart_text_input_temp_buffer_password)
+        {
+            strncpy(app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password - 1);
+            app->uart_text_input_temp_buffer_password[app->uart_text_input_buffer_size_password - 1] = '\0';
         }
     }
 
@@ -186,4 +126,4 @@ FlipTraderApp* flip_trader_app_alloc() {
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipTraderViewMainSubmenu);
 
     return app;
-}
+}

+ 2 - 2
flip_trader/alloc/flip_trader_alloc.h

@@ -5,6 +5,6 @@
 #include <callback/flip_trader_callback.h>
 
 // Function to allocate resources for the FlipTraderApp
-FlipTraderApp* flip_trader_app_alloc();
+FlipTraderApp *flip_trader_app_alloc();
 
-#endif // FLIP_TRADER_I_H
+#endif // FLIP_TRADER_I_H

+ 15 - 9
flip_trader/app.c

@@ -2,34 +2,40 @@
 #include <alloc/flip_trader_alloc.h>
 
 // Entry point for the FlipTrader application
-int32_t flip_trader_app(void* p) {
+int32_t flip_trader_app(void *p)
+{
     // Suppress unused parameter warning
     UNUSED(p);
 
     // Initialize the FlipTrader application
     app_instance = flip_trader_app_alloc();
-    if(!app_instance) {
+    if (!app_instance)
+    {
         FURI_LOG_E(TAG, "Failed to allocate FlipTraderApp");
         return -1;
     }
 
-    if(!flipper_http_ping()) {
+    if (!flipper_http_ping())
+    {
         FURI_LOG_E(TAG, "Failed to ping the device");
         return -1;
     }
 
-    if(app_instance->uart_text_input_buffer_ssid != NULL &&
-       app_instance->uart_text_input_buffer_password != NULL) {
+    if (app_instance->uart_text_input_buffer_ssid != NULL &&
+        app_instance->uart_text_input_buffer_password != NULL)
+    {
         // Try to wait for pong response.
         uint8_t counter = 10;
-        while(fhttp.state == INACTIVE && --counter > 0) {
+        while (fhttp.state == INACTIVE && --counter > 0)
+        {
             FURI_LOG_D(TAG, "Waiting for PONG");
             furi_delay_ms(100);
         }
 
-        if(counter == 0) {
-            DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
-            DialogMessage* message = dialog_message_alloc();
+        if (counter == 0)
+        {
+            DialogsApp *dialogs = furi_record_open(RECORD_DIALOGS);
+            DialogMessage *message = dialog_message_alloc();
             dialog_message_set_header(
                 message, "[FlipperHTTP Error]", 64, 0, AlignCenter, AlignTop);
             dialog_message_set_text(

+ 1 - 1
flip_trader/application.fam

@@ -10,5 +10,5 @@ App(
     fap_description="Use WiFi to get the price of stocks and currency pairs on your Flipper Zero.",
     fap_author="JBlanked",
     fap_weburl="https://github.com/jblanked/FlipTrader",
-    fap_version="1.2",
+    fap_version = "1.2",
 )

+ 275 - 207
flip_trader/callback/flip_trader_callback.c

@@ -3,8 +3,7 @@
 // Below added by Derek Jamison
 // FURI_LOG_DEV will log only during app development. Be sure that Settings/System/Log Device is "LPUART"; so we dont use serial port.
 #ifdef DEVELOPMENT
-#define FURI_LOG_DEV(tag, format, ...) \
-    furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
+#define FURI_LOG_DEV(tag, format, ...) furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
 #define DEV_CRASH() furi_crash()
 #else
 #define FURI_LOG_DEV(tag, format, ...)
@@ -17,35 +16,46 @@ bool sent_get_request = false;
 bool get_request_success = false;
 bool request_processed = false;
 
-static void flip_trader_request_error_draw(Canvas* canvas) {
-    if(canvas == NULL) {
+static void flip_trader_request_error_draw(Canvas *canvas)
+{
+    if (canvas == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_request_error_draw - canvas is NULL");
         DEV_CRASH();
         return;
     }
-    if(fhttp.last_response != NULL) {
-        if(strstr(fhttp.last_response, "[ERROR] Not connected to Wifi. Failed to reconnect.") !=
-           NULL) {
+    if (fhttp.last_response != NULL)
+    {
+        if (strstr(fhttp.last_response, "[ERROR] Not connected to Wifi. Failed to reconnect.") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[ERROR] Not connected to Wifi.");
             canvas_draw_str(canvas, 0, 22, "Failed to reconnect.");
             canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
             canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        } else if(strstr(fhttp.last_response, "[ERROR] Failed to connect to Wifi.") != NULL) {
+        }
+        else if (strstr(fhttp.last_response, "[ERROR] Failed to connect to Wifi.") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[ERROR] Not connected to Wifi.");
             canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
             canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        } else if(strstr(fhttp.last_response, "[PONG]") != NULL) {
+        }
+        else if (strstr(fhttp.last_response, "[PONG]") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[STATUS]Connecting to AP...");
-        } else {
+        }
+        else
+        {
             canvas_clear(canvas);
             FURI_LOG_E(TAG, "Received an error: %s", fhttp.last_response);
             canvas_draw_str(canvas, 0, 10, "[ERROR] Unusual error...");
             canvas_draw_str(canvas, 0, 60, "Press BACK and retry.");
         }
-    } else {
+    }
+    else
+    {
         canvas_clear(canvas);
         canvas_draw_str(canvas, 0, 10, "Failed to receive data.");
         canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
@@ -53,29 +63,29 @@ static void flip_trader_request_error_draw(Canvas* canvas) {
     }
 }
 
-static bool send_price_request(AssetLoaderModel* model) {
+static bool send_price_request(AssetLoaderModel* model)
+{
     UNUSED(model);
-    if(fhttp.state == INACTIVE) {
+    if (fhttp.state == INACTIVE)
+    {
         return false;
     }
-    if(!sent_get_request && fhttp.state == IDLE) {
+    if (!sent_get_request && fhttp.state == IDLE)
+    {
         sent_get_request = true;
         char url[128];
-        char* headers = jsmn("Content-Type", "application/json");
+        char *headers = jsmn("Content-Type", "application/json");
         snprintf(
             fhttp.file_path,
             sizeof(fhttp.file_path),
             STORAGE_EXT_PATH_PREFIX "/apps_data/flip_trader/price.txt");
 
         fhttp.save_received_data = true;
-        snprintf(
-            url,
-            128,
-            "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=%s&apikey=2X90WLEFMP43OJKE",
-            asset_names[asset_index]);
+        snprintf(url, 128, "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=%s&apikey=2X90WLEFMP43OJKE", asset_names[asset_index]);
         get_request_success = flipper_http_get_request_with_headers(url, headers);
         free(headers);
-        if(!get_request_success) {
+        if (!get_request_success)
+        {
             FURI_LOG_E(TAG, "Failed to send GET request");
             fhttp.state = ISSUE;
             return false;
@@ -85,26 +95,31 @@ static bool send_price_request(AssetLoaderModel* model) {
     return true;
 }
 
-static char* process_asset_price(AssetLoaderModel* model) {
+static char *process_asset_price(AssetLoaderModel* model)
+{
     UNUSED(model);
-    if(!request_processed) {
+    if (!request_processed)
+    {
         // load the received data from the saved file
-        FuriString* price_data = flipper_http_load_from_file(fhttp.file_path);
-        if(price_data == NULL) {
+        FuriString *price_data = flipper_http_load_from_file(fhttp.file_path);
+        if (price_data == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to load received data from file.");
             fhttp.state = ISSUE;
             return NULL;
         }
-        char* data_cstr = (char*)furi_string_get_cstr(price_data);
-        if(data_cstr == NULL) {
+        char *data_cstr = (char *)furi_string_get_cstr(price_data);
+        if (data_cstr == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to get C-string from FuriString.");
             furi_string_free(price_data);
             fhttp.state = ISSUE;
             return NULL;
         }
         request_processed = true;
-        char* global_quote = get_json_value("Global Quote", data_cstr, MAX_TOKENS);
-        if(global_quote == NULL) {
+        char *global_quote = get_json_value("Global Quote", data_cstr, MAX_TOKENS);
+        if (global_quote == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to get Global Quote");
             fhttp.state = ISSUE;
             furi_string_free(price_data);
@@ -112,8 +127,9 @@ static char* process_asset_price(AssetLoaderModel* model) {
             free(data_cstr);
             return NULL;
         }
-        char* price = get_json_value("05. price", global_quote, MAX_TOKENS);
-        if(price == NULL) {
+        char *price = get_json_value("05. price", global_quote, MAX_TOKENS);
+        if (price == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to get price");
             fhttp.state = ISSUE;
             furi_string_free(price_data);
@@ -134,24 +150,21 @@ static char* process_asset_price(AssetLoaderModel* model) {
     return asset_price;
 }
 
-static void flip_trader_asset_switch_to_view(FlipTraderApp* app) {
-    flip_trader_generic_switch_to_view(
-        app,
-        "Fetching..",
-        send_price_request,
-        process_asset_price,
-        1,
-        callback_to_assets_submenu,
-        FlipTraderViewLoader);
+static void flip_trader_asset_switch_to_view(FlipTraderApp *app)
+{
+    flip_trader_generic_switch_to_view(app, "Fetching..", send_price_request, process_asset_price, 1, callback_to_assets_submenu, FlipTraderViewLoader);
 }
 
-void callback_submenu_choices(void* context, uint32_t index) {
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    if(!app) {
+void callback_submenu_choices(void *context, uint32_t index)
+{
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipTraderApp is NULL");
         return;
     }
-    switch(index) {
+    switch (index)
+    {
     // view the assets submenu
     case FlipTradeSubmenuIndexAssets:
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipTraderViewAssetsSubmenu);
@@ -166,46 +179,48 @@ void callback_submenu_choices(void* context, uint32_t index) {
         break;
     default:
         // handle FlipTraderSubmenuIndexAssetStartIndex + index
-        if(index >= FlipTraderSubmenuIndexAssetStartIndex) {
+        if (index >= FlipTraderSubmenuIndexAssetStartIndex)
+        {
             asset_index = index - FlipTraderSubmenuIndexAssetStartIndex;
             flip_trader_asset_switch_to_view(app);
-        } else {
+        }
+        else
+        {
             FURI_LOG_E(TAG, "Unknown submenu index");
         }
         break;
     }
 }
 
-void text_updated_ssid(void* context) {
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    if(!app) {
+void text_updated_ssid(void *context)
+{
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipTraderApp is NULL");
         return;
     }
 
     // store the entered text
-    strncpy(
-        app->uart_text_input_buffer_ssid,
-        app->uart_text_input_temp_buffer_ssid,
-        app->uart_text_input_buffer_size_ssid);
+    strncpy(app->uart_text_input_buffer_ssid, app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid);
 
     // Ensure null-termination
     app->uart_text_input_buffer_ssid[app->uart_text_input_buffer_size_ssid - 1] = '\0';
 
     // update the variable item text
-    if(app->variable_item_ssid) {
-        variable_item_set_current_value_text(
-            app->variable_item_ssid, app->uart_text_input_buffer_ssid);
+    if (app->variable_item_ssid)
+    {
+        variable_item_set_current_value_text(app->variable_item_ssid, app->uart_text_input_buffer_ssid);
     }
 
     // save settings
     save_settings(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password);
 
     // save wifi settings to devboard
-    if(strlen(app->uart_text_input_buffer_ssid) > 0 &&
-       strlen(app->uart_text_input_buffer_password) > 0) {
-        if(!flipper_http_save_wifi(
-               app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password)) {
+    if (strlen(app->uart_text_input_buffer_ssid) > 0 && strlen(app->uart_text_input_buffer_password) > 0)
+    {
+        if (!flipper_http_save_wifi(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password))
+        {
             FURI_LOG_E(TAG, "Failed to save wifi settings");
         }
     }
@@ -214,36 +229,35 @@ void text_updated_ssid(void* context) {
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipTraderViewWiFiSettings);
 }
 
-void text_updated_password(void* context) {
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    if(!app) {
+void text_updated_password(void *context)
+{
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipTraderApp is NULL");
         return;
     }
 
     // store the entered text
-    strncpy(
-        app->uart_text_input_buffer_password,
-        app->uart_text_input_temp_buffer_password,
-        app->uart_text_input_buffer_size_password);
+    strncpy(app->uart_text_input_buffer_password, app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_size_password);
 
     // Ensure null-termination
     app->uart_text_input_buffer_password[app->uart_text_input_buffer_size_password - 1] = '\0';
 
     // update the variable item text
-    if(app->variable_item_password) {
-        variable_item_set_current_value_text(
-            app->variable_item_password, app->uart_text_input_buffer_password);
+    if (app->variable_item_password)
+    {
+        variable_item_set_current_value_text(app->variable_item_password, app->uart_text_input_buffer_password);
     }
 
     // save settings
     save_settings(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password);
 
     // save wifi settings to devboard
-    if(strlen(app->uart_text_input_buffer_ssid) > 0 &&
-       strlen(app->uart_text_input_buffer_password) > 0) {
-        if(!flipper_http_save_wifi(
-               app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password)) {
+    if (strlen(app->uart_text_input_buffer_ssid) > 0 && strlen(app->uart_text_input_buffer_password) > 0)
+    {
+        if (!flipper_http_save_wifi(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password))
+        {
             FURI_LOG_E(TAG, "Failed to save wifi settings");
         }
     }
@@ -252,8 +266,10 @@ void text_updated_password(void* context) {
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipTraderViewWiFiSettings);
 }
 
-uint32_t callback_to_submenu(void* context) {
-    if(!context) {
+uint32_t callback_to_submenu(void *context)
+{
+    if (!context)
+    {
         FURI_LOG_E(TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -265,8 +281,10 @@ uint32_t callback_to_submenu(void* context) {
     return FlipTraderViewMainSubmenu;
 }
 
-uint32_t callback_to_wifi_settings(void* context) {
-    if(!context) {
+uint32_t callback_to_wifi_settings(void *context)
+{
+    if (!context)
+    {
         FURI_LOG_E(TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -274,8 +292,10 @@ uint32_t callback_to_wifi_settings(void* context) {
     return FlipTraderViewWiFiSettings;
 }
 
-uint32_t callback_to_assets_submenu(void* context) {
-    if(!context) {
+uint32_t callback_to_assets_submenu(void *context)
+{
+    if (!context)
+    {
         FURI_LOG_E(TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -287,13 +307,16 @@ uint32_t callback_to_assets_submenu(void* context) {
     return FlipTraderViewAssetsSubmenu;
 }
 
-void settings_item_selected(void* context, uint32_t index) {
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    if(!app) {
+void settings_item_selected(void *context, uint32_t index)
+{
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipTraderApp is NULL");
         return;
     }
-    switch(index) {
+    switch (index)
+    {
     case 0: // Input SSID
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipTraderViewTextInputSSID);
         break;
@@ -306,13 +329,16 @@ void settings_item_selected(void* context, uint32_t index) {
     }
 }
 
-static void flip_trader_widget_set_text(char* message, Widget** widget) {
-    if(widget == NULL) {
+static void flip_trader_widget_set_text(char *message, Widget **widget)
+{
+    if (widget == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_set_widget_text - widget is NULL");
         DEV_CRASH();
         return;
     }
-    if(message == NULL) {
+    if (message == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_set_widget_text - message is NULL");
         DEV_CRASH();
         return;
@@ -320,19 +346,20 @@ static void flip_trader_widget_set_text(char* message, Widget** widget) {
     widget_reset(*widget);
 
     uint32_t message_length = strlen(message); // Length of the message
-    uint32_t i = 0; // Index tracker
-    uint32_t formatted_index = 0; // Tracker for where we are in the formatted message
-    char* formatted_message; // Buffer to hold the final formatted message
-    if(!easy_flipper_set_buffer(&formatted_message, message_length * 2 + 1)) {
+    uint32_t i = 0;                            // Index tracker
+    uint32_t formatted_index = 0;              // Tracker for where we are in the formatted message
+    char *formatted_message;                   // Buffer to hold the final formatted message
+    if (!easy_flipper_set_buffer(&formatted_message, message_length * 2 + 1))
+    {
         return;
     }
 
-    while(i < message_length) {
+    while (i < message_length)
+    {
         // TODO: Use canvas_glyph_width to calculate the maximum characters for the line
-        uint32_t max_line_length = 29; // Maximum characters per line
+        uint32_t max_line_length = 29;                  // Maximum characters per line
         uint32_t remaining_length = message_length - i; // Remaining characters
-        uint32_t line_length = (remaining_length < max_line_length) ? remaining_length :
-                                                                      max_line_length;
+        uint32_t line_length = (remaining_length < max_line_length) ? remaining_length : max_line_length;
 
         // Temporary buffer to hold the current line
         char line[30];
@@ -340,11 +367,12 @@ static void flip_trader_widget_set_text(char* message, Widget** widget) {
         line[line_length] = '\0';
 
         // Check if the line ends in the middle of a word and adjust accordingly
-        if(line_length == 29 && message[i + line_length] != '\0' &&
-           message[i + line_length] != ' ') {
+        if (line_length == 29 && message[i + line_length] != '\0' && message[i + line_length] != ' ')
+        {
             // Find the last space within the 30-character segment
-            char* last_space = strrchr(line, ' ');
-            if(last_space != NULL) {
+            char *last_space = strrchr(line, ' ');
+            if (last_space != NULL)
+            {
                 // Adjust the line length to avoid cutting the word
                 line_length = last_space - line;
                 line[line_length] = '\0'; // Null-terminate at the space
@@ -352,7 +380,8 @@ static void flip_trader_widget_set_text(char* message, Widget** widget) {
         }
 
         // Manually copy the fixed line into the formatted_message buffer
-        for(uint32_t j = 0; j < line_length; j++) {
+        for (uint32_t j = 0; j < line_length; j++)
+        {
             formatted_message[formatted_index++] = line[j];
         }
 
@@ -363,7 +392,8 @@ static void flip_trader_widget_set_text(char* message, Widget** widget) {
         i += line_length;
 
         // Skip spaces at the beginning of the next line
-        while(message[i] == ' ') {
+        while (message[i] == ' ')
+        {
             i++;
         }
     }
@@ -372,20 +402,23 @@ static void flip_trader_widget_set_text(char* message, Widget** widget) {
     widget_add_text_scroll_element(*widget, 0, 0, 128, 64, formatted_message);
 }
 
-void flip_trader_loader_draw_callback(Canvas* canvas, void* model) {
-    if(!canvas || !model) {
+void flip_trader_loader_draw_callback(Canvas *canvas, void *model)
+{
+    if (!canvas || !model)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_draw_callback - canvas or model is NULL");
         return;
     }
 
     SerialState http_state = fhttp.state;
-    AssetLoaderModel* asset_loader_model = (AssetLoaderModel*)model;
+    AssetLoaderModel *asset_loader_model = (AssetLoaderModel *)model;
     AssetState asset_state = asset_loader_model->asset_state;
-    char* title = asset_loader_model->title;
+    char *title = asset_loader_model->title;
 
     canvas_set_font(canvas, FontSecondary);
 
-    if(http_state == INACTIVE) {
+    if (http_state == INACTIVE)
+    {
         canvas_draw_str(canvas, 0, 7, "Wifi Dev Board disconnected.");
         canvas_draw_str(canvas, 0, 17, "Please connect to the board.");
         canvas_draw_str(canvas, 0, 32, "If your board is connected,");
@@ -395,7 +428,8 @@ void flip_trader_loader_draw_callback(Canvas* canvas, void* model) {
         return;
     }
 
-    if(asset_state == AssetStateError || asset_state == AssetStateParseError) {
+    if (asset_state == AssetStateError || asset_state == AssetStateParseError)
+    {
         flip_trader_request_error_draw(canvas);
         return;
     }
@@ -403,53 +437,61 @@ void flip_trader_loader_draw_callback(Canvas* canvas, void* model) {
     canvas_draw_str(canvas, 0, 7, title);
     canvas_draw_str(canvas, 0, 17, "Loading...");
 
-    if(asset_state == AssetStateInitial) {
+    if (asset_state == AssetStateInitial)
+    {
         return;
     }
 
-    if(http_state == SENDING) {
+    if (http_state == SENDING)
+    {
         canvas_draw_str(canvas, 0, 27, "Sending...");
         return;
     }
 
-    if(http_state == RECEIVING || asset_state == AssetStateRequested) {
+    if (http_state == RECEIVING || asset_state == AssetStateRequested)
+    {
         canvas_draw_str(canvas, 0, 27, "Receiving...");
         return;
     }
 
-    if(http_state == IDLE && asset_state == AssetStateReceived) {
+    if (http_state == IDLE && asset_state == AssetStateReceived)
+    {
         canvas_draw_str(canvas, 0, 27, "Processing...");
         return;
     }
 
-    if(http_state == IDLE && asset_state == AssetStateParsed) {
+    if (http_state == IDLE && asset_state == AssetStateParsed)
+    {
         canvas_draw_str(canvas, 0, 27, "Processed...");
         return;
     }
 }
 
-static void flip_trader_loader_process_callback(void* context) {
-    if(context == NULL) {
+static void flip_trader_loader_process_callback(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_process_callback - context is NULL");
         DEV_CRASH();
         return;
     }
 
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    View* view = app->view_loader;
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    View *view = app->view_loader;
 
     AssetState current_asset_state;
-    with_view_model(
-        view, AssetLoaderModel * model, { current_asset_state = model->asset_state; }, false);
+    with_view_model(view, AssetLoaderModel * model, { current_asset_state = model->asset_state; }, false);
 
-    if(current_asset_state == AssetStateInitial) {
+    if (current_asset_state == AssetStateInitial)
+    {
         with_view_model(
             view,
             AssetLoaderModel * model,
             {
                 model->asset_state = AssetStateRequested;
                 AssetLoaderFetch fetch = model->fetcher;
-                if(fetch == NULL) {
+                if (fetch == NULL)
+                {
                     FURI_LOG_E(TAG, "Model doesn't have Fetch function assigned.");
                     model->asset_state = AssetStateError;
                     return;
@@ -458,151 +500,174 @@ static void flip_trader_loader_process_callback(void* context) {
                 // Clear any previous responses
                 strncpy(fhttp.last_response, "", 1);
                 bool request_status = fetch(model);
-                if(!request_status) {
+                if (!request_status)
+                {
                     model->asset_state = AssetStateError;
                 }
             },
             true);
-    } else if(current_asset_state == AssetStateRequested || current_asset_state == AssetStateError) {
-        if(fhttp.state == IDLE && fhttp.last_response != NULL) {
-            if(strstr(fhttp.last_response, "[PONG]") != NULL) {
+    }
+    else if (current_asset_state == AssetStateRequested || current_asset_state == AssetStateError)
+    {
+        if (fhttp.state == IDLE && fhttp.last_response != NULL)
+        {
+            if (strstr(fhttp.last_response, "[PONG]") != NULL)
+            {
                 FURI_LOG_DEV(TAG, "PONG received.");
-            } else if(strncmp(fhttp.last_response, "[SUCCESS]", 9) == 0) {
-                FURI_LOG_DEV(
-                    TAG,
-                    "SUCCESS received. %s",
-                    fhttp.last_response ? fhttp.last_response : "NULL");
-            } else if(strncmp(fhttp.last_response, "[ERROR]", 9) == 0) {
-                FURI_LOG_DEV(
-                    TAG, "ERROR received. %s", fhttp.last_response ? fhttp.last_response : "NULL");
-            } else if(strlen(fhttp.last_response) == 0) {
+            }
+            else if (strncmp(fhttp.last_response, "[SUCCESS]", 9) == 0)
+            {
+                FURI_LOG_DEV(TAG, "SUCCESS received. %s", fhttp.last_response ? fhttp.last_response : "NULL");
+            }
+            else if (strncmp(fhttp.last_response, "[ERROR]", 9) == 0)
+            {
+                FURI_LOG_DEV(TAG, "ERROR received. %s", fhttp.last_response ? fhttp.last_response : "NULL");
+            }
+            else if (strlen(fhttp.last_response) == 0)
+            {
                 // Still waiting on response
-            } else {
-                with_view_model(
-                    view,
-                    AssetLoaderModel * model,
-                    { model->asset_state = AssetStateReceived; },
-                    true);
             }
-        } else if(fhttp.state == SENDING || fhttp.state == RECEIVING) {
+            else
+            {
+                with_view_model(view, AssetLoaderModel * model, { model->asset_state = AssetStateReceived; }, true);
+            }
+        }
+        else if (fhttp.state == SENDING || fhttp.state == RECEIVING)
+        {
             // continue waiting
-        } else if(fhttp.state == INACTIVE) {
+        }
+        else if (fhttp.state == INACTIVE)
+        {
             // inactive. try again
-        } else if(fhttp.state == ISSUE) {
-            with_view_model(
-                view, AssetLoaderModel * model, { model->asset_state = AssetStateError; }, true);
-        } else {
-            FURI_LOG_DEV(
-                TAG,
-                "Unexpected state: %d lastresp: %s",
-                fhttp.state,
-                fhttp.last_response ? fhttp.last_response : "NULL");
+        }
+        else if (fhttp.state == ISSUE)
+        {
+            with_view_model(view, AssetLoaderModel * model, { model->asset_state = AssetStateError; }, true);
+        }
+        else
+        {
+            FURI_LOG_DEV(TAG, "Unexpected state: %d lastresp: %s", fhttp.state, fhttp.last_response ? fhttp.last_response : "NULL");
             DEV_CRASH();
         }
-    } else if(current_asset_state == AssetStateReceived) {
+    }
+    else if (current_asset_state == AssetStateReceived)
+    {
         with_view_model(
             view,
             AssetLoaderModel * model,
             {
-                char* asset_text;
-                if(model->parser == NULL) {
+                char *asset_text;
+                if (model->parser == NULL)
+                {
                     asset_text = NULL;
                     FURI_LOG_DEV(TAG, "Parser is NULL");
                     DEV_CRASH();
-                } else {
+                }
+                else
+                {
                     asset_text = model->parser(model);
                 }
-                FURI_LOG_DEV(
-                    TAG,
-                    "Parsed asset: %s\r\ntext: %s",
-                    fhttp.last_response ? fhttp.last_response : "NULL",
-                    asset_text ? asset_text : "NULL");
+                FURI_LOG_DEV(TAG, "Parsed asset: %s\r\ntext: %s", fhttp.last_response ? fhttp.last_response : "NULL", asset_text ? asset_text : "NULL");
                 model->asset_text = asset_text;
-                if(asset_text == NULL) {
+                if (asset_text == NULL)
+                {
                     model->asset_state = AssetStateParseError;
-                } else {
+                }
+                else
+                {
                     model->asset_state = AssetStateParsed;
                 }
             },
             true);
-    } else if(current_asset_state == AssetStateParsed) {
+    }
+    else if (current_asset_state == AssetStateParsed)
+    {
         with_view_model(
             view,
             AssetLoaderModel * model,
             {
-                if(++model->request_index < model->request_count) {
+                if (++model->request_index < model->request_count)
+                {
                     model->asset_state = AssetStateInitial;
-                } else {
-                    flip_trader_widget_set_text(
-                        model->asset_text != NULL ? model->asset_text : "Empty result",
-                        &app_instance->widget_result);
-                    if(model->asset_text != NULL) {
+                }
+                else
+                {
+                    flip_trader_widget_set_text(model->asset_text != NULL ? model->asset_text : "Empty result", &app_instance->widget_result);
+                    if (model->asset_text != NULL)
+                    {
                         free(model->asset_text);
                         model->asset_text = NULL;
                     }
-                    view_set_previous_callback(
-                        widget_get_view(app_instance->widget_result), model->back_callback);
-                    view_dispatcher_switch_to_view(
-                        app_instance->view_dispatcher, FlipTraderViewWidgetResult);
+                    view_set_previous_callback(widget_get_view(app_instance->widget_result), model->back_callback);
+                    view_dispatcher_switch_to_view(app_instance->view_dispatcher, FlipTraderViewWidgetResult);
                 }
             },
             true);
     }
 }
 
-static void flip_trader_loader_timer_callback(void* context) {
-    if(context == NULL) {
+static void flip_trader_loader_timer_callback(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_timer_callback - context is NULL");
         DEV_CRASH();
         return;
     }
-    FlipTraderApp* app = (FlipTraderApp*)context;
+    FlipTraderApp *app = (FlipTraderApp *)context;
     view_dispatcher_send_custom_event(app->view_dispatcher, FlipTraderCustomEventProcess);
 }
 
-static void flip_trader_loader_on_enter(void* context) {
-    if(context == NULL) {
+static void flip_trader_loader_on_enter(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_on_enter - context is NULL");
         DEV_CRASH();
         return;
     }
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    View* view = app->view_loader;
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    View *view = app->view_loader;
     with_view_model(
         view,
         AssetLoaderModel * model,
         {
             view_set_previous_callback(view, model->back_callback);
-            if(model->timer == NULL) {
-                model->timer = furi_timer_alloc(
-                    flip_trader_loader_timer_callback, FuriTimerTypePeriodic, app);
+            if (model->timer == NULL)
+            {
+                model->timer = furi_timer_alloc(flip_trader_loader_timer_callback, FuriTimerTypePeriodic, app);
             }
             furi_timer_start(model->timer, 250);
         },
         true);
 }
 
-static void flip_trader_loader_on_exit(void* context) {
-    if(context == NULL) {
+static void flip_trader_loader_on_exit(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_on_exit - context is NULL");
         DEV_CRASH();
         return;
     }
-    FlipTraderApp* app = (FlipTraderApp*)context;
-    View* view = app->view_loader;
+    FlipTraderApp *app = (FlipTraderApp *)context;
+    View *view = app->view_loader;
     with_view_model(
         view,
         AssetLoaderModel * model,
         {
-            if(model->timer) {
+            if (model->timer)
+            {
                 furi_timer_stop(model->timer);
             }
         },
         false);
 }
 
-void flip_trader_loader_init(View* view) {
-    if(view == NULL) {
+void flip_trader_loader_init(View *view)
+{
+    if (view == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_init - view is NULL");
         DEV_CRASH();
         return;
@@ -612,8 +677,10 @@ void flip_trader_loader_init(View* view) {
     view_set_exit_callback(view, flip_trader_loader_on_exit);
 }
 
-void flip_trader_loader_free_model(View* view) {
-    if(view == NULL) {
+void flip_trader_loader_free_model(View *view)
+{
+    if (view == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_loader_free_model - view is NULL");
         DEV_CRASH();
         return;
@@ -622,11 +689,13 @@ void flip_trader_loader_free_model(View* view) {
         view,
         AssetLoaderModel * model,
         {
-            if(model->timer) {
+            if (model->timer)
+            {
                 furi_timer_free(model->timer);
                 model->timer = NULL;
             }
-            if(model->parser_context) {
+            if (model->parser_context)
+            {
                 free(model->parser_context);
                 model->parser_context = NULL;
             }
@@ -634,14 +703,17 @@ void flip_trader_loader_free_model(View* view) {
         false);
 }
 
-bool flip_trader_custom_event_callback(void* context, uint32_t index) {
-    if(context == NULL) {
+bool flip_trader_custom_event_callback(void *context, uint32_t index)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_custom_event_callback - context is NULL");
         DEV_CRASH();
         return false;
     }
 
-    switch(index) {
+    switch (index)
+    {
     case FlipTraderCustomEventProcess:
         flip_trader_loader_process_callback(context);
         return true;
@@ -651,22 +723,18 @@ bool flip_trader_custom_event_callback(void* context, uint32_t index) {
     }
 }
 
-void flip_trader_generic_switch_to_view(
-    FlipTraderApp* app,
-    char* title,
-    AssetLoaderFetch fetcher,
-    AssetLoaderParser parser,
-    size_t request_count,
-    ViewNavigationCallback back,
-    uint32_t view_id) {
-    if(app == NULL) {
+void flip_trader_generic_switch_to_view(FlipTraderApp *app, char *title, AssetLoaderFetch fetcher, AssetLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id)
+{
+    if (app == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_generic_switch_to_view - app is NULL");
         DEV_CRASH();
         return;
     }
 
-    View* view = app->view_loader;
-    if(view == NULL) {
+    View *view = app->view_loader;
+    if (view == NULL)
+    {
         FURI_LOG_E(TAG, "flip_trader_generic_switch_to_view - view is NULL");
         DEV_CRASH();
         return;

+ 25 - 29
flip_trader/callback/flip_trader_callback.h

@@ -11,20 +11,21 @@ extern bool sent_get_request;
 extern bool get_request_success;
 extern bool request_processed;
 
-void callback_submenu_choices(void* context, uint32_t index);
-void text_updated_ssid(void* context);
+void callback_submenu_choices(void *context, uint32_t index);
+void text_updated_ssid(void *context);
 
-void text_updated_password(void* context);
+void text_updated_password(void *context);
 
-uint32_t callback_to_submenu(void* context);
+uint32_t callback_to_submenu(void *context);
 
-uint32_t callback_to_wifi_settings(void* context);
-uint32_t callback_to_assets_submenu(void* context);
-void settings_item_selected(void* context, uint32_t index);
+uint32_t callback_to_wifi_settings(void *context);
+uint32_t callback_to_assets_submenu(void *context);
+void settings_item_selected(void *context, uint32_t index);
 
 // Add edits by Derek Jamison
 typedef enum AssetState AssetState;
-enum AssetState {
+enum AssetState
+{
     AssetStateInitial,
     AssetStateRequested,
     AssetStateReceived,
@@ -34,40 +35,35 @@ enum AssetState {
 };
 
 typedef enum FlipTraderCustomEvent FlipTraderCustomEvent;
-enum FlipTraderCustomEvent {
+enum FlipTraderCustomEvent
+{
     FlipTraderCustomEventProcess,
 };
 
 typedef struct AssetLoaderModel AssetLoaderModel;
-typedef bool (*AssetLoaderFetch)(AssetLoaderModel* model);
-typedef char* (*AssetLoaderParser)(AssetLoaderModel* model);
-struct AssetLoaderModel {
-    char* title;
-    char* asset_text;
+typedef bool (*AssetLoaderFetch)(AssetLoaderModel *model);
+typedef char *(*AssetLoaderParser)(AssetLoaderModel *model);
+struct AssetLoaderModel
+{
+    char *title;
+    char *asset_text;
     AssetState asset_state;
     AssetLoaderFetch fetcher;
     AssetLoaderParser parser;
-    void* parser_context;
+    void *parser_context;
     size_t request_index;
     size_t request_count;
     ViewNavigationCallback back_callback;
-    FuriTimer* timer;
+    FuriTimer *timer;
 };
 
-void flip_trader_generic_switch_to_view(
-    FlipTraderApp* app,
-    char* title,
-    AssetLoaderFetch fetcher,
-    AssetLoaderParser parser,
-    size_t request_count,
-    ViewNavigationCallback back,
-    uint32_t view_id);
+void flip_trader_generic_switch_to_view(FlipTraderApp *app, char *title, AssetLoaderFetch fetcher, AssetLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id);
 
-void flip_trader_loader_draw_callback(Canvas* canvas, void* model);
+void flip_trader_loader_draw_callback(Canvas *canvas, void *model);
 
-void flip_trader_loader_init(View* view);
+void flip_trader_loader_init(View *view);
 
-void flip_trader_loader_free_model(View* view);
+void flip_trader_loader_free_model(View *view);
 
-bool flip_trader_custom_event_callback(void* context, uint32_t index);
-#endif // FLIP_TRADER_CALLBACK_H
+bool flip_trader_custom_event_callback(void *context, uint32_t index);
+#endif // FLIP_TRADER_CALLBACK_H

+ 198 - 139
flip_trader/easy_flipper/easy_flipper.c

@@ -5,9 +5,11 @@
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t easy_flipper_callback_exit_app(void* context) {
+uint32_t easy_flipper_callback_exit_app(void *context)
+{
     // Exit the application
-    if(!context) {
+    if (!context)
+    {
         FURI_LOG_E(EASY_TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -21,13 +23,16 @@ uint32_t easy_flipper_callback_exit_app(void* context) {
  * @param buffer_size The size of the buffer
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size) {
-    if(!buffer) {
+bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size)
+{
+    if (!buffer)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer");
         return false;
     }
-    *buffer = (char*)malloc(buffer_size);
-    if(!*buffer) {
+    *buffer = (char *)malloc(buffer_size);
+    if (!*buffer)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate buffer");
         return false;
     }
@@ -46,32 +51,39 @@ bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size) {
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_view(
-    View** view,
+    View **view,
     int32_t view_id,
-    void draw_callback(Canvas*, void*),
-    bool input_callback(InputEvent*, void*),
-    uint32_t (*previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!view || !view_dispatcher) {
+    void draw_callback(Canvas *, void *),
+    bool input_callback(InputEvent *, void *),
+    uint32_t (*previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!view || !view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view");
         return false;
     }
     *view = view_alloc();
-    if(!*view) {
+    if (!*view)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate View");
         return false;
     }
-    if(draw_callback) {
+    if (draw_callback)
+    {
         view_set_draw_callback(*view, draw_callback);
     }
-    if(input_callback) {
+    if (input_callback)
+    {
         view_set_input_callback(*view, input_callback);
     }
-    if(context) {
+    if (context)
+    {
         view_set_context(*view, context);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(*view, previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, *view);
@@ -85,18 +97,22 @@ bool easy_flipper_set_view(
  * @param context The context to pass to the event callback
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui, void* context) {
-    if(!view_dispatcher) {
+bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context)
+{
+    if (!view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view_dispatcher");
         return false;
     }
     *view_dispatcher = view_dispatcher_alloc();
-    if(!*view_dispatcher) {
+    if (!*view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate ViewDispatcher");
         return false;
     }
     view_dispatcher_attach_to_gui(*view_dispatcher, gui, ViewDispatcherTypeFullscreen);
-    if(context) {
+    if (context)
+    {
         view_dispatcher_set_event_callback_context(*view_dispatcher, context);
     }
     return true;
@@ -113,24 +129,29 @@ bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_submenu(
-    Submenu** submenu,
+    Submenu **submenu,
     int32_t view_id,
-    char* title,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!submenu) {
+    char *title,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!submenu)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_submenu");
         return false;
     }
     *submenu = submenu_alloc();
-    if(!*submenu) {
+    if (!*submenu)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Submenu");
         return false;
     }
-    if(title) {
+    if (title)
+    {
         submenu_set_header(*submenu, title);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(submenu_get_view(*submenu), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, submenu_get_view(*submenu));
@@ -147,20 +168,24 @@ bool easy_flipper_set_submenu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_menu(
-    Menu** menu,
+    Menu **menu,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!menu) {
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!menu)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_menu");
         return false;
     }
     *menu = menu_alloc();
-    if(!*menu) {
+    if (!*menu)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Menu");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(menu_get_view(*menu), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, menu_get_view(*menu));
@@ -177,24 +202,29 @@ bool easy_flipper_set_menu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_widget(
-    Widget** widget,
+    Widget **widget,
     int32_t view_id,
-    char* text,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!widget) {
+    char *text,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!widget)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_widget");
         return false;
     }
     *widget = widget_alloc();
-    if(!*widget) {
+    if (!*widget)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Widget");
         return false;
     }
-    if(text) {
+    if (text)
+    {
         widget_add_text_scroll_element(*widget, 0, 0, 128, 64, text);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(widget_get_view(*widget), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, widget_get_view(*widget));
@@ -213,30 +243,33 @@ bool easy_flipper_set_widget(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_variable_item_list(
-    VariableItemList** variable_item_list,
+    VariableItemList **variable_item_list,
     int32_t view_id,
-    void (*enter_callback)(void*, uint32_t),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!variable_item_list) {
+    void (*enter_callback)(void *, uint32_t),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!variable_item_list)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_variable_item_list");
         return false;
     }
     *variable_item_list = variable_item_list_alloc();
-    if(!*variable_item_list) {
+    if (!*variable_item_list)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate VariableItemList");
         return false;
     }
-    if(enter_callback) {
+    if (enter_callback)
+    {
         variable_item_list_set_enter_callback(*variable_item_list, enter_callback, context);
     }
-    if(previous_callback) {
-        view_set_previous_callback(
-            variable_item_list_get_view(*variable_item_list), previous_callback);
+    if (previous_callback)
+    {
+        view_set_previous_callback(variable_item_list_get_view(*variable_item_list), previous_callback);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
+    view_dispatcher_add_view(*view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
     return true;
 }
 
@@ -249,38 +282,38 @@ bool easy_flipper_set_variable_item_list(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_text_input(
-    TextInput** text_input,
+    TextInput **text_input,
     int32_t view_id,
-    char* header_text,
-    char* text_input_temp_buffer,
+    char *header_text,
+    char *text_input_temp_buffer,
     uint32_t text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!text_input) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_text_input");
         return false;
     }
     *text_input = text_input_alloc();
-    if(!*text_input) {
+    if (!*text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate TextInput");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(text_input_get_view(*text_input), previous_callback);
     }
-    if(header_text) {
+    if (header_text)
+    {
         text_input_set_header_text(*text_input, header_text);
     }
-    if(text_input_temp_buffer && text_input_buffer_size && result_callback) {
-        text_input_set_result_callback(
-            *text_input,
-            result_callback,
-            context,
-            text_input_temp_buffer,
-            text_input_buffer_size,
-            false);
+    if (text_input_temp_buffer && text_input_buffer_size && result_callback)
+    {
+        text_input_set_result_callback(*text_input, result_callback, context, text_input_temp_buffer, text_input_buffer_size, false);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*text_input));
     return true;
@@ -295,38 +328,38 @@ bool easy_flipper_set_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    TextInput** uart_text_input,
+    TextInput **uart_text_input,
     int32_t view_id,
-    char* header_text,
-    char* uart_text_input_temp_buffer,
+    char *header_text,
+    char *uart_text_input_temp_buffer,
     uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!uart_text_input) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!uart_text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
     *uart_text_input = text_input_alloc();
-    if(!*uart_text_input) {
+    if (!*uart_text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
-    if(header_text) {
+    if (header_text)
+    {
         text_input_set_header_text(*uart_text_input, header_text);
     }
-    if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        text_input_set_result_callback(
-            *uart_text_input,
-            result_callback,
-            context,
-            uart_text_input_temp_buffer,
-            uart_text_input_buffer_size,
-            false);
+    if (uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback)
+    {
+        text_input_set_result_callback(*uart_text_input, result_callback, context, uart_text_input_temp_buffer, uart_text_input_buffer_size, false);
     }
     text_input_show_illegal_symbols(*uart_text_input, true);
     view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
@@ -353,52 +386,63 @@ bool easy_flipper_set_uart_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_dialog_ex(
-    DialogEx** dialog_ex,
+    DialogEx **dialog_ex,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    char* left_button_text,
-    char* right_button_text,
-    char* center_button_text,
-    void (*result_callback)(DialogExResult, void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!dialog_ex) {
+    char *left_button_text,
+    char *right_button_text,
+    char *center_button_text,
+    void (*result_callback)(DialogExResult, void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!dialog_ex)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_dialog_ex");
         return false;
     }
     *dialog_ex = dialog_ex_alloc();
-    if(!*dialog_ex) {
+    if (!*dialog_ex)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate DialogEx");
         return false;
     }
-    if(header) {
+    if (header)
+    {
         dialog_ex_set_header(*dialog_ex, header, header_x, header_y, AlignLeft, AlignTop);
     }
-    if(text) {
+    if (text)
+    {
         dialog_ex_set_text(*dialog_ex, text, text_x, text_y, AlignLeft, AlignTop);
     }
-    if(left_button_text) {
+    if (left_button_text)
+    {
         dialog_ex_set_left_button_text(*dialog_ex, left_button_text);
     }
-    if(right_button_text) {
+    if (right_button_text)
+    {
         dialog_ex_set_right_button_text(*dialog_ex, right_button_text);
     }
-    if(center_button_text) {
+    if (center_button_text)
+    {
         dialog_ex_set_center_button_text(*dialog_ex, center_button_text);
     }
-    if(result_callback) {
+    if (result_callback)
+    {
         dialog_ex_set_result_callback(*dialog_ex, result_callback);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(dialog_ex_get_view(*dialog_ex), previous_callback);
     }
-    if(context) {
+    if (context)
+    {
         dialog_ex_set_context(*dialog_ex, context);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, dialog_ex_get_view(*dialog_ex));
@@ -422,40 +466,48 @@ bool easy_flipper_set_dialog_ex(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_popup(
-    Popup** popup,
+    Popup **popup,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!popup) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!popup)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_popup");
         return false;
     }
     *popup = popup_alloc();
-    if(!*popup) {
+    if (!*popup)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Popup");
         return false;
     }
-    if(header) {
+    if (header)
+    {
         popup_set_header(*popup, header, header_x, header_y, AlignLeft, AlignTop);
     }
-    if(text) {
+    if (text)
+    {
         popup_set_text(*popup, text, text_x, text_y, AlignLeft, AlignTop);
     }
-    if(result_callback) {
+    if (result_callback)
+    {
         popup_set_callback(*popup, result_callback);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(popup_get_view(*popup), previous_callback);
     }
-    if(context) {
+    if (context)
+    {
         popup_set_context(*popup, context);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, popup_get_view(*popup));
@@ -471,20 +523,24 @@ bool easy_flipper_set_popup(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_loading(
-    Loading** loading,
+    Loading **loading,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!loading) {
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!loading)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_loading");
         return false;
     }
     *loading = loading_alloc();
-    if(!*loading) {
+    if (!*loading)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Loading");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(loading_get_view(*loading), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, loading_get_view(*loading));
@@ -497,16 +553,19 @@ bool easy_flipper_set_loading(
  * @param buffer The buffer to copy the string to
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_char_to_furi_string(FuriString** furi_string, char* buffer) {
-    if(!furi_string) {
+bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer)
+{
+    if (!furi_string)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer_to_furi_string");
         return false;
     }
     *furi_string = furi_string_alloc();
-    if(!furi_string) {
+    if (!furi_string)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate FuriString");
         return false;
     }
     furi_string_set_str(*furi_string, buffer);
     return true;
-}
+}

+ 61 - 61
flip_trader/easy_flipper/easy_flipper.h

@@ -28,14 +28,14 @@
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t easy_flipper_callback_exit_app(void* context);
+uint32_t easy_flipper_callback_exit_app(void *context);
 /**
  * @brief Initialize a buffer
  * @param buffer The buffer to initialize
  * @param buffer_size The size of the buffer
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size);
+bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size);
 /**
  * @brief Initialize a View object
  * @param view The View object to initialize
@@ -47,13 +47,13 @@ bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size);
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_view(
-    View** view,
+    View **view,
     int32_t view_id,
-    void draw_callback(Canvas*, void*),
-    bool input_callback(InputEvent*, void*),
-    uint32_t (*previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void draw_callback(Canvas *, void *),
+    bool input_callback(InputEvent *, void *),
+    uint32_t (*previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a ViewDispatcher object
@@ -62,7 +62,7 @@ bool easy_flipper_set_view(
  * @param context The context to pass to the event callback
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui, void* context);
+bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context);
 
 /**
  * @brief Initialize a Submenu object
@@ -75,11 +75,11 @@ bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_submenu(
-    Submenu** submenu,
+    Submenu **submenu,
     int32_t view_id,
-    char* title,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    char *title,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a Menu object
@@ -92,10 +92,10 @@ bool easy_flipper_set_submenu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_menu(
-    Menu** menu,
+    Menu **menu,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a Widget object
@@ -107,11 +107,11 @@ bool easy_flipper_set_menu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_widget(
-    Widget** widget,
+    Widget **widget,
     int32_t view_id,
-    char* text,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    char *text,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a VariableItemList object
@@ -125,12 +125,12 @@ bool easy_flipper_set_widget(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_variable_item_list(
-    VariableItemList** variable_item_list,
+    VariableItemList **variable_item_list,
     int32_t view_id,
-    void (*enter_callback)(void*, uint32_t),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*enter_callback)(void *, uint32_t),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a TextInput object
@@ -141,15 +141,15 @@ bool easy_flipper_set_variable_item_list(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_text_input(
-    TextInput** text_input,
+    TextInput **text_input,
     int32_t view_id,
-    char* header_text,
-    char* text_input_temp_buffer,
+    char *header_text,
+    char *text_input_temp_buffer,
     uint32_t text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a TextInput object with extra symbols
@@ -160,15 +160,15 @@ bool easy_flipper_set_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    TextInput** uart_text_input,
+    TextInput **uart_text_input,
     int32_t view_id,
-    char* header_text,
-    char* uart_text_input_temp_buffer,
+    char *header_text,
+    char *uart_text_input_temp_buffer,
     uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a DialogEx object
@@ -190,21 +190,21 @@ bool easy_flipper_set_uart_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_dialog_ex(
-    DialogEx** dialog_ex,
+    DialogEx **dialog_ex,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    char* left_button_text,
-    char* right_button_text,
-    char* center_button_text,
-    void (*result_callback)(DialogExResult, void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    char *left_button_text,
+    char *right_button_text,
+    char *center_button_text,
+    void (*result_callback)(DialogExResult, void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a Popup object
@@ -223,18 +223,18 @@ bool easy_flipper_set_dialog_ex(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_popup(
-    Popup** popup,
+    Popup **popup,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a Loading object
@@ -245,10 +245,10 @@ bool easy_flipper_set_popup(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_loading(
-    Loading** loading,
+    Loading **loading,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Set a char butter to a FuriString
@@ -256,6 +256,6 @@ bool easy_flipper_set_loading(
  * @param buffer The buffer to copy the string to
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_char_to_furi_string(FuriString** furi_string, char* buffer);
+bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer);
 
-#endif
+#endif

+ 32 - 20
flip_trader/flip_storage/flip_trader_storage.c

@@ -1,18 +1,21 @@
 #include "flip_storage/flip_trader_storage.h"
 
-void save_settings(const char* ssid, const char* password) {
+void save_settings(
+    const char *ssid,
+    const char *password)
+{
     // Create the directory for saving settings
     char directory_path[256];
-    snprintf(
-        directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_trader");
+    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_trader");
 
     // Create the directory
-    Storage* storage = furi_record_open(RECORD_STORAGE);
+    Storage *storage = furi_record_open(RECORD_STORAGE);
     storage_common_mkdir(storage, directory_path);
 
     // Open the settings file
-    File* file = storage_file_alloc(storage);
-    if(!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
+    File *file = storage_file_alloc(storage);
+    if (!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS))
+    {
         FURI_LOG_E(TAG, "Failed to open settings file for writing: %s", SETTINGS_PATH);
         storage_file_free(file);
         furi_record_close(RECORD_STORAGE);
@@ -21,15 +24,17 @@ void save_settings(const char* ssid, const char* password) {
 
     // Save the ssid length and data
     size_t ssid_length = strlen(ssid) + 1; // Include null terminator
-    if(storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, ssid, ssid_length) != ssid_length) {
+    if (storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, ssid, ssid_length) != ssid_length)
+    {
         FURI_LOG_E(TAG, "Failed to write SSID");
     }
 
     // Save the password length and data
     size_t password_length = strlen(password) + 1; // Include null terminator
-    if(storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, password, password_length) != password_length) {
+    if (storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, password, password_length) != password_length)
+    {
         FURI_LOG_E(TAG, "Failed to write password");
     }
 
@@ -38,11 +43,17 @@ void save_settings(const char* ssid, const char* password) {
     furi_record_close(RECORD_STORAGE);
 }
 
-bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password_size) {
-    Storage* storage = furi_record_open(RECORD_STORAGE);
-    File* file = storage_file_alloc(storage);
+bool load_settings(
+    char *ssid,
+    size_t ssid_size,
+    char *password,
+    size_t password_size)
+{
+    Storage *storage = furi_record_open(RECORD_STORAGE);
+    File *file = storage_file_alloc(storage);
 
-    if(!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
+    if (!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING))
+    {
         FURI_LOG_E(TAG, "Failed to open settings file for reading: %s", SETTINGS_PATH);
         storage_file_free(file);
         furi_record_close(RECORD_STORAGE);
@@ -51,8 +62,9 @@ bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password
 
     // Load the ssid
     size_t ssid_length;
-    if(storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-       ssid_length > ssid_size || storage_file_read(file, ssid, ssid_length) != ssid_length) {
+    if (storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) || ssid_length > ssid_size ||
+        storage_file_read(file, ssid, ssid_length) != ssid_length)
+    {
         FURI_LOG_E(TAG, "Failed to read SSID");
         storage_file_close(file);
         storage_file_free(file);
@@ -63,9 +75,9 @@ bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password
 
     // Load the password
     size_t password_length;
-    if(storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-       password_length > password_size ||
-       storage_file_read(file, password, password_length) != password_length) {
+    if (storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) || password_length > password_size ||
+        storage_file_read(file, password, password_length) != password_length)
+    {
         FURI_LOG_E(TAG, "Failed to read password");
         storage_file_close(file);
         storage_file_free(file);
@@ -79,4 +91,4 @@ bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password
     furi_record_close(RECORD_STORAGE);
 
     return true;
-}
+}

+ 9 - 3
flip_trader/flip_storage/flip_trader_storage.h

@@ -7,8 +7,14 @@
 
 #define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_trader/settings.bin"
 
-void save_settings(const char* ssid, const char* password);
+void save_settings(
+    const char *ssid,
+    const char *password);
 
-bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password_size);
+bool load_settings(
+    char *ssid,
+    size_t ssid_size,
+    char *password,
+    size_t password_size);
 
-#endif // FLIP_TRADER_STORAGE_H
+#endif // FLIP_TRADER_STORAGE_H

+ 35 - 20
flip_trader/flip_trader.c

@@ -1,19 +1,24 @@
 #include <flip_trader.h>
-void flip_trader_loader_free_model(View* view);
+void flip_trader_loader_free_model(View *view);
 
-void asset_names_free(char** names) {
-    if(names) {
-        for(int i = 0; i < ASSET_COUNT; i++) {
+void asset_names_free(char **names)
+{
+    if (names)
+    {
+        for (int i = 0; i < ASSET_COUNT; i++)
+        {
             free(names[i]);
         }
         free(names);
     }
 }
 
-char** asset_names_alloc() {
+char **asset_names_alloc()
+{
     // Allocate memory for an array of 42 string pointers
-    char** names = malloc(ASSET_COUNT * sizeof(char*));
-    if(!names) {
+    char **names = malloc(ASSET_COUNT * sizeof(char *));
+    if (!names)
+    {
         FURI_LOG_E(TAG, "Failed to allocate memory for asset names");
         return NULL;
     }
@@ -65,56 +70,66 @@ char** asset_names_alloc() {
     return names;
 }
 
-char** asset_names = NULL;
+char **asset_names = NULL;
 // index
 uint32_t asset_index = 0;
-FlipTraderApp* app_instance = NULL;
+FlipTraderApp *app_instance = NULL;
 // Function to free the resources used by FlipTraderApp
-void flip_trader_app_free(FlipTraderApp* app) {
-    if(!app) {
+void flip_trader_app_free(FlipTraderApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipTraderApp is NULL");
         return;
     }
 
     // Free View(s)
-    if(app->view_loader) {
+    if (app->view_loader)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewLoader);
         flip_trader_loader_free_model(app->view_loader);
         view_free(app->view_loader);
     }
 
     // Free Submenu(s)
-    if(app->submenu_main) {
+    if (app->submenu_main)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewMainSubmenu);
         submenu_free(app->submenu_main);
     }
-    if(app->submenu_assets) {
+    if (app->submenu_assets)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewAssetsSubmenu);
         submenu_free(app->submenu_assets);
     }
 
     // Free Widget(s)
-    if(app->widget_about) {
+    if (app->widget_about)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewAbout);
         widget_free(app->widget_about);
     }
-    if(app->widget_result) {
+    if (app->widget_result)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewWidgetResult);
         widget_free(app->widget_result);
     }
 
     // Free Variable Item List(s)
-    if(app->variable_item_list_wifi) {
+    if (app->variable_item_list_wifi)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewWiFiSettings);
         variable_item_list_free(app->variable_item_list_wifi);
     }
 
     // Free Text Input(s)
-    if(app->uart_text_input_ssid) {
+    if (app->uart_text_input_ssid)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewTextInputSSID);
         text_input_free(app->uart_text_input_ssid);
     }
-    if(app->uart_text_input_password) {
+    if (app->uart_text_input_password)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipTraderViewTextInputPassword);
         text_input_free(app->uart_text_input_password);
     }
@@ -132,4 +147,4 @@ void flip_trader_app_free(FlipTraderApp* app) {
 
     // free the app
     free(app);
-}
+}

+ 38 - 35
flip_trader/flip_trader.h

@@ -16,62 +16,65 @@
 #define TAG "FlipTrader"
 
 // Define the submenu items for our FlipTrader application
-typedef enum {
+typedef enum
+{
     // FlipTraderSubmenuIndexMain,     // Click to run get the info of the selected pair
-    FlipTradeSubmenuIndexAssets, // Click to view the assets screen (ETHUSD, BTCUSD, etc.)
-    FlipTraderSubmenuIndexAbout, // Click to view the about screen
-    FlipTraderSubmenuIndexSettings, // Click to view the WiFi settings screen
-        //
+    FlipTradeSubmenuIndexAssets,           // Click to view the assets screen (ETHUSD, BTCUSD, etc.)
+    FlipTraderSubmenuIndexAbout,           // Click to view the about screen
+    FlipTraderSubmenuIndexSettings,        // Click to view the WiFi settings screen
+                                           //
     FlipTraderSubmenuIndexAssetStartIndex, // Start of the submenu items for the assets
 } FlipTraderSubmenuIndex;
 
 // Define a single view for our FlipTrader application
-typedef enum {
-    FlipTraderViewMain, // The screen that displays the info of the selected pair
-    FlipTraderViewMainSubmenu, // The main submenu of the FlipTrader app
-    FlipTraderViewAbout, // The about screen
-    FlipTraderViewWiFiSettings, // The WiFi settings screen
-    FlipTraderViewTextInputSSID, // The text input screen for the SSID
+typedef enum
+{
+    FlipTraderViewMain,              // The screen that displays the info of the selected pair
+    FlipTraderViewMainSubmenu,       // The main submenu of the FlipTrader app
+    FlipTraderViewAbout,             // The about screen
+    FlipTraderViewWiFiSettings,      // The WiFi settings screen
+    FlipTraderViewTextInputSSID,     // The text input screen for the SSID
     FlipTraderViewTextInputPassword, // The text input screen for the password
     //
     FlipTraderViewAssetsSubmenu, // The submenu for the assets
-    FlipTraderViewWidgetResult, // The text box that displays the random fact
-    FlipTraderViewLoader, // The loader screen retrieves data from the internet
+    FlipTraderViewWidgetResult,  // The text box that displays the random fact
+    FlipTraderViewLoader,        // The loader screen retrieves data from the internet
 } FlipTraderView;
 
 // Each screen will have its own view
-typedef struct {
-    ViewDispatcher* view_dispatcher; // Switches between our views
-    View* view_loader; // The screen that loads data from internet
-    Submenu* submenu_main; // The submenu
-    Submenu* submenu_assets; // The submenu for the assets
-    Widget* widget_about; // The widget
-    Widget* widget_result; // The widget that displays the result
-    VariableItemList* variable_item_list_wifi; // The variable item list (settngs)
-    VariableItem* variable_item_ssid; // The variable item for the SSID
-    VariableItem* variable_item_password; // The variable item for the password
-    TextInput* uart_text_input_ssid; // The text input for the SSID
-    TextInput* uart_text_input_password; // The text input for the password
+typedef struct
+{
+    ViewDispatcher *view_dispatcher;           // Switches between our views
+    View *view_loader;                         // The screen that loads data from internet
+    Submenu *submenu_main;                     // The submenu
+    Submenu *submenu_assets;                   // The submenu for the assets
+    Widget *widget_about;                      // The widget
+    Widget *widget_result;                     // The widget that displays the result
+    VariableItemList *variable_item_list_wifi; // The variable item list (settngs)
+    VariableItem *variable_item_ssid;          // The variable item for the SSID
+    VariableItem *variable_item_password;      // The variable item for the password
+    TextInput *uart_text_input_ssid;      // The text input for the SSID
+    TextInput *uart_text_input_password;  // The text input for the password
 
-    char* uart_text_input_buffer_ssid; // Buffer for the text input (SSID)
-    char* uart_text_input_temp_buffer_ssid; // Temporary buffer for the text input (SSID)
+    char *uart_text_input_buffer_ssid;         // Buffer for the text input (SSID)
+    char *uart_text_input_temp_buffer_ssid;    // Temporary buffer for the text input (SSID)
     uint32_t uart_text_input_buffer_size_ssid; // Size of the text input buffer (SSID)
 
-    char* uart_text_input_buffer_password; // Buffer for the text input (password)
-    char* uart_text_input_temp_buffer_password; // Temporary buffer for the text input (password)
+    char *uart_text_input_buffer_password;         // Buffer for the text input (password)
+    char *uart_text_input_temp_buffer_password;    // Temporary buffer for the text input (password)
     uint32_t uart_text_input_buffer_size_password; // Size of the text input buffer (password)
 
 } FlipTraderApp;
 
 #define ASSET_COUNT 42
-extern char** asset_names;
+extern char **asset_names;
 
 // index
 extern uint32_t asset_index;
 
 // Function to free the resources used by FlipTraderApp
-void flip_trader_app_free(FlipTraderApp* app);
-char** asset_names_alloc();
-void asset_names_free(char** names);
-extern FlipTraderApp* app_instance;
-#endif // FLIP_TRADE_E_H
+void flip_trader_app_free(FlipTraderApp *app);
+char **asset_names_alloc();
+void asset_names_free(char **names);
+extern FlipTraderApp *app_instance;
+#endif // FLIP_TRADE_E_H

File diff suppressed because it is too large
+ 294 - 166
flip_trader/flipper_http/flipper_http.c


+ 62 - 59
flip_trader/flipper_http/flipper_http.h

@@ -11,69 +11,72 @@
 
 // STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext
 
-#define HTTP_TAG               "FlipTrader" // change this to your app name
-#define http_tag               "flip_trader" // change this to your app id
-#define UART_CH                (momentum_settings.uart_esp_channel) // UART channel
+#define HTTP_TAG "FlipTrader"             // change this to your app name
+#define http_tag "flip_trader"            // change this to your app id
+#define UART_CH (momentum_settings.uart_esp_channel)    // UART channel
 #define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds
-#define BAUDRATE               (115200) // UART baudrate
-#define RX_BUF_SIZE            1024 // UART RX buffer size
-#define RX_LINE_BUFFER_SIZE    4096 // UART RX line buffer size (increase for large responses)
-#define MAX_FILE_SHOW          4096 // Maximum data from file to show
-#define FILE_BUFFER_SIZE       512 // File buffer size
+#define BAUDRATE (115200)                 // UART baudrate
+#define RX_BUF_SIZE 1024                  // UART RX buffer size
+#define RX_LINE_BUFFER_SIZE 4096          // UART RX line buffer size (increase for large responses)
+#define MAX_FILE_SHOW 4096                // Maximum data from file to show
+#define FILE_BUFFER_SIZE 512              // File buffer size
 
 // Forward declaration for callback
-typedef void (*FlipperHTTP_Callback)(const char* line, void* context);
+typedef void (*FlipperHTTP_Callback)(const char *line, void *context);
 
 // State variable to track the UART state
-typedef enum {
-    INACTIVE, // Inactive state
-    IDLE, // Default state
+typedef enum
+{
+    INACTIVE,  // Inactive state
+    IDLE,      // Default state
     RECEIVING, // Receiving data
-    SENDING, // Sending data
-    ISSUE, // Issue with connection
+    SENDING,   // Sending data
+    ISSUE,     // Issue with connection
 } SerialState;
 
 // Event Flags for UART Worker Thread
-typedef enum {
+typedef enum
+{
     WorkerEvtStop = (1 << 0),
     WorkerEvtRxDone = (1 << 1),
 } WorkerEvtFlags;
 
 // FlipperHTTP Structure
-typedef struct {
-    FuriStreamBuffer* flipper_http_stream; // Stream buffer for UART communication
-    FuriHalSerialHandle* serial_handle; // Serial handle for UART communication
-    FuriThread* rx_thread; // Worker thread for UART
-    FuriThreadId rx_thread_id; // Worker thread ID
+typedef struct
+{
+    FuriStreamBuffer *flipper_http_stream;  // Stream buffer for UART communication
+    FuriHalSerialHandle *serial_handle;     // Serial handle for UART communication
+    FuriThread *rx_thread;                  // Worker thread for UART
+    FuriThreadId rx_thread_id;              // Worker thread ID
     FlipperHTTP_Callback handle_rx_line_cb; // Callback for received lines
-    void* callback_context; // Context for the callback
-    SerialState state; // State of the UART
+    void *callback_context;                 // Context for the callback
+    SerialState state;                      // State of the UART
 
     // variable to store the last received data from the UART
-    char* last_response;
+    char *last_response;
     char file_path[256]; // Path to save the received data
 
     // Timer-related members
-    FuriTimer* get_timeout_timer; // Timer for HTTP request timeout
+    FuriTimer *get_timeout_timer; // Timer for HTTP request timeout
 
     bool started_receiving_get; // Indicates if a GET request has started
-    bool just_started_get; // Indicates if GET data reception has just started
+    bool just_started_get;      // Indicates if GET data reception has just started
 
     bool started_receiving_post; // Indicates if a POST request has started
-    bool just_started_post; // Indicates if POST data reception has just started
+    bool just_started_post;      // Indicates if POST data reception has just started
 
     bool started_receiving_put; // Indicates if a PUT request has started
-    bool just_started_put; // Indicates if PUT data reception has just started
+    bool just_started_put;      // Indicates if PUT data reception has just started
 
     bool started_receiving_delete; // Indicates if a DELETE request has started
-    bool just_started_delete; // Indicates if DELETE data reception has just started
+    bool just_started_delete;      // Indicates if DELETE data reception has just started
 
     // Buffer to hold the raw bytes received from the UART
-    uint8_t* received_bytes;
+    uint8_t *received_bytes;
     size_t received_bytes_len; // Length of the received bytes
-    bool is_bytes_request; // Flag to indicate if the request is for bytes
-    bool save_bytes; // Flag to save the received data to a file
-    bool save_received_data; // Flag to save the received data to a file
+    bool is_bytes_request;     // Flag to indicate if the request is for bytes
+    bool save_bytes;           // Flag to save the received data to a file
+    bool save_received_data;   // Flag to save the received data to a file
 
     bool just_started_bytes; // Indicates if bytes data reception has just started
 } FlipperHTTP;
@@ -88,12 +91,12 @@ extern uint8_t file_buffer[FILE_BUFFER_SIZE];
 // Function to append received data to file
 // make sure to initialize the file path before calling this function
 bool flipper_http_append_to_file(
-    const void* data,
+    const void *data,
     size_t data_size,
     bool start_new_file,
-    char* file_path);
+    char *file_path);
 
-FuriString* flipper_http_load_from_file(char* file_path);
+FuriString *flipper_http_load_from_file(char *file_path);
 
 // UART worker thread
 /**
@@ -103,7 +106,7 @@ FuriString* flipper_http_load_from_file(char* file_path);
  * @note       This function will handle received data asynchronously via the callback.
  */
 // UART worker thread
-int32_t flipper_http_worker(void* context);
+int32_t flipper_http_worker(void *context);
 
 // Timer callback function
 /**
@@ -112,7 +115,7 @@ int32_t flipper_http_worker(void* context);
  * @param      context   The context to pass to the callback.
  * @note       This function will be called when the GET request times out.
  */
-void get_timeout_timer_callback(void* context);
+void get_timeout_timer_callback(void *context);
 
 // UART RX Handler Callback (Interrupt Context)
 /**
@@ -124,9 +127,9 @@ void get_timeout_timer_callback(void* context);
  * @note       This function will handle received data asynchronously via the callback.
  */
 void _flipper_http_rx_callback(
-    FuriHalSerialHandle* handle,
+    FuriHalSerialHandle *handle,
     FuriHalSerialRxEvent event,
-    void* context);
+    void *context);
 
 // UART initialization function
 /**
@@ -136,7 +139,7 @@ void _flipper_http_rx_callback(
  * @param      context   The context to pass to the callback.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_init(FlipperHTTP_Callback callback, void* context);
+bool flipper_http_init(FlipperHTTP_Callback callback, void *context);
 
 // Deinitialize UART
 /**
@@ -153,7 +156,7 @@ void flipper_http_deinit();
  * @param      data  The data to send over UART.
  * @note       The data will be sent over UART with a newline character appended.
  */
-bool flipper_http_send_data(const char* data);
+bool flipper_http_send_data(const char *data);
 
 // Function to send a PING request
 /**
@@ -197,7 +200,7 @@ bool flipper_http_led_off();
  * @param      json_data The JSON data to parse.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_parse_json(const char* key, const char* json_data);
+bool flipper_http_parse_json(const char *key, const char *json_data);
 
 // Function to parse JSON array data
 /**
@@ -208,7 +211,7 @@ bool flipper_http_parse_json(const char* key, const char* json_data);
  * @param      json_data The JSON array data to parse.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_parse_json_array(const char* key, int index, const char* json_data);
+bool flipper_http_parse_json_array(const char *key, int index, const char *json_data);
 
 // Function to scan for WiFi networks
 /**
@@ -224,7 +227,7 @@ bool flipper_http_scan_wifi();
  * @return     true if the request was successful, false otherwise.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_save_wifi(const char* ssid, const char* password);
+bool flipper_http_save_wifi(const char *ssid, const char *password);
 
 // Function to get IP address of WiFi Devboard
 /**
@@ -265,7 +268,7 @@ bool flipper_http_connect_wifi();
  * @param      url  The URL to send the GET request to.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request(const char* url);
+bool flipper_http_get_request(const char *url);
 
 // Function to send a GET request with headers
 /**
@@ -275,7 +278,7 @@ bool flipper_http_get_request(const char* url);
  * @param      headers  The headers to send with the GET request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request_with_headers(const char* url, const char* headers);
+bool flipper_http_get_request_with_headers(const char *url, const char *headers);
 
 // Function to send a GET request with headers and return bytes
 /**
@@ -285,7 +288,7 @@ bool flipper_http_get_request_with_headers(const char* url, const char* headers)
  * @param      headers  The headers to send with the GET request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request_bytes(const char* url, const char* headers);
+bool flipper_http_get_request_bytes(const char *url, const char *headers);
 
 // Function to send a POST request with headers
 /**
@@ -297,9 +300,9 @@ bool flipper_http_get_request_bytes(const char* url, const char* headers);
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_post_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to send a POST request with headers and return bytes
 /**
@@ -310,7 +313,7 @@ bool flipper_http_post_request_with_headers(
  * @param      payload  The data to send with the POST request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_post_request_bytes(const char* url, const char* headers, const char* payload);
+bool flipper_http_post_request_bytes(const char *url, const char *headers, const char *payload);
 
 // Function to send a PUT request with headers
 /**
@@ -322,9 +325,9 @@ bool flipper_http_post_request_bytes(const char* url, const char* headers, const
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_put_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to send a DELETE request with headers
 /**
@@ -336,9 +339,9 @@ bool flipper_http_put_request_with_headers(
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_delete_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to handle received data asynchronously
 /**
@@ -348,10 +351,10 @@ bool flipper_http_delete_request_with_headers(
  * @param      context  The context passed to the callback.
  * @note       The received data will be handled asynchronously via the callback and handles the state of the UART.
  */
-void flipper_http_rx_callback(const char* line, void* context);
+void flipper_http_rx_callback(const char *line, void *context);
 
 // Function to trim leading and trailing spaces and newlines from a constant string
-char* trim(const char* str);
+char *trim(const char *str);
 /**
  * @brief Process requests and parse JSON data asynchronously
  * @param http_request The function to send the request

+ 217 - 136
flip_trader/jsmn/jsmn.c

@@ -13,11 +13,13 @@
 /**
  * Allocates a fresh unused token from the token pool.
  */
-static jsmntok_t*
-    jsmn_alloc_token(jsmn_parser* parser, jsmntok_t* tokens, const size_t num_tokens) {
-    jsmntok_t* tok;
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
+                                   const size_t num_tokens)
+{
+    jsmntok_t *tok;
 
-    if(parser->toknext >= num_tokens) {
+    if (parser->toknext >= num_tokens)
+    {
         return NULL;
     }
     tok = &tokens[parser->toknext++];
@@ -32,8 +34,9 @@ static jsmntok_t*
 /**
  * Fills token type and boundaries.
  */
-static void
-    jsmn_fill_token(jsmntok_t* token, const jsmntype_t type, const int start, const int end) {
+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
+                            const int start, const int end)
+{
     token->type = type;
     token->start = start;
     token->end = end;
@@ -43,19 +46,19 @@ static void
 /**
  * Fills next available token with JSON primitive.
  */
-static int jsmn_parse_primitive(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+                                const size_t len, jsmntok_t *tokens,
+                                const size_t num_tokens)
+{
+    jsmntok_t *token;
     int start;
 
     start = parser->pos;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-        switch(js[parser->pos]) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
+        switch (js[parser->pos])
+        {
 #ifndef JSMN_STRICT
         /* In strict mode primitive must be followed by "," or "}" or "]" */
         case ':':
@@ -72,7 +75,8 @@ static int jsmn_parse_primitive(
             /* to quiet a warning from gcc*/
             break;
         }
-        if(js[parser->pos] < 32 || js[parser->pos] >= 127) {
+        if (js[parser->pos] < 32 || js[parser->pos] >= 127)
+        {
             parser->pos = start;
             return JSMN_ERROR_INVAL;
         }
@@ -84,12 +88,14 @@ static int jsmn_parse_primitive(
 #endif
 
 found:
-    if(tokens == NULL) {
+    if (tokens == NULL)
+    {
         parser->pos--;
         return 0;
     }
     token = jsmn_alloc_token(parser, tokens, num_tokens);
-    if(token == NULL) {
+    if (token == NULL)
+    {
         parser->pos = start;
         return JSMN_ERROR_NOMEM;
     }
@@ -104,29 +110,31 @@ found:
 /**
  * Fills next token with JSON string.
  */
-static int jsmn_parse_string(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+                             const size_t len, jsmntok_t *tokens,
+                             const size_t num_tokens)
+{
+    jsmntok_t *token;
 
     int start = parser->pos;
 
     /* Skip starting quote */
     parser->pos++;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c = js[parser->pos];
 
         /* Quote: end of string */
-        if(c == '\"') {
-            if(tokens == NULL) {
+        if (c == '\"')
+        {
+            if (tokens == NULL)
+            {
                 return 0;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 parser->pos = start;
                 return JSMN_ERROR_NOMEM;
             }
@@ -138,10 +146,12 @@ static int jsmn_parse_string(
         }
 
         /* Backslash: Quoted symbol expected */
-        if(c == '\\' && parser->pos + 1 < len) {
+        if (c == '\\' && parser->pos + 1 < len)
+        {
             int i;
             parser->pos++;
-            switch(js[parser->pos]) {
+            switch (js[parser->pos])
+            {
             /* Allowed escaped symbols */
             case '\"':
             case '/':
@@ -155,11 +165,13 @@ static int jsmn_parse_string(
             /* Allows escaped symbol \uXXXX */
             case 'u':
                 parser->pos++;
-                for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+                for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++)
+                {
                     /* If it isn't a hex character we have an error */
-                    if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                         (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                         (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+                    if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+                          (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+                          (js[parser->pos] >= 97 && js[parser->pos] <= 102)))
+                    { /* a-f */
                         parser->pos = start;
                         return JSMN_ERROR_INVAL;
                     }
@@ -181,7 +193,8 @@ static int jsmn_parse_string(
 /**
  * Create JSON parser over an array of tokens
  */
-void jsmn_init(jsmn_parser* parser) {
+void jsmn_init(jsmn_parser *parser)
+{
     parser->pos = 0;
     parser->toknext = 0;
     parser->toksuper = -1;
@@ -190,38 +203,41 @@ void jsmn_init(jsmn_parser* parser) {
 /**
  * Parse JSON string and fill tokens.
  */
-int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens) {
+int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+               jsmntok_t *tokens, const unsigned int num_tokens)
+{
     int r;
     int i;
-    jsmntok_t* token;
+    jsmntok_t *token;
     int count = parser->toknext;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c;
         jsmntype_t type;
 
         c = js[parser->pos];
-        switch(c) {
+        switch (c)
+        {
         case '{':
         case '[':
             count++;
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 return JSMN_ERROR_NOMEM;
             }
-            if(parser->toksuper != -1) {
-                jsmntok_t* t = &tokens[parser->toksuper];
+            if (parser->toksuper != -1)
+            {
+                jsmntok_t *t = &tokens[parser->toksuper];
 #ifdef JSMN_STRICT
                 /* In strict mode an object or array can't become a key */
-                if(t->type == JSMN_OBJECT) {
+                if (t->type == JSMN_OBJECT)
+                {
                     return JSMN_ERROR_INVAL;
                 }
 #endif
@@ -236,26 +252,33 @@ int jsmn_parse(
             break;
         case '}':
         case ']':
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
 #ifdef JSMN_PARENT_LINKS
-            if(parser->toknext < 1) {
+            if (parser->toknext < 1)
+            {
                 return JSMN_ERROR_INVAL;
             }
             token = &tokens[parser->toknext - 1];
-            for(;;) {
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+            for (;;)
+            {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     token->end = parser->pos + 1;
                     parser->toksuper = token->parent;
                     break;
                 }
-                if(token->parent == -1) {
-                    if(token->type != type || parser->toksuper == -1) {
+                if (token->parent == -1)
+                {
+                    if (token->type != type || parser->toksuper == -1)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     break;
@@ -263,10 +286,13 @@ int jsmn_parse(
                 token = &tokens[token->parent];
             }
 #else
-            for(i = parser->toknext - 1; i >= 0; i--) {
+            for (i = parser->toknext - 1; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     parser->toksuper = -1;
@@ -275,12 +301,15 @@ int jsmn_parse(
                 }
             }
             /* Error if unmatched closing bracket */
-            if(i == -1) {
+            if (i == -1)
+            {
                 return JSMN_ERROR_INVAL;
             }
-            for(; i >= 0; i--) {
+            for (; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
+                if (token->start != -1 && token->end == -1)
+                {
                     parser->toksuper = i;
                     break;
                 }
@@ -289,11 +318,13 @@ int jsmn_parse(
             break;
         case '\"':
             r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -306,15 +337,19 @@ int jsmn_parse(
             parser->toksuper = parser->toknext - 1;
             break;
         case ',':
-            if(tokens != NULL && parser->toksuper != -1 &&
-               tokens[parser->toksuper].type != JSMN_ARRAY &&
-               tokens[parser->toksuper].type != JSMN_OBJECT) {
+            if (tokens != NULL && parser->toksuper != -1 &&
+                tokens[parser->toksuper].type != JSMN_ARRAY &&
+                tokens[parser->toksuper].type != JSMN_OBJECT)
+            {
 #ifdef JSMN_PARENT_LINKS
                 parser->toksuper = tokens[parser->toksuper].parent;
 #else
-                for(i = parser->toknext - 1; i >= 0; i--) {
-                    if(tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
-                        if(tokens[i].start != -1 && tokens[i].end == -1) {
+                for (i = parser->toknext - 1; i >= 0; i--)
+                {
+                    if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT)
+                    {
+                        if (tokens[i].start != -1 && tokens[i].end == -1)
+                        {
                             parser->toksuper = i;
                             break;
                         }
@@ -340,9 +375,12 @@ int jsmn_parse(
         case 'f':
         case 'n':
             /* And they must not be keys of the object */
-            if(tokens != NULL && parser->toksuper != -1) {
-                const jsmntok_t* t = &tokens[parser->toksuper];
-                if(t->type == JSMN_OBJECT || (t->type == JSMN_STRING && t->size != 0)) {
+            if (tokens != NULL && parser->toksuper != -1)
+            {
+                const jsmntok_t *t = &tokens[parser->toksuper];
+                if (t->type == JSMN_OBJECT ||
+                    (t->type == JSMN_STRING && t->size != 0))
+                {
                     return JSMN_ERROR_INVAL;
                 }
             }
@@ -351,11 +389,13 @@ int jsmn_parse(
         default:
 #endif
             r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -368,10 +408,13 @@ int jsmn_parse(
         }
     }
 
-    if(tokens != NULL) {
-        for(i = parser->toknext - 1; i >= 0; i--) {
+    if (tokens != NULL)
+    {
+        for (i = parser->toknext - 1; i >= 0; i--)
+        {
             /* Unmatched opened object or array */
-            if(tokens[i].start != -1 && tokens[i].end == -1) {
+            if (tokens[i].start != -1 && tokens[i].end == -1)
+            {
                 return JSMN_ERROR_PART;
             }
         }
@@ -381,10 +424,12 @@ int jsmn_parse(
 }
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value) {
-    int length = strlen(key) + strlen(value) + 8; // Calculate required length
-    char* result = (char*)malloc(length * sizeof(char)); // Allocate memory
-    if(result == NULL) {
+char *jsmn(const char *key, const char *value)
+{
+    int length = strlen(key) + strlen(value) + 8;         // Calculate required length
+    char *result = (char *)malloc(length * sizeof(char)); // Allocate memory
+    if (result == NULL)
+    {
         return NULL; // Handle memory allocation failure
     }
     snprintf(result, length, "{\"%s\":\"%s\"}", key, value);
@@ -392,30 +437,36 @@ char* jsmn(const char* key, const char* value) {
 }
 
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s) {
-    if(tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
-       strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+    if (tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
+        strncmp(json + tok->start, s, tok->end - tok->start) == 0)
+    {
         return 0;
     }
     return -1;
 }
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens)
+{
     // Parse the JSON feed
-    if(json_data != NULL) {
+    if (json_data != NULL)
+    {
         jsmn_parser parser;
         jsmn_init(&parser);
 
         // Allocate tokens array on the heap
-        jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-        if(tokens == NULL) {
+        jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+        if (tokens == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
             return NULL;
         }
 
         int ret = jsmn_parse(&parser, json_data, strlen(json_data), tokens, max_tokens);
-        if(ret < 0) {
+        if (ret < 0)
+        {
             // Handle parsing errors
             FURI_LOG_E("JSMM.H", "Failed to parse JSON: %d", ret);
             free(tokens);
@@ -423,19 +474,23 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
         }
 
         // Ensure that the root element is an object
-        if(ret < 1 || tokens[0].type != JSMN_OBJECT) {
+        if (ret < 1 || tokens[0].type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Root element is not an object.");
             free(tokens);
             return NULL;
         }
 
         // Loop through the tokens to find the key
-        for(int i = 1; i < ret; i++) {
-            if(jsoneq(json_data, &tokens[i], key) == 0) {
+        for (int i = 1; i < ret; i++)
+        {
+            if (jsoneq(json_data, &tokens[i], key) == 0)
+            {
                 // We found the key. Now, return the associated value.
                 int length = tokens[i + 1].end - tokens[i + 1].start;
-                char* value = malloc(length + 1);
-                if(value == NULL) {
+                char *value = malloc(length + 1);
+                if (value == NULL)
+                {
                     FURI_LOG_E("JSMM.H", "Failed to allocate memory for value.");
                     free(tokens);
                     return NULL;
@@ -450,7 +505,9 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 
         // Free the token array if key was not found
         free(tokens);
-    } else {
+    }
+    else
+    {
         FURI_LOG_E("JSMM.H", "JSON data is NULL");
     }
     FURI_LOG_E("JSMM.H", "Failed to find the key in the JSON.");
@@ -458,10 +515,12 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 }
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens) {
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -471,8 +530,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -480,7 +540,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -488,7 +549,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Ensure the root element is an array
-    if(ret < 1 || tokens[0].type != JSMN_ARRAY) {
+    if (ret < 1 || tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -496,12 +558,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Check if the index is within bounds
-    if(index >= (uint32_t)tokens[0].size) {
-        FURI_LOG_E(
-            "JSMM.H",
-            "Index %lu out of bounds for array with size %d.",
-            (unsigned long)index,
-            tokens[0].size);
+    if (index >= (uint32_t)tokens[0].size)
+    {
+        FURI_LOG_E("JSMM.H", "Index %lu out of bounds for array with size %d.", (unsigned long)index, tokens[0].size);
         free(tokens);
         free(array_str);
         return NULL;
@@ -509,20 +568,27 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Locate the token corresponding to the desired array element
     int current_token = 1; // Start after the array token
-    for(uint32_t i = 0; i < index; i++) {
-        if(tokens[current_token].type == JSMN_OBJECT) {
+    for (uint32_t i = 0; i < index; i++)
+    {
+        if (tokens[current_token].type == JSMN_OBJECT)
+        {
             // For objects, skip all key-value pairs
             current_token += 1 + 2 * tokens[current_token].size;
-        } else if(tokens[current_token].type == JSMN_ARRAY) {
+        }
+        else if (tokens[current_token].type == JSMN_ARRAY)
+        {
             // For nested arrays, skip all elements
             current_token += 1 + tokens[current_token].size;
-        } else {
+        }
+        else
+        {
             // For primitive types, simply move to the next token
             current_token += 1;
         }
 
         // Safety check to prevent out-of-bounds
-        if(current_token >= ret) {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             free(tokens);
             free(array_str);
@@ -533,8 +599,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     // Extract the array element
     jsmntok_t element = tokens[current_token];
     int length = element.end - element.start;
-    char* value = malloc(length + 1);
-    if(value == NULL) {
+    char *value = malloc(length + 1);
+    if (value == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
         free(tokens);
         free(array_str);
@@ -553,10 +620,12 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 }
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values) {
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -566,8 +635,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -575,7 +645,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -583,7 +654,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     }
 
     // Ensure the root element is an array
-    if(tokens[0].type != JSMN_ARRAY) {
+    if (tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -592,8 +664,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Allocate memory for the array of values (maximum possible)
     int array_size = tokens[0].size;
-    char** values = malloc(array_size * sizeof(char*));
-    if(values == NULL) {
+    char **values = malloc(array_size * sizeof(char *));
+    if (values == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array of values.");
         free(tokens);
         free(array_str);
@@ -604,15 +677,18 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Traverse the array and extract all object values
     int current_token = 1; // Start after the array token
-    for(int i = 0; i < array_size; i++) {
-        if(current_token >= ret) {
+    for (int i = 0; i < array_size; i++)
+    {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             break;
         }
 
         jsmntok_t element = tokens[current_token];
 
-        if(element.type != JSMN_OBJECT) {
+        if (element.type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Array element %d is not an object, skipping.", i);
             // Skip this element
             current_token += 1;
@@ -622,10 +698,12 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
         int length = element.end - element.start;
 
         // Allocate a new string for the value and copy the data
-        char* value = malloc(length + 1);
-        if(value == NULL) {
+        char *value = malloc(length + 1);
+        if (value == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
-            for(int j = 0; j < actual_num_values; j++) {
+            for (int j = 0; j < actual_num_values; j++)
+            {
                 free(values[j]);
             }
             free(values);
@@ -647,14 +725,17 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     *num_values = actual_num_values;
 
     // Reallocate the values array to actual_num_values if necessary
-    if(actual_num_values < array_size) {
-        char** reduced_values = realloc(values, actual_num_values * sizeof(char*));
-        if(reduced_values != NULL) {
+    if (actual_num_values < array_size)
+    {
+        char **reduced_values = realloc(values, actual_num_values * sizeof(char *));
+        if (reduced_values != NULL)
+        {
             values = reduced_values;
         }
 
         // Free the remaining values
-        for(int i = actual_num_values; i < array_size; i++) {
+        for (int i = actual_num_values; i < array_size; i++)
+        {
             free(values[i]);
         }
     }

+ 49 - 48
flip_trader/jsmn/jsmn.h

@@ -19,7 +19,8 @@
 #include <stddef.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
 #ifdef JSMN_STATIC
@@ -28,71 +29,71 @@ extern "C" {
 #define JSMN_API extern
 #endif
 
-/**
+    /**
      * JSON type identifier. Basic types are:
      * 	o Object
      * 	o Array
      * 	o String
      * 	o Other primitive: number, boolean (true/false) or null
      */
-typedef enum {
-    JSMN_UNDEFINED = 0,
-    JSMN_OBJECT = 1 << 0,
-    JSMN_ARRAY = 1 << 1,
-    JSMN_STRING = 1 << 2,
-    JSMN_PRIMITIVE = 1 << 3
-} jsmntype_t;
-
-enum jsmnerr {
-    /* Not enough tokens were provided */
-    JSMN_ERROR_NOMEM = -1,
-    /* Invalid character inside JSON string */
-    JSMN_ERROR_INVAL = -2,
-    /* The string is not a full JSON packet, more bytes expected */
-    JSMN_ERROR_PART = -3
-};
-
-/**
+    typedef enum
+    {
+        JSMN_UNDEFINED = 0,
+        JSMN_OBJECT = 1 << 0,
+        JSMN_ARRAY = 1 << 1,
+        JSMN_STRING = 1 << 2,
+        JSMN_PRIMITIVE = 1 << 3
+    } jsmntype_t;
+
+    enum jsmnerr
+    {
+        /* Not enough tokens were provided */
+        JSMN_ERROR_NOMEM = -1,
+        /* Invalid character inside JSON string */
+        JSMN_ERROR_INVAL = -2,
+        /* The string is not a full JSON packet, more bytes expected */
+        JSMN_ERROR_PART = -3
+    };
+
+    /**
      * JSON token description.
      * type		type (object, array, string etc.)
      * start	start position in JSON data string
      * end		end position in JSON data string
      */
-typedef struct {
-    jsmntype_t type;
-    int start;
-    int end;
-    int size;
+    typedef struct
+    {
+        jsmntype_t type;
+        int start;
+        int end;
+        int size;
 #ifdef JSMN_PARENT_LINKS
-    int parent;
+        int parent;
 #endif
-} jsmntok_t;
+    } jsmntok_t;
 
-/**
+    /**
      * JSON parser. Contains an array of token blocks available. Also stores
      * the string being parsed now and current position in that string.
      */
-typedef struct {
-    unsigned int pos; /* offset in the JSON string */
-    unsigned int toknext; /* next token to allocate */
-    int toksuper; /* superior token node, e.g. parent object or array */
-} jsmn_parser;
-
-/**
+    typedef struct
+    {
+        unsigned int pos;     /* offset in the JSON string */
+        unsigned int toknext; /* next token to allocate */
+        int toksuper;         /* superior token node, e.g. parent object or array */
+    } jsmn_parser;
+
+    /**
      * Create JSON parser over an array of tokens
      */
-JSMN_API void jsmn_init(jsmn_parser* parser);
+    JSMN_API void jsmn_init(jsmn_parser *parser);
 
-/**
+    /**
      * Run JSON parser. It parses a JSON data string into and array of tokens, each
      * describing a single JSON object.
      */
-JSMN_API int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens);
+    JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+                            jsmntok_t *tokens, const unsigned int num_tokens);
 
 #ifndef JSMN_HEADER
 /* Implementation has been moved to jsmn.c */
@@ -116,16 +117,16 @@ JSMN_API int jsmn_parse(
 #include <furi.h>
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value);
+char *jsmn(const char *key, const char *value);
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s);
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens);
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens);
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values);
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values);
 #endif /* JB_JSMN_EDIT */

+ 50 - 104
flip_weather/alloc/flip_weather_alloc.c

@@ -1,13 +1,15 @@
 #include <alloc/flip_weather_alloc.h>
 
 // Function to allocate resources for the FlipWeatherApp
-FlipWeatherApp* flip_weather_app_alloc() {
-    FlipWeatherApp* app = (FlipWeatherApp*)malloc(sizeof(FlipWeatherApp));
+FlipWeatherApp *flip_weather_app_alloc()
+{
+    FlipWeatherApp *app = (FlipWeatherApp *)malloc(sizeof(FlipWeatherApp));
 
-    Gui* gui = furi_record_open(RECORD_GUI);
+    Gui *gui = furi_record_open(RECORD_GUI);
 
     // initialize uart
-    if(!flipper_http_init(flipper_http_rx_callback, app)) {
+    if (!flipper_http_init(flipper_http_rx_callback, app))
+    {
         FURI_LOG_E(TAG, "Failed to initialize flipper http");
         return NULL;
     }
@@ -15,150 +17,94 @@ FlipWeatherApp* flip_weather_app_alloc() {
     // Allocate the text input buffer
     app->uart_text_input_buffer_size_ssid = 64;
     app->uart_text_input_buffer_size_password = 64;
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(
-           &app->uart_text_input_temp_buffer_password,
-           app->uart_text_input_buffer_size_password)) {
+    if (!easy_flipper_set_buffer(&app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_size_password))
+    {
         return NULL;
     }
 
     // Allocate ViewDispatcher
-    if(!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app)) {
+    if (!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app))
+    {
         return NULL;
     }
-    view_dispatcher_set_custom_event_callback(
-        app->view_dispatcher, flip_weather_custom_event_callback);
+    view_dispatcher_set_custom_event_callback(app->view_dispatcher, flip_weather_custom_event_callback);
     // Main view
-    if(!easy_flipper_set_view(
-           &app->view_loader,
-           FlipWeatherViewLoader,
-           flip_weather_loader_draw_callback,
-           NULL,
-           callback_to_submenu,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_view(&app->view_loader, FlipWeatherViewLoader, flip_weather_loader_draw_callback, NULL, callback_to_submenu, &app->view_dispatcher, app))
+    {
         return NULL;
     }
     flip_weather_loader_init(app->view_loader);
 
     // Widget
-    if(!easy_flipper_set_widget(
-           &app->widget,
-           FlipWeatherViewAbout,
-           "FlipWeather v1.2\n-----\nUse WiFi to get GPS and \nWeather information.\n-----\nwww.github.com/jblanked",
-           callback_to_submenu,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget, FlipWeatherViewAbout, "FlipWeather v1.2\n-----\nUse WiFi to get GPS and \nWeather information.\n-----\nwww.github.com/jblanked", callback_to_submenu, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_widget(
-           &app->widget_result,
-           FlipWeatherViewWidgetResult,
-           "Error, try again.",
-           callback_to_submenu,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_result, FlipWeatherViewWidgetResult, "Error, try again.", callback_to_submenu, &app->view_dispatcher))
+    {
         return NULL;
     }
 
     // Text Input
-    if(!easy_flipper_set_uart_text_input(
-           &app->uart_text_input_ssid,
-           FlipWeatherViewTextInputSSID,
-           "Enter SSID",
-           app->uart_text_input_temp_buffer_ssid,
-           app->uart_text_input_buffer_size_ssid,
-           text_updated_ssid,
-           callback_to_wifi_settings,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_uart_text_input(&app->uart_text_input_ssid, FlipWeatherViewTextInputSSID, "Enter SSID", app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid, text_updated_ssid, callback_to_wifi_settings, &app->view_dispatcher, app))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_uart_text_input(
-           &app->uart_text_input_password,
-           FlipWeatherViewTextInputPassword,
-           "Enter Password",
-           app->uart_text_input_temp_buffer_password,
-           app->uart_text_input_buffer_size_password,
-           text_updated_password,
-           callback_to_wifi_settings,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_uart_text_input(&app->uart_text_input_password, FlipWeatherViewTextInputPassword, "Enter Password", app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_size_password, text_updated_password, callback_to_wifi_settings, &app->view_dispatcher, app))
+    {
         return NULL;
     }
 
     // Variable Item List
-    if(!easy_flipper_set_variable_item_list(
-           &app->variable_item_list,
-           FlipWeatherViewSettings,
-           settings_item_selected,
-           callback_to_submenu,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_variable_item_list(&app->variable_item_list, FlipWeatherViewSettings, settings_item_selected, callback_to_submenu, &app->view_dispatcher, app))
+    {
         return NULL;
     }
-    app->variable_item_ssid =
-        variable_item_list_add(app->variable_item_list, "SSID", 0, NULL, NULL);
-    app->variable_item_password =
-        variable_item_list_add(app->variable_item_list, "Password", 0, NULL, NULL);
+    app->variable_item_ssid = variable_item_list_add(app->variable_item_list, "SSID", 0, NULL, NULL);
+    app->variable_item_password = variable_item_list_add(app->variable_item_list, "Password", 0, NULL, NULL);
     variable_item_set_current_value_text(app->variable_item_ssid, "");
     variable_item_set_current_value_text(app->variable_item_password, "");
 
     // Submenu
-    if(!easy_flipper_set_submenu(
-           &app->submenu,
-           FlipWeatherViewSubmenu,
-           "FlipWeather v1.2",
-           callback_exit_app,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_submenu(&app->submenu, FlipWeatherViewSubmenu, "FlipWeather v1.2", callback_exit_app, &app->view_dispatcher))
+    {
         return NULL;
     }
-    submenu_add_item(
-        app->submenu, "Weather", FlipWeatherSubmenuIndexWeather, callback_submenu_choices, app);
-    submenu_add_item(
-        app->submenu, "GPS", FlipWeatherSubmenuIndexGPS, callback_submenu_choices, app);
-    submenu_add_item(
-        app->submenu, "About", FlipWeatherSubmenuIndexAbout, callback_submenu_choices, app);
-    submenu_add_item(
-        app->submenu, "Settings", FlipWeatherSubmenuIndexSettings, callback_submenu_choices, app);
+    submenu_add_item(app->submenu, "Weather", FlipWeatherSubmenuIndexWeather, callback_submenu_choices, app);
+    submenu_add_item(app->submenu, "GPS", FlipWeatherSubmenuIndexGPS, callback_submenu_choices, app);
+    submenu_add_item(app->submenu, "About", FlipWeatherSubmenuIndexAbout, callback_submenu_choices, app);
+    submenu_add_item(app->submenu, "Settings", FlipWeatherSubmenuIndexSettings, callback_submenu_choices, app);
 
     // load settings
-    if(load_settings(
-           app->uart_text_input_buffer_ssid,
-           app->uart_text_input_buffer_size_ssid,
-           app->uart_text_input_buffer_password,
-           app->uart_text_input_buffer_size_password)) {
+    if (load_settings(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid, app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password))
+    {
         // Update variable items
-        if(app->variable_item_ssid)
-            variable_item_set_current_value_text(
-                app->variable_item_ssid, app->uart_text_input_buffer_ssid);
+        if (app->variable_item_ssid)
+            variable_item_set_current_value_text(app->variable_item_ssid, app->uart_text_input_buffer_ssid);
         // dont show password
 
         // Copy items into their temp buffers with safety checks
-        if(app->uart_text_input_buffer_ssid && app->uart_text_input_temp_buffer_ssid) {
-            strncpy(
-                app->uart_text_input_temp_buffer_ssid,
-                app->uart_text_input_buffer_ssid,
-                app->uart_text_input_buffer_size_ssid - 1);
-            app->uart_text_input_temp_buffer_ssid[app->uart_text_input_buffer_size_ssid - 1] =
-                '\0';
+        if (app->uart_text_input_buffer_ssid && app->uart_text_input_temp_buffer_ssid)
+        {
+            strncpy(app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_size_ssid - 1);
+            app->uart_text_input_temp_buffer_ssid[app->uart_text_input_buffer_size_ssid - 1] = '\0';
         }
-        if(app->uart_text_input_buffer_password && app->uart_text_input_temp_buffer_password) {
-            strncpy(
-                app->uart_text_input_temp_buffer_password,
-                app->uart_text_input_buffer_password,
-                app->uart_text_input_buffer_size_password - 1);
-            app->uart_text_input_temp_buffer_password[app->uart_text_input_buffer_size_password - 1] =
-                '\0';
+        if (app->uart_text_input_buffer_password && app->uart_text_input_temp_buffer_password)
+        {
+            strncpy(app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_password, app->uart_text_input_buffer_size_password - 1);
+            app->uart_text_input_temp_buffer_password[app->uart_text_input_buffer_size_password - 1] = '\0';
         }
     }
 
@@ -166,4 +112,4 @@ FlipWeatherApp* flip_weather_app_alloc() {
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipWeatherViewSubmenu);
 
     return app;
-}
+}

+ 2 - 2
flip_weather/alloc/flip_weather_alloc.h

@@ -3,6 +3,6 @@
 #include <flip_weather.h>
 #include <callback/flip_weather_callback.h>
 #include <flip_storage/flip_weather_storage.h>
-FlipWeatherApp* flip_weather_app_alloc();
+FlipWeatherApp *flip_weather_app_alloc();
 
-#endif
+#endif

+ 15 - 9
flip_weather/app.c

@@ -2,35 +2,41 @@
 #include <alloc/flip_weather_alloc.h>
 
 // Entry point for the FlipWeather application
-int32_t flip_weather_app(void* p) {
+int32_t flip_weather_app(void *p)
+{
     // Suppress unused parameter warning
     UNUSED(p);
 
     // Initialize the FlipWeather application
     app_instance = flip_weather_app_alloc();
-    if(!app_instance) {
+    if (!app_instance)
+    {
         FURI_LOG_E(TAG, "Failed to allocate FlipWeatherApp");
         return -1;
     }
 
-    if(!flipper_http_ping()) {
+    if (!flipper_http_ping())
+    {
         FURI_LOG_E(TAG, "Failed to ping the device");
         return -1;
     }
 
     // Thanks to Derek Jamison for the following edits
-    if(app_instance->uart_text_input_buffer_ssid != NULL &&
-       app_instance->uart_text_input_buffer_password != NULL) {
+    if (app_instance->uart_text_input_buffer_ssid != NULL &&
+        app_instance->uart_text_input_buffer_password != NULL)
+    {
         // Try to wait for pong response.
         uint8_t counter = 10;
-        while(fhttp.state == INACTIVE && --counter > 0) {
+        while (fhttp.state == INACTIVE && --counter > 0)
+        {
             FURI_LOG_D(TAG, "Waiting for PONG");
             furi_delay_ms(100);
         }
 
-        if(counter == 0) {
-            DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
-            DialogMessage* message = dialog_message_alloc();
+        if (counter == 0)
+        {
+            DialogsApp *dialogs = furi_record_open(RECORD_DIALOGS);
+            DialogMessage *message = dialog_message_alloc();
             dialog_message_set_header(
                 message, "[FlipperHTTP Error]", 64, 0, AlignCenter, AlignTop);
             dialog_message_set_text(

+ 1 - 1
flip_weather/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.2",
+    fap_version = "1.2",
 )

+ 266 - 210
flip_weather/callback/flip_weather_callback.c

@@ -3,8 +3,7 @@
 // Below added by Derek Jamison
 // FURI_LOG_DEV will log only during app development. Be sure that Settings/System/Log Device is "LPUART"; so we dont use serial port.
 #ifdef DEVELOPMENT
-#define FURI_LOG_DEV(tag, format, ...) \
-    furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
+#define FURI_LOG_DEV(tag, format, ...) furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
 #define DEV_CRASH() furi_crash()
 #else
 #define FURI_LOG_DEV(tag, format, ...)
@@ -15,83 +14,80 @@ bool weather_request_success = false;
 bool sent_weather_request = false;
 bool got_weather_data = false;
 
-static void flip_weather_request_error_draw(Canvas* canvas) {
-    if(canvas == NULL) {
+static void flip_weather_request_error_draw(Canvas *canvas)
+{
+    if (canvas == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_request_error_draw - canvas is NULL");
         DEV_CRASH();
         return;
     }
-    if(fhttp.last_response != NULL) {
-        if(strstr(fhttp.last_response, "[ERROR] Not connected to Wifi. Failed to reconnect.") !=
-           NULL) {
+    if (fhttp.last_response != NULL)
+    {
+        if (strstr(fhttp.last_response, "[ERROR] Not connected to Wifi. Failed to reconnect.") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[ERROR] Not connected to Wifi.");
             canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
             canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        } else if(strstr(fhttp.last_response, "[ERROR] Failed to connect to Wifi.") != NULL) {
+        }
+        else if (strstr(fhttp.last_response, "[ERROR] Failed to connect to Wifi.") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[ERROR] Not connected to Wifi.");
             canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
             canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        } else if(
-            strstr(fhttp.last_response, "[ERROR] GET request failed or returned empty data.") !=
-            NULL) {
+        }
+        else if (strstr(fhttp.last_response, "[ERROR] GET request failed or returned empty data.") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[ERROR] WiFi error.");
             canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
             canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
-        } else if(strstr(fhttp.last_response, "[PONG]") != NULL) {
+        }
+        else if (strstr(fhttp.last_response, "[PONG]") != NULL)
+        {
             canvas_clear(canvas);
             canvas_draw_str(canvas, 0, 10, "[STATUS]Connecting to AP...");
-        } else {
+        }
+        else
+        {
             canvas_clear(canvas);
             FURI_LOG_E(TAG, "Received an error: %s", fhttp.last_response);
             canvas_draw_str(canvas, 0, 10, "[ERROR] Unusual error...");
             canvas_draw_str(canvas, 0, 60, "Press BACK and retry.");
         }
-    } else {
+    }
+    else
+    {
         canvas_clear(canvas);
         canvas_draw_str(canvas, 0, 10, "[ERROR] Unknown error.");
         canvas_draw_str(canvas, 0, 50, "Update your WiFi settings.");
         canvas_draw_str(canvas, 0, 60, "Press BACK to return.");
     }
 }
-static void flip_weather_gps_switch_to_view(FlipWeatherApp* app) {
-    flip_weather_generic_switch_to_view(
-        app,
-        "Fetching GPS data..",
-        send_geo_location_request,
-        process_geo_location,
-        1,
-        callback_to_submenu,
-        FlipWeatherViewLoader);
+static void flip_weather_gps_switch_to_view(FlipWeatherApp *app)
+{
+    flip_weather_generic_switch_to_view(app, "Fetching GPS data..", send_geo_location_request, process_geo_location, 1, callback_to_submenu, FlipWeatherViewLoader);
 }
 
-static void flip_weather_weather_switch_to_view(FlipWeatherApp* app) {
-    flip_weather_generic_switch_to_view(
-        app,
-        "Fetching Weather data..",
-        send_geo_weather_request,
-        process_weather,
-        1,
-        callback_to_submenu,
-        FlipWeatherViewLoader);
+static void flip_weather_weather_switch_to_view(FlipWeatherApp *app)
+{
+    flip_weather_generic_switch_to_view(app, "Fetching Weather data..", send_geo_weather_request, process_weather, 1, callback_to_submenu, FlipWeatherViewLoader);
 }
 
-void callback_submenu_choices(void* context, uint32_t index) {
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    if(!app) {
+void callback_submenu_choices(void *context, uint32_t index)
+{
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipWeatherApp is NULL");
         return;
     }
-    switch(index) {
+    switch (index)
+    {
     case FlipWeatherSubmenuIndexWeather:
-        flipper_http_loading_task(
-            send_geo_location_request,
-            process_geo_location_2,
-            FlipWeatherViewSubmenu,
-            FlipWeatherViewSubmenu,
-            &app->view_dispatcher);
+        flipper_http_loading_task(send_geo_location_request, process_geo_location_2, FlipWeatherViewSubmenu, FlipWeatherViewSubmenu, &app->view_dispatcher);
         flip_weather_weather_switch_to_view(app);
         break;
     case FlipWeatherSubmenuIndexGPS:
@@ -108,36 +104,35 @@ void callback_submenu_choices(void* context, uint32_t index) {
     }
 }
 
-void text_updated_ssid(void* context) {
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    if(!app) {
+void text_updated_ssid(void *context)
+{
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipWeatherApp is NULL");
         return;
     }
 
     // store the entered text
-    strncpy(
-        app->uart_text_input_buffer_ssid,
-        app->uart_text_input_temp_buffer_ssid,
-        app->uart_text_input_buffer_size_ssid);
+    strncpy(app->uart_text_input_buffer_ssid, app->uart_text_input_temp_buffer_ssid, app->uart_text_input_buffer_size_ssid);
 
     // Ensure null-termination
     app->uart_text_input_buffer_ssid[app->uart_text_input_buffer_size_ssid - 1] = '\0';
 
     // update the variable item text
-    if(app->variable_item_ssid) {
-        variable_item_set_current_value_text(
-            app->variable_item_ssid, app->uart_text_input_buffer_ssid);
+    if (app->variable_item_ssid)
+    {
+        variable_item_set_current_value_text(app->variable_item_ssid, app->uart_text_input_buffer_ssid);
     }
 
     // save settings
     save_settings(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password);
 
     // save wifi settings to devboard
-    if(strlen(app->uart_text_input_buffer_ssid) > 0 &&
-       strlen(app->uart_text_input_buffer_password) > 0) {
-        if(!flipper_http_save_wifi(
-               app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password)) {
+    if (strlen(app->uart_text_input_buffer_ssid) > 0 && strlen(app->uart_text_input_buffer_password) > 0)
+    {
+        if (!flipper_http_save_wifi(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password))
+        {
             FURI_LOG_E(TAG, "Failed to save wifi settings");
         }
     }
@@ -146,36 +141,35 @@ void text_updated_ssid(void* context) {
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipWeatherViewSettings);
 }
 
-void text_updated_password(void* context) {
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    if(!app) {
+void text_updated_password(void *context)
+{
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipWeatherApp is NULL");
         return;
     }
 
     // store the entered text
-    strncpy(
-        app->uart_text_input_buffer_password,
-        app->uart_text_input_temp_buffer_password,
-        app->uart_text_input_buffer_size_password);
+    strncpy(app->uart_text_input_buffer_password, app->uart_text_input_temp_buffer_password, app->uart_text_input_buffer_size_password);
 
     // Ensure null-termination
     app->uart_text_input_buffer_password[app->uart_text_input_buffer_size_password - 1] = '\0';
 
     // update the variable item text
-    if(app->variable_item_password) {
-        variable_item_set_current_value_text(
-            app->variable_item_password, app->uart_text_input_buffer_password);
+    if (app->variable_item_password)
+    {
+        variable_item_set_current_value_text(app->variable_item_password, app->uart_text_input_buffer_password);
     }
 
     // save settings
     save_settings(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password);
 
     // save wifi settings to devboard
-    if(strlen(app->uart_text_input_buffer_ssid) > 0 &&
-       strlen(app->uart_text_input_buffer_password) > 0) {
-        if(!flipper_http_save_wifi(
-               app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password)) {
+    if (strlen(app->uart_text_input_buffer_ssid) > 0 && strlen(app->uart_text_input_buffer_password) > 0)
+    {
+        if (!flipper_http_save_wifi(app->uart_text_input_buffer_ssid, app->uart_text_input_buffer_password))
+        {
             FURI_LOG_E(TAG, "Failed to save wifi settings");
         }
     }
@@ -184,8 +178,10 @@ void text_updated_password(void* context) {
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipWeatherViewSettings);
 }
 
-uint32_t callback_to_submenu(void* context) {
-    if(!context) {
+uint32_t callback_to_submenu(void *context)
+{
+    if (!context)
+    {
         FURI_LOG_E(TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -198,24 +194,29 @@ uint32_t callback_to_submenu(void* context) {
     weather_information_processed = false;
     sent_weather_request = false;
     weather_request_success = false;
-    if(weather_data != NULL) {
+    if (weather_data != NULL)
+    {
         free(weather_data);
         weather_data = NULL;
     }
-    if(total_data != NULL) {
+    if (total_data != NULL)
+    {
         free(total_data);
         total_data = NULL;
     }
     return FlipWeatherViewSubmenu;
 }
 
-void settings_item_selected(void* context, uint32_t index) {
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    if(!app) {
+void settings_item_selected(void *context, uint32_t index)
+{
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipWeatherApp is NULL");
         return;
     }
-    switch(index) {
+    switch (index)
+    {
     case 0: // Input SSID
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipWeatherViewTextInputSSID);
         break;
@@ -233,9 +234,11 @@ void settings_item_selected(void* context, uint32_t index) {
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t callback_exit_app(void* context) {
+uint32_t callback_exit_app(void *context)
+{
     // Exit the application
-    if(!context) {
+    if (!context)
+    {
         FURI_LOG_E(TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -243,8 +246,10 @@ uint32_t callback_exit_app(void* context) {
     return VIEW_NONE; // Return VIEW_NONE to exit the app
 }
 
-uint32_t callback_to_wifi_settings(void* context) {
-    if(!context) {
+uint32_t callback_to_wifi_settings(void *context)
+{
+    if (!context)
+    {
         FURI_LOG_E(TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -252,13 +257,16 @@ uint32_t callback_to_wifi_settings(void* context) {
     return FlipWeatherViewSettings;
 }
 
-static void flip_weather_widget_set_text(char* message, Widget** widget) {
-    if(widget == NULL) {
+static void flip_weather_widget_set_text(char *message, Widget **widget)
+{
+    if (widget == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_set_widget_text - widget is NULL");
         DEV_CRASH();
         return;
     }
-    if(message == NULL) {
+    if (message == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_set_widget_text - message is NULL");
         DEV_CRASH();
         return;
@@ -266,32 +274,36 @@ static void flip_weather_widget_set_text(char* message, Widget** widget) {
     widget_reset(*widget);
 
     uint32_t message_length = strlen(message); // Length of the message
-    uint32_t i = 0; // Index tracker
-    uint32_t formatted_index = 0; // Tracker for where we are in the formatted message
-    char* formatted_message; // Buffer to hold the final formatted message
+    uint32_t i = 0;                            // Index tracker
+    uint32_t formatted_index = 0;              // Tracker for where we are in the formatted message
+    char *formatted_message;                   // Buffer to hold the final formatted message
 
     // Allocate buffer with double the message length plus one for safety
-    if(!easy_flipper_set_buffer(&formatted_message, message_length * 2 + 1)) {
+    if (!easy_flipper_set_buffer(&formatted_message, message_length * 2 + 1))
+    {
         return;
     }
 
-    while(i < message_length) {
-        uint32_t max_line_length = 31; // Maximum characters per line
+    while (i < message_length)
+    {
+        uint32_t max_line_length = 31;                  // Maximum characters per line
         uint32_t remaining_length = message_length - i; // Remaining characters
-        uint32_t line_length = (remaining_length < max_line_length) ? remaining_length :
-                                                                      max_line_length;
+        uint32_t line_length = (remaining_length < max_line_length) ? remaining_length : max_line_length;
 
         // Check for newline character within the current segment
         uint32_t newline_pos = i;
         bool found_newline = false;
-        for(; newline_pos < i + line_length && newline_pos < message_length; newline_pos++) {
-            if(message[newline_pos] == '\n') {
+        for (; newline_pos < i + line_length && newline_pos < message_length; newline_pos++)
+        {
+            if (message[newline_pos] == '\n')
+            {
                 found_newline = true;
                 break;
             }
         }
 
-        if(found_newline) {
+        if (found_newline)
+        {
             // If newline found, set line_length up to the newline
             line_length = newline_pos - i;
         }
@@ -302,15 +314,19 @@ static void flip_weather_widget_set_text(char* message, Widget** widget) {
         line[line_length] = '\0';
 
         // If newline was found, skip it for the next iteration
-        if(found_newline) {
+        if (found_newline)
+        {
             i += line_length + 1; // +1 to skip the '\n' character
-        } else {
+        }
+        else
+        {
             // Check if the line ends in the middle of a word and adjust accordingly
-            if(line_length == max_line_length && message[i + line_length] != '\0' &&
-               message[i + line_length] != ' ') {
+            if (line_length == max_line_length && message[i + line_length] != '\0' && message[i + line_length] != ' ')
+            {
                 // Find the last space within the current line to avoid breaking a word
-                char* last_space = strrchr(line, ' ');
-                if(last_space != NULL) {
+                char *last_space = strrchr(line, ' ');
+                if (last_space != NULL)
+                {
                     // Adjust the line_length to avoid cutting the word
                     line_length = last_space - line;
                     line[line_length] = '\0'; // Null-terminate at the space
@@ -321,13 +337,15 @@ static void flip_weather_widget_set_text(char* message, Widget** widget) {
             i += line_length;
 
             // Skip any spaces at the beginning of the next line
-            while(i < message_length && message[i] == ' ') {
+            while (i < message_length && message[i] == ' ')
+            {
                 i++;
             }
         }
 
         // Manually copy the fixed line into the formatted_message buffer
-        for(uint32_t j = 0; j < line_length; j++) {
+        for (uint32_t j = 0; j < line_length; j++)
+        {
             formatted_message[formatted_index++] = line[j];
         }
 
@@ -342,20 +360,23 @@ static void flip_weather_widget_set_text(char* message, Widget** widget) {
     widget_add_text_scroll_element(*widget, 0, 0, 128, 64, formatted_message);
 }
 
-void flip_weather_loader_draw_callback(Canvas* canvas, void* model) {
-    if(!canvas || !model) {
+void flip_weather_loader_draw_callback(Canvas *canvas, void *model)
+{
+    if (!canvas || !model)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_draw_callback - canvas or model is NULL");
         return;
     }
 
     SerialState http_state = fhttp.state;
-    DataLoaderModel* data_loader_model = (DataLoaderModel*)model;
+    DataLoaderModel *data_loader_model = (DataLoaderModel *)model;
     DataState data_state = data_loader_model->data_state;
-    char* title = data_loader_model->title;
+    char *title = data_loader_model->title;
 
     canvas_set_font(canvas, FontSecondary);
 
-    if(http_state == INACTIVE) {
+    if (http_state == INACTIVE)
+    {
         canvas_draw_str(canvas, 0, 7, "Wifi Dev Board disconnected.");
         canvas_draw_str(canvas, 0, 17, "Please connect to the board.");
         canvas_draw_str(canvas, 0, 32, "If your board is connected,");
@@ -365,7 +386,8 @@ void flip_weather_loader_draw_callback(Canvas* canvas, void* model) {
         return;
     }
 
-    if(data_state == DataStateError || data_state == DataStateParseError) {
+    if (data_state == DataStateError || data_state == DataStateParseError)
+    {
         flip_weather_request_error_draw(canvas);
         return;
     }
@@ -373,53 +395,61 @@ void flip_weather_loader_draw_callback(Canvas* canvas, void* model) {
     canvas_draw_str(canvas, 0, 7, title);
     canvas_draw_str(canvas, 0, 17, "Loading...");
 
-    if(data_state == DataStateInitial) {
+    if (data_state == DataStateInitial)
+    {
         return;
     }
 
-    if(http_state == SENDING) {
+    if (http_state == SENDING)
+    {
         canvas_draw_str(canvas, 0, 27, "Sending...");
         return;
     }
 
-    if(http_state == RECEIVING || data_state == DataStateRequested) {
+    if (http_state == RECEIVING || data_state == DataStateRequested)
+    {
         canvas_draw_str(canvas, 0, 27, "Receiving...");
         return;
     }
 
-    if(http_state == IDLE && data_state == DataStateReceived) {
+    if (http_state == IDLE && data_state == DataStateReceived)
+    {
         canvas_draw_str(canvas, 0, 27, "Processing...");
         return;
     }
 
-    if(http_state == IDLE && data_state == DataStateParsed) {
+    if (http_state == IDLE && data_state == DataStateParsed)
+    {
         canvas_draw_str(canvas, 0, 27, "Processed...");
         return;
     }
 }
 
-static void flip_weather_loader_process_callback(void* context) {
-    if(context == NULL) {
+static void flip_weather_loader_process_callback(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_process_callback - context is NULL");
         DEV_CRASH();
         return;
     }
 
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    View* view = app->view_loader;
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    View *view = app->view_loader;
 
     DataState current_data_state;
-    with_view_model(
-        view, DataLoaderModel * model, { current_data_state = model->data_state; }, false);
+    with_view_model(view, DataLoaderModel * model, { current_data_state = model->data_state; }, false);
 
-    if(current_data_state == DataStateInitial) {
+    if (current_data_state == DataStateInitial)
+    {
         with_view_model(
             view,
             DataLoaderModel * model,
             {
                 model->data_state = DataStateRequested;
                 DataLoaderFetch fetch = model->fetcher;
-                if(fetch == NULL) {
+                if (fetch == NULL)
+                {
                     FURI_LOG_E(TAG, "Model doesn't have Fetch function assigned.");
                     model->data_state = DataStateError;
                     return;
@@ -428,151 +458,174 @@ static void flip_weather_loader_process_callback(void* context) {
                 // Clear any previous responses
                 strncpy(fhttp.last_response, "", 1);
                 bool request_status = fetch(model);
-                if(!request_status) {
+                if (!request_status)
+                {
                     model->data_state = DataStateError;
                 }
             },
             true);
-    } else if(current_data_state == DataStateRequested || current_data_state == DataStateError) {
-        if(fhttp.state == IDLE && fhttp.last_response != NULL) {
-            if(strstr(fhttp.last_response, "[PONG]") != NULL) {
+    }
+    else if (current_data_state == DataStateRequested || current_data_state == DataStateError)
+    {
+        if (fhttp.state == IDLE && fhttp.last_response != NULL)
+        {
+            if (strstr(fhttp.last_response, "[PONG]") != NULL)
+            {
                 FURI_LOG_DEV(TAG, "PONG received.");
-            } else if(strncmp(fhttp.last_response, "[SUCCESS]", 9) == 0) {
-                FURI_LOG_DEV(
-                    TAG,
-                    "SUCCESS received. %s",
-                    fhttp.last_response ? fhttp.last_response : "NULL");
-            } else if(strncmp(fhttp.last_response, "[ERROR]", 9) == 0) {
-                FURI_LOG_DEV(
-                    TAG, "ERROR received. %s", fhttp.last_response ? fhttp.last_response : "NULL");
-            } else if(strlen(fhttp.last_response) == 0) {
+            }
+            else if (strncmp(fhttp.last_response, "[SUCCESS]", 9) == 0)
+            {
+                FURI_LOG_DEV(TAG, "SUCCESS received. %s", fhttp.last_response ? fhttp.last_response : "NULL");
+            }
+            else if (strncmp(fhttp.last_response, "[ERROR]", 9) == 0)
+            {
+                FURI_LOG_DEV(TAG, "ERROR received. %s", fhttp.last_response ? fhttp.last_response : "NULL");
+            }
+            else if (strlen(fhttp.last_response) == 0)
+            {
                 // Still waiting on response
-            } else {
-                with_view_model(
-                    view,
-                    DataLoaderModel * model,
-                    { model->data_state = DataStateReceived; },
-                    true);
             }
-        } else if(fhttp.state == SENDING || fhttp.state == RECEIVING) {
+            else
+            {
+                with_view_model(view, DataLoaderModel * model, { model->data_state = DataStateReceived; }, true);
+            }
+        }
+        else if (fhttp.state == SENDING || fhttp.state == RECEIVING)
+        {
             // continue waiting
-        } else if(fhttp.state == INACTIVE) {
+        }
+        else if (fhttp.state == INACTIVE)
+        {
             // inactive. try again
-        } else if(fhttp.state == ISSUE) {
-            with_view_model(
-                view, DataLoaderModel * model, { model->data_state = DataStateError; }, true);
-        } else {
-            FURI_LOG_DEV(
-                TAG,
-                "Unexpected state: %d lastresp: %s",
-                fhttp.state,
-                fhttp.last_response ? fhttp.last_response : "NULL");
+        }
+        else if (fhttp.state == ISSUE)
+        {
+            with_view_model(view, DataLoaderModel * model, { model->data_state = DataStateError; }, true);
+        }
+        else
+        {
+            FURI_LOG_DEV(TAG, "Unexpected state: %d lastresp: %s", fhttp.state, fhttp.last_response ? fhttp.last_response : "NULL");
             DEV_CRASH();
         }
-    } else if(current_data_state == DataStateReceived) {
+    }
+    else if (current_data_state == DataStateReceived)
+    {
         with_view_model(
             view,
             DataLoaderModel * model,
             {
-                char* data_text;
-                if(model->parser == NULL) {
+                char *data_text;
+                if (model->parser == NULL)
+                {
                     data_text = NULL;
                     FURI_LOG_DEV(TAG, "Parser is NULL");
                     DEV_CRASH();
-                } else {
+                }
+                else
+                {
                     data_text = model->parser(model);
                 }
-                FURI_LOG_DEV(
-                    TAG,
-                    "Parsed data: %s\r\ntext: %s",
-                    fhttp.last_response ? fhttp.last_response : "NULL",
-                    data_text ? data_text : "NULL");
+                FURI_LOG_DEV(TAG, "Parsed data: %s\r\ntext: %s", fhttp.last_response ? fhttp.last_response : "NULL", data_text ? data_text : "NULL");
                 model->data_text = data_text;
-                if(data_text == NULL) {
+                if (data_text == NULL)
+                {
                     model->data_state = DataStateParseError;
-                } else {
+                }
+                else
+                {
                     model->data_state = DataStateParsed;
                 }
             },
             true);
-    } else if(current_data_state == DataStateParsed) {
+    }
+    else if (current_data_state == DataStateParsed)
+    {
         with_view_model(
             view,
             DataLoaderModel * model,
             {
-                if(++model->request_index < model->request_count) {
+                if (++model->request_index < model->request_count)
+                {
                     model->data_state = DataStateInitial;
-                } else {
-                    flip_weather_widget_set_text(
-                        model->data_text != NULL ? model->data_text : "Empty result",
-                        &app_instance->widget_result);
-                    if(model->data_text != NULL) {
+                }
+                else
+                {
+                    flip_weather_widget_set_text(model->data_text != NULL ? model->data_text : "Empty result", &app_instance->widget_result);
+                    if (model->data_text != NULL)
+                    {
                         free(model->data_text);
                         model->data_text = NULL;
                     }
-                    view_set_previous_callback(
-                        widget_get_view(app_instance->widget_result), model->back_callback);
-                    view_dispatcher_switch_to_view(
-                        app_instance->view_dispatcher, FlipWeatherViewWidgetResult);
+                    view_set_previous_callback(widget_get_view(app_instance->widget_result), model->back_callback);
+                    view_dispatcher_switch_to_view(app_instance->view_dispatcher, FlipWeatherViewWidgetResult);
                 }
             },
             true);
     }
 }
 
-static void flip_weather_loader_timer_callback(void* context) {
-    if(context == NULL) {
+static void flip_weather_loader_timer_callback(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_timer_callback - context is NULL");
         DEV_CRASH();
         return;
     }
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
     view_dispatcher_send_custom_event(app->view_dispatcher, FlipWeatherCustomEventProcess);
 }
 
-static void flip_weather_loader_on_enter(void* context) {
-    if(context == NULL) {
+static void flip_weather_loader_on_enter(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_on_enter - context is NULL");
         DEV_CRASH();
         return;
     }
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    View* view = app->view_loader;
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    View *view = app->view_loader;
     with_view_model(
         view,
         DataLoaderModel * model,
         {
             view_set_previous_callback(view, model->back_callback);
-            if(model->timer == NULL) {
-                model->timer = furi_timer_alloc(
-                    flip_weather_loader_timer_callback, FuriTimerTypePeriodic, app);
+            if (model->timer == NULL)
+            {
+                model->timer = furi_timer_alloc(flip_weather_loader_timer_callback, FuriTimerTypePeriodic, app);
             }
             furi_timer_start(model->timer, 250);
         },
         true);
 }
 
-static void flip_weather_loader_on_exit(void* context) {
-    if(context == NULL) {
+static void flip_weather_loader_on_exit(void *context)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_on_exit - context is NULL");
         DEV_CRASH();
         return;
     }
-    FlipWeatherApp* app = (FlipWeatherApp*)context;
-    View* view = app->view_loader;
+    FlipWeatherApp *app = (FlipWeatherApp *)context;
+    View *view = app->view_loader;
     with_view_model(
         view,
         DataLoaderModel * model,
         {
-            if(model->timer) {
+            if (model->timer)
+            {
                 furi_timer_stop(model->timer);
             }
         },
         false);
 }
 
-void flip_weather_loader_init(View* view) {
-    if(view == NULL) {
+void flip_weather_loader_init(View *view)
+{
+    if (view == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_init - view is NULL");
         DEV_CRASH();
         return;
@@ -582,8 +635,10 @@ void flip_weather_loader_init(View* view) {
     view_set_exit_callback(view, flip_weather_loader_on_exit);
 }
 
-void flip_weather_loader_free_model(View* view) {
-    if(view == NULL) {
+void flip_weather_loader_free_model(View *view)
+{
+    if (view == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_loader_free_model - view is NULL");
         DEV_CRASH();
         return;
@@ -592,11 +647,13 @@ void flip_weather_loader_free_model(View* view) {
         view,
         DataLoaderModel * model,
         {
-            if(model->timer) {
+            if (model->timer)
+            {
                 furi_timer_free(model->timer);
                 model->timer = NULL;
             }
-            if(model->parser_context) {
+            if (model->parser_context)
+            {
                 free(model->parser_context);
                 model->parser_context = NULL;
             }
@@ -604,14 +661,17 @@ void flip_weather_loader_free_model(View* view) {
         false);
 }
 
-bool flip_weather_custom_event_callback(void* context, uint32_t index) {
-    if(context == NULL) {
+bool flip_weather_custom_event_callback(void *context, uint32_t index)
+{
+    if (context == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_custom_event_callback - context is NULL");
         DEV_CRASH();
         return false;
     }
 
-    switch(index) {
+    switch (index)
+    {
     case FlipWeatherCustomEventProcess:
         flip_weather_loader_process_callback(context);
         return true;
@@ -621,22 +681,18 @@ bool flip_weather_custom_event_callback(void* context, uint32_t index) {
     }
 }
 
-void flip_weather_generic_switch_to_view(
-    FlipWeatherApp* app,
-    char* title,
-    DataLoaderFetch fetcher,
-    DataLoaderParser parser,
-    size_t request_count,
-    ViewNavigationCallback back,
-    uint32_t view_id) {
-    if(app == NULL) {
+void flip_weather_generic_switch_to_view(FlipWeatherApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id)
+{
+    if (app == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_generic_switch_to_view - app is NULL");
         DEV_CRASH();
         return;
     }
 
-    View* view = app->view_loader;
-    if(view == NULL) {
+    View *view = app->view_loader;
+    if (view == NULL)
+    {
         FURI_LOG_E(TAG, "flip_weather_generic_switch_to_view - view is NULL");
         DEV_CRASH();
         return;

+ 15 - 22
flip_weather/callback/flip_weather_callback.h

@@ -9,37 +9,30 @@ extern bool weather_request_success;
 extern bool sent_weather_request;
 extern bool got_weather_data;
 
-void flip_weather_view_draw_callback_weather(Canvas* canvas, void* model);
-void flip_weather_view_draw_callback_gps(Canvas* canvas, void* model);
-void callback_submenu_choices(void* context, uint32_t index);
-void text_updated_ssid(void* context);
-void text_updated_password(void* context);
-uint32_t callback_to_submenu(void* context);
-void settings_item_selected(void* context, uint32_t index);
+void flip_weather_view_draw_callback_weather(Canvas *canvas, void *model);
+void flip_weather_view_draw_callback_gps(Canvas *canvas, void *model);
+void callback_submenu_choices(void *context, uint32_t index);
+void text_updated_ssid(void *context);
+void text_updated_password(void *context);
+uint32_t callback_to_submenu(void *context);
+void settings_item_selected(void *context, uint32_t index);
 
 /**
  * @brief Navigation callback for exiting the application
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t callback_exit_app(void* context);
-uint32_t callback_to_wifi_settings(void* context);
+uint32_t callback_exit_app(void *context);
+uint32_t callback_to_wifi_settings(void *context);
 
 // Add edits by Derek Jamison
-void flip_weather_generic_switch_to_view(
-    FlipWeatherApp* app,
-    char* title,
-    DataLoaderFetch fetcher,
-    DataLoaderParser parser,
-    size_t request_count,
-    ViewNavigationCallback back,
-    uint32_t view_id);
+void flip_weather_generic_switch_to_view(FlipWeatherApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id);
 
-void flip_weather_loader_draw_callback(Canvas* canvas, void* model);
+void flip_weather_loader_draw_callback(Canvas *canvas, void *model);
 
-void flip_weather_loader_init(View* view);
+void flip_weather_loader_init(View *view);
 
-void flip_weather_loader_free_model(View* view);
+void flip_weather_loader_free_model(View *view);
 
-bool flip_weather_custom_event_callback(void* context, uint32_t index);
-#endif
+bool flip_weather_custom_event_callback(void *context, uint32_t index);
+#endif

+ 198 - 139
flip_weather/easy_flipper/easy_flipper.c

@@ -5,9 +5,11 @@
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t easy_flipper_callback_exit_app(void* context) {
+uint32_t easy_flipper_callback_exit_app(void *context)
+{
     // Exit the application
-    if(!context) {
+    if (!context)
+    {
         FURI_LOG_E(EASY_TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -21,13 +23,16 @@ uint32_t easy_flipper_callback_exit_app(void* context) {
  * @param buffer_size The size of the buffer
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size) {
-    if(!buffer) {
+bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size)
+{
+    if (!buffer)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer");
         return false;
     }
-    *buffer = (char*)malloc(buffer_size);
-    if(!*buffer) {
+    *buffer = (char *)malloc(buffer_size);
+    if (!*buffer)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate buffer");
         return false;
     }
@@ -46,32 +51,39 @@ bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size) {
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_view(
-    View** view,
+    View **view,
     int32_t view_id,
-    void draw_callback(Canvas*, void*),
-    bool input_callback(InputEvent*, void*),
-    uint32_t (*previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!view || !view_dispatcher) {
+    void draw_callback(Canvas *, void *),
+    bool input_callback(InputEvent *, void *),
+    uint32_t (*previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!view || !view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view");
         return false;
     }
     *view = view_alloc();
-    if(!*view) {
+    if (!*view)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate View");
         return false;
     }
-    if(draw_callback) {
+    if (draw_callback)
+    {
         view_set_draw_callback(*view, draw_callback);
     }
-    if(input_callback) {
+    if (input_callback)
+    {
         view_set_input_callback(*view, input_callback);
     }
-    if(context) {
+    if (context)
+    {
         view_set_context(*view, context);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(*view, previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, *view);
@@ -85,18 +97,22 @@ bool easy_flipper_set_view(
  * @param context The context to pass to the event callback
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui, void* context) {
-    if(!view_dispatcher) {
+bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context)
+{
+    if (!view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view_dispatcher");
         return false;
     }
     *view_dispatcher = view_dispatcher_alloc();
-    if(!*view_dispatcher) {
+    if (!*view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate ViewDispatcher");
         return false;
     }
     view_dispatcher_attach_to_gui(*view_dispatcher, gui, ViewDispatcherTypeFullscreen);
-    if(context) {
+    if (context)
+    {
         view_dispatcher_set_event_callback_context(*view_dispatcher, context);
     }
     return true;
@@ -113,24 +129,29 @@ bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_submenu(
-    Submenu** submenu,
+    Submenu **submenu,
     int32_t view_id,
-    char* title,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!submenu) {
+    char *title,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!submenu)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_submenu");
         return false;
     }
     *submenu = submenu_alloc();
-    if(!*submenu) {
+    if (!*submenu)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Submenu");
         return false;
     }
-    if(title) {
+    if (title)
+    {
         submenu_set_header(*submenu, title);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(submenu_get_view(*submenu), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, submenu_get_view(*submenu));
@@ -147,20 +168,24 @@ bool easy_flipper_set_submenu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_menu(
-    Menu** menu,
+    Menu **menu,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!menu) {
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!menu)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_menu");
         return false;
     }
     *menu = menu_alloc();
-    if(!*menu) {
+    if (!*menu)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Menu");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(menu_get_view(*menu), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, menu_get_view(*menu));
@@ -177,24 +202,29 @@ bool easy_flipper_set_menu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_widget(
-    Widget** widget,
+    Widget **widget,
     int32_t view_id,
-    char* text,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!widget) {
+    char *text,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!widget)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_widget");
         return false;
     }
     *widget = widget_alloc();
-    if(!*widget) {
+    if (!*widget)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Widget");
         return false;
     }
-    if(text) {
+    if (text)
+    {
         widget_add_text_scroll_element(*widget, 0, 0, 128, 64, text);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(widget_get_view(*widget), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, widget_get_view(*widget));
@@ -213,30 +243,33 @@ bool easy_flipper_set_widget(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_variable_item_list(
-    VariableItemList** variable_item_list,
+    VariableItemList **variable_item_list,
     int32_t view_id,
-    void (*enter_callback)(void*, uint32_t),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!variable_item_list) {
+    void (*enter_callback)(void *, uint32_t),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!variable_item_list)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_variable_item_list");
         return false;
     }
     *variable_item_list = variable_item_list_alloc();
-    if(!*variable_item_list) {
+    if (!*variable_item_list)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate VariableItemList");
         return false;
     }
-    if(enter_callback) {
+    if (enter_callback)
+    {
         variable_item_list_set_enter_callback(*variable_item_list, enter_callback, context);
     }
-    if(previous_callback) {
-        view_set_previous_callback(
-            variable_item_list_get_view(*variable_item_list), previous_callback);
+    if (previous_callback)
+    {
+        view_set_previous_callback(variable_item_list_get_view(*variable_item_list), previous_callback);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
+    view_dispatcher_add_view(*view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
     return true;
 }
 
@@ -249,38 +282,38 @@ bool easy_flipper_set_variable_item_list(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_text_input(
-    TextInput** text_input,
+    TextInput **text_input,
     int32_t view_id,
-    char* header_text,
-    char* text_input_temp_buffer,
+    char *header_text,
+    char *text_input_temp_buffer,
     uint32_t text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!text_input) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_text_input");
         return false;
     }
     *text_input = text_input_alloc();
-    if(!*text_input) {
+    if (!*text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate TextInput");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(text_input_get_view(*text_input), previous_callback);
     }
-    if(header_text) {
+    if (header_text)
+    {
         text_input_set_header_text(*text_input, header_text);
     }
-    if(text_input_temp_buffer && text_input_buffer_size && result_callback) {
-        text_input_set_result_callback(
-            *text_input,
-            result_callback,
-            context,
-            text_input_temp_buffer,
-            text_input_buffer_size,
-            false);
+    if (text_input_temp_buffer && text_input_buffer_size && result_callback)
+    {
+        text_input_set_result_callback(*text_input, result_callback, context, text_input_temp_buffer, text_input_buffer_size, false);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*text_input));
     return true;
@@ -295,38 +328,38 @@ bool easy_flipper_set_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    TextInput** uart_text_input,
+    TextInput **uart_text_input,
     int32_t view_id,
-    char* header_text,
-    char* uart_text_input_temp_buffer,
+    char *header_text,
+    char *uart_text_input_temp_buffer,
     uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!uart_text_input) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!uart_text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
     *uart_text_input = text_input_alloc();
-    if(!*uart_text_input) {
+    if (!*uart_text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
-    if(header_text) {
+    if (header_text)
+    {
         text_input_set_header_text(*uart_text_input, header_text);
     }
-    if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        text_input_set_result_callback(
-            *uart_text_input,
-            result_callback,
-            context,
-            uart_text_input_temp_buffer,
-            uart_text_input_buffer_size,
-            false);
+    if (uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback)
+    {
+        text_input_set_result_callback(*uart_text_input, result_callback, context, uart_text_input_temp_buffer, uart_text_input_buffer_size, false);
     }
     text_input_show_illegal_symbols(*uart_text_input, true);
     view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
@@ -353,52 +386,63 @@ bool easy_flipper_set_uart_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_dialog_ex(
-    DialogEx** dialog_ex,
+    DialogEx **dialog_ex,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    char* left_button_text,
-    char* right_button_text,
-    char* center_button_text,
-    void (*result_callback)(DialogExResult, void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!dialog_ex) {
+    char *left_button_text,
+    char *right_button_text,
+    char *center_button_text,
+    void (*result_callback)(DialogExResult, void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!dialog_ex)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_dialog_ex");
         return false;
     }
     *dialog_ex = dialog_ex_alloc();
-    if(!*dialog_ex) {
+    if (!*dialog_ex)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate DialogEx");
         return false;
     }
-    if(header) {
+    if (header)
+    {
         dialog_ex_set_header(*dialog_ex, header, header_x, header_y, AlignLeft, AlignTop);
     }
-    if(text) {
+    if (text)
+    {
         dialog_ex_set_text(*dialog_ex, text, text_x, text_y, AlignLeft, AlignTop);
     }
-    if(left_button_text) {
+    if (left_button_text)
+    {
         dialog_ex_set_left_button_text(*dialog_ex, left_button_text);
     }
-    if(right_button_text) {
+    if (right_button_text)
+    {
         dialog_ex_set_right_button_text(*dialog_ex, right_button_text);
     }
-    if(center_button_text) {
+    if (center_button_text)
+    {
         dialog_ex_set_center_button_text(*dialog_ex, center_button_text);
     }
-    if(result_callback) {
+    if (result_callback)
+    {
         dialog_ex_set_result_callback(*dialog_ex, result_callback);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(dialog_ex_get_view(*dialog_ex), previous_callback);
     }
-    if(context) {
+    if (context)
+    {
         dialog_ex_set_context(*dialog_ex, context);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, dialog_ex_get_view(*dialog_ex));
@@ -422,40 +466,48 @@ bool easy_flipper_set_dialog_ex(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_popup(
-    Popup** popup,
+    Popup **popup,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!popup) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!popup)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_popup");
         return false;
     }
     *popup = popup_alloc();
-    if(!*popup) {
+    if (!*popup)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Popup");
         return false;
     }
-    if(header) {
+    if (header)
+    {
         popup_set_header(*popup, header, header_x, header_y, AlignLeft, AlignTop);
     }
-    if(text) {
+    if (text)
+    {
         popup_set_text(*popup, text, text_x, text_y, AlignLeft, AlignTop);
     }
-    if(result_callback) {
+    if (result_callback)
+    {
         popup_set_callback(*popup, result_callback);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(popup_get_view(*popup), previous_callback);
     }
-    if(context) {
+    if (context)
+    {
         popup_set_context(*popup, context);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, popup_get_view(*popup));
@@ -471,20 +523,24 @@ bool easy_flipper_set_popup(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_loading(
-    Loading** loading,
+    Loading **loading,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!loading) {
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!loading)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_loading");
         return false;
     }
     *loading = loading_alloc();
-    if(!*loading) {
+    if (!*loading)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Loading");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(loading_get_view(*loading), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, loading_get_view(*loading));
@@ -497,16 +553,19 @@ bool easy_flipper_set_loading(
  * @param buffer The buffer to copy the string to
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_char_to_furi_string(FuriString** furi_string, char* buffer) {
-    if(!furi_string) {
+bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer)
+{
+    if (!furi_string)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer_to_furi_string");
         return false;
     }
     *furi_string = furi_string_alloc();
-    if(!furi_string) {
+    if (!furi_string)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate FuriString");
         return false;
     }
     furi_string_set_str(*furi_string, buffer);
     return true;
-}
+}

+ 61 - 61
flip_weather/easy_flipper/easy_flipper.h

@@ -30,14 +30,14 @@
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t easy_flipper_callback_exit_app(void* context);
+uint32_t easy_flipper_callback_exit_app(void *context);
 /**
  * @brief Initialize a buffer
  * @param buffer The buffer to initialize
  * @param buffer_size The size of the buffer
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size);
+bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size);
 /**
  * @brief Initialize a View object
  * @param view The View object to initialize
@@ -49,13 +49,13 @@ bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size);
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_view(
-    View** view,
+    View **view,
     int32_t view_id,
-    void draw_callback(Canvas*, void*),
-    bool input_callback(InputEvent*, void*),
-    uint32_t (*previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void draw_callback(Canvas *, void *),
+    bool input_callback(InputEvent *, void *),
+    uint32_t (*previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a ViewDispatcher object
@@ -64,7 +64,7 @@ bool easy_flipper_set_view(
  * @param context The context to pass to the event callback
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui, void* context);
+bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context);
 
 /**
  * @brief Initialize a Submenu object
@@ -77,11 +77,11 @@ bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_submenu(
-    Submenu** submenu,
+    Submenu **submenu,
     int32_t view_id,
-    char* title,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    char *title,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a Menu object
@@ -94,10 +94,10 @@ bool easy_flipper_set_submenu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_menu(
-    Menu** menu,
+    Menu **menu,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a Widget object
@@ -109,11 +109,11 @@ bool easy_flipper_set_menu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_widget(
-    Widget** widget,
+    Widget **widget,
     int32_t view_id,
-    char* text,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    char *text,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a VariableItemList object
@@ -127,12 +127,12 @@ bool easy_flipper_set_widget(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_variable_item_list(
-    VariableItemList** variable_item_list,
+    VariableItemList **variable_item_list,
     int32_t view_id,
-    void (*enter_callback)(void*, uint32_t),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*enter_callback)(void *, uint32_t),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a TextInput object
@@ -143,15 +143,15 @@ bool easy_flipper_set_variable_item_list(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_text_input(
-    TextInput** text_input,
+    TextInput **text_input,
     int32_t view_id,
-    char* header_text,
-    char* text_input_temp_buffer,
+    char *header_text,
+    char *text_input_temp_buffer,
     uint32_t text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a TextInput object with extra symbols
@@ -162,15 +162,15 @@ bool easy_flipper_set_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    TextInput** uart_text_input,
+    TextInput **uart_text_input,
     int32_t view_id,
-    char* header_text,
-    char* uart_text_input_temp_buffer,
+    char *header_text,
+    char *uart_text_input_temp_buffer,
     uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a DialogEx object
@@ -192,21 +192,21 @@ bool easy_flipper_set_uart_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_dialog_ex(
-    DialogEx** dialog_ex,
+    DialogEx **dialog_ex,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    char* left_button_text,
-    char* right_button_text,
-    char* center_button_text,
-    void (*result_callback)(DialogExResult, void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    char *left_button_text,
+    char *right_button_text,
+    char *center_button_text,
+    void (*result_callback)(DialogExResult, void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a Popup object
@@ -225,18 +225,18 @@ bool easy_flipper_set_dialog_ex(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_popup(
-    Popup** popup,
+    Popup **popup,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a Loading object
@@ -247,10 +247,10 @@ bool easy_flipper_set_popup(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_loading(
-    Loading** loading,
+    Loading **loading,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Set a char butter to a FuriString
@@ -258,6 +258,6 @@ bool easy_flipper_set_loading(
  * @param buffer The buffer to copy the string to
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_char_to_furi_string(FuriString** furi_string, char* buffer);
+bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer);
 
-#endif
+#endif

+ 32 - 20
flip_weather/flip_storage/flip_weather_storage.c

@@ -1,19 +1,22 @@
 
 #include "flip_storage/flip_weather_storage.h"
 
-void save_settings(const char* ssid, const char* password) {
+void save_settings(
+    const char *ssid,
+    const char *password)
+{
     // Create the directory for saving settings
     char directory_path[256];
-    snprintf(
-        directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_weather");
+    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/flip_weather");
 
     // Create the directory
-    Storage* storage = furi_record_open(RECORD_STORAGE);
+    Storage *storage = furi_record_open(RECORD_STORAGE);
     storage_common_mkdir(storage, directory_path);
 
     // Open the settings file
-    File* file = storage_file_alloc(storage);
-    if(!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
+    File *file = storage_file_alloc(storage);
+    if (!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS))
+    {
         FURI_LOG_E(TAG, "Failed to open settings file for writing: %s", SETTINGS_PATH);
         storage_file_free(file);
         furi_record_close(RECORD_STORAGE);
@@ -22,15 +25,17 @@ void save_settings(const char* ssid, const char* password) {
 
     // Save the ssid length and data
     size_t ssid_length = strlen(ssid) + 1; // Include null terminator
-    if(storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, ssid, ssid_length) != ssid_length) {
+    if (storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, ssid, ssid_length) != ssid_length)
+    {
         FURI_LOG_E(TAG, "Failed to write SSID");
     }
 
     // Save the password length and data
     size_t password_length = strlen(password) + 1; // Include null terminator
-    if(storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, password, password_length) != password_length) {
+    if (storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, password, password_length) != password_length)
+    {
         FURI_LOG_E(TAG, "Failed to write password");
     }
 
@@ -39,11 +44,17 @@ void save_settings(const char* ssid, const char* password) {
     furi_record_close(RECORD_STORAGE);
 }
 
-bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password_size) {
-    Storage* storage = furi_record_open(RECORD_STORAGE);
-    File* file = storage_file_alloc(storage);
+bool load_settings(
+    char *ssid,
+    size_t ssid_size,
+    char *password,
+    size_t password_size)
+{
+    Storage *storage = furi_record_open(RECORD_STORAGE);
+    File *file = storage_file_alloc(storage);
 
-    if(!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
+    if (!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING))
+    {
         FURI_LOG_E(TAG, "Failed to open settings file for reading: %s", SETTINGS_PATH);
         storage_file_free(file);
         furi_record_close(RECORD_STORAGE);
@@ -52,8 +63,9 @@ bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password
 
     // Load the ssid
     size_t ssid_length;
-    if(storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-       ssid_length > ssid_size || storage_file_read(file, ssid, ssid_length) != ssid_length) {
+    if (storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) || ssid_length > ssid_size ||
+        storage_file_read(file, ssid, ssid_length) != ssid_length)
+    {
         FURI_LOG_E(TAG, "Failed to read SSID");
         storage_file_close(file);
         storage_file_free(file);
@@ -64,9 +76,9 @@ bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password
 
     // Load the password
     size_t password_length;
-    if(storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-       password_length > password_size ||
-       storage_file_read(file, password, password_length) != password_length) {
+    if (storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) || password_length > password_size ||
+        storage_file_read(file, password, password_length) != password_length)
+    {
         FURI_LOG_E(TAG, "Failed to read password");
         storage_file_close(file);
         storage_file_free(file);
@@ -80,4 +92,4 @@ bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password
     furi_record_close(RECORD_STORAGE);
 
     return true;
-}
+}

+ 9 - 3
flip_weather/flip_storage/flip_weather_storage.h

@@ -7,7 +7,13 @@
 
 #define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_weather/settings.bin"
 
-void save_settings(const char* ssid, const char* password);
+void save_settings(
+    const char *ssid,
+    const char *password);
 
-bool load_settings(char* ssid, size_t ssid_size, char* password, size_t password_size);
-#endif // FLIP_WEATHER_STORAGE_H
+bool load_settings(
+    char *ssid,
+    size_t ssid_size,
+    char *password,
+    size_t password_size);
+#endif // FLIP_WEATHER_STORAGE_H

+ 37 - 21
flip_weather/flip_weather.c

@@ -3,75 +3,91 @@
 char lat_data[32];
 char lon_data[32];
 
-char* total_data = NULL;
-char* weather_data = NULL;
+char *total_data = NULL;
+char *weather_data = NULL;
 
-FlipWeatherApp* app_instance = NULL;
-void flip_weather_loader_free_model(View* view);
+FlipWeatherApp *app_instance = NULL;
+void flip_weather_loader_free_model(View *view);
 
 // Function to free the resources used by FlipWeatherApp
-void flip_weather_app_free(FlipWeatherApp* app) {
-    if(!app) {
+void flip_weather_app_free(FlipWeatherApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "FlipWeatherApp is NULL");
         return;
     }
 
     // Free View(s)
-    if(app->view_loader) {
+    if (app->view_loader)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewLoader);
         flip_weather_loader_free_model(app->view_loader);
         view_free(app->view_loader);
     }
 
     // Free Submenu(s)
-    if(app->submenu) {
+    if (app->submenu)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewSubmenu);
         submenu_free(app->submenu);
     }
 
     // Free Widget(s)
-    if(app->widget) {
+    if (app->widget)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewAbout);
         widget_free(app->widget);
     }
-    if(app->widget_result) {
+    if (app->widget_result)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewWidgetResult);
         widget_free(app->widget_result);
     }
 
     // Free Variable Item List(s)
-    if(app->variable_item_list) {
+    if (app->variable_item_list)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewSettings);
         variable_item_list_free(app->variable_item_list);
     }
 
     // Free Text Input(s)
-    if(app->uart_text_input_ssid) {
+    if (app->uart_text_input_ssid)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewTextInputSSID);
         text_input_free(app->uart_text_input_ssid);
     }
-    if(app->uart_text_input_password) {
+    if (app->uart_text_input_password)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, FlipWeatherViewTextInputPassword);
         text_input_free(app->uart_text_input_password);
     }
 
     // Free the text input buffer
-    if(app->uart_text_input_buffer_ssid) free(app->uart_text_input_buffer_ssid);
-    if(app->uart_text_input_temp_buffer_ssid) free(app->uart_text_input_temp_buffer_ssid);
-    if(app->uart_text_input_buffer_password) free(app->uart_text_input_buffer_password);
-    if(app->uart_text_input_temp_buffer_password) free(app->uart_text_input_temp_buffer_password);
+    if (app->uart_text_input_buffer_ssid)
+        free(app->uart_text_input_buffer_ssid);
+    if (app->uart_text_input_temp_buffer_ssid)
+        free(app->uart_text_input_temp_buffer_ssid);
+    if (app->uart_text_input_buffer_password)
+        free(app->uart_text_input_buffer_password);
+    if (app->uart_text_input_temp_buffer_password)
+        free(app->uart_text_input_temp_buffer_password);
 
     // deinitalize flipper http
     flipper_http_deinit();
 
     // free the view dispatcher
-    if(app->view_dispatcher) view_dispatcher_free(app->view_dispatcher);
+    if (app->view_dispatcher)
+        view_dispatcher_free(app->view_dispatcher);
 
     // close the gui
     furi_record_close(RECORD_GUI);
 
-    if(total_data) free(total_data);
+    if (total_data)
+        free(total_data);
 
     // free the app
-    if(app) free(app);
-}
+    if (app)
+        free(app);
+}

+ 36 - 33
flip_weather/flip_weather.h

@@ -5,61 +5,64 @@
 #include <easy_flipper/easy_flipper.h>
 #include <jsmn/jsmn.h>
 
-#define TAG        "FlipWeather"
+#define TAG "FlipWeather"
 #define MAX_TOKENS 64 // Adjust based on expected JSON size (50)
 
 // Define the submenu items for our FlipWeather application
-typedef enum {
-    FlipWeatherSubmenuIndexWeather, // Click to view the weather
-    FlipWeatherSubmenuIndexGPS, // Click to view the GPS
-    FlipWeatherSubmenuIndexAbout, // Click to view the about screen
+typedef enum
+{
+    FlipWeatherSubmenuIndexWeather,  // Click to view the weather
+    FlipWeatherSubmenuIndexGPS,      // Click to view the GPS
+    FlipWeatherSubmenuIndexAbout,    // Click to view the about screen
     FlipWeatherSubmenuIndexSettings, // Click to view the settings screen
 } FlipWeatherSubmenuIndex;
 
 // Define a single view for our FlipWeather application
-typedef enum {
-    FlipWeatherViewSubmenu, // The main submenu
-    FlipWeatherViewAbout, // The about screen
-    FlipWeatherViewSettings, // The wifi settings screen
-    FlipWeatherViewTextInputSSID, // The text input screen for SSID
+typedef enum
+{
+    FlipWeatherViewSubmenu,           // The main submenu
+    FlipWeatherViewAbout,             // The about screen
+    FlipWeatherViewSettings,          // The wifi settings screen
+    FlipWeatherViewTextInputSSID,     // The text input screen for SSID
     FlipWeatherViewTextInputPassword, // The text input screen for password
     //
-    FlipWeatherViewPopupError, // The error popup screen
+    FlipWeatherViewPopupError,   // The error popup screen
     FlipWeatherViewWidgetResult, // The text box that displays the random fact
-    FlipWeatherViewLoader, // The loader screen retrieves data from the internet
+    FlipWeatherViewLoader,       // The loader screen retrieves data from the internet
 } FlipWeatherView;
 
 // Each screen will have its own view
-typedef struct {
-    ViewDispatcher* view_dispatcher; // Switches between our views
-    View* view_loader; // The screen that loads data from internet
-    Submenu* submenu; // The main submenu
-    Widget* widget; // The widget (about)
-    Widget* widget_result; // The widget that displays the result
-    Popup* popup_error; // The error popup
-    VariableItemList* variable_item_list; // The variable item list (settngs)
-    VariableItem* variable_item_ssid; // The variable item
-    VariableItem* variable_item_password; // The variable item
-    TextInput* uart_text_input_ssid; // The text input
-    TextInput* uart_text_input_password; // The text input
+typedef struct
+{
+    ViewDispatcher *view_dispatcher;          // Switches between our views
+    View *view_loader;                        // The screen that loads data from internet
+    Submenu *submenu;                         // The main submenu
+    Widget *widget;                           // The widget (about)
+    Widget *widget_result;                    // The widget that displays the result
+    Popup *popup_error;                       // The error popup
+    VariableItemList *variable_item_list;     // The variable item list (settngs)
+    VariableItem *variable_item_ssid;         // The variable item
+    VariableItem *variable_item_password;     // The variable item
+    TextInput *uart_text_input_ssid;     // The text input
+    TextInput *uart_text_input_password; // The text input
 
-    char* uart_text_input_buffer_ssid; // Buffer for the text input
-    char* uart_text_input_temp_buffer_ssid; // Temporary buffer for the text input
+    char *uart_text_input_buffer_ssid;         // Buffer for the text input
+    char *uart_text_input_temp_buffer_ssid;    // Temporary buffer for the text input
     uint32_t uart_text_input_buffer_size_ssid; // Size of the text input buffer
 
-    char* uart_text_input_buffer_password; // Buffer for the text input
-    char* uart_text_input_temp_buffer_password; // Temporary buffer for the text input
+    char *uart_text_input_buffer_password;         // Buffer for the text input
+    char *uart_text_input_temp_buffer_password;    // Temporary buffer for the text input
     uint32_t uart_text_input_buffer_size_password; // Size of the text input buffer
 } FlipWeatherApp;
 
 extern char lat_data[32];
 extern char lon_data[32];
 
-extern char* total_data;
-extern char* weather_data;
+extern char *total_data;
+extern char *weather_data;
 
 // Function to free the resources used by FlipWeatherApp
-void flip_weather_app_free(FlipWeatherApp* app);
-extern FlipWeatherApp* app_instance;
+void flip_weather_app_free(FlipWeatherApp *app);
+extern FlipWeatherApp *app_instance;
 
-#endif
+#endif

File diff suppressed because it is too large
+ 291 - 165
flip_weather/flipper_http/flipper_http.c


+ 67 - 65
flip_weather/flipper_http/flipper_http.h

@@ -15,69 +15,72 @@
 
 // STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext
 
-#define HTTP_TAG               "FlipWeather" // change this to your app name
-#define http_tag               "flip_weather" // change this to your app id
-#define UART_CH                (momentum_settings.uart_esp_channel) // UART channel
+#define HTTP_TAG "FlipWeather"            // change this to your app name
+#define http_tag "flip_weather"           // change this to your app id
+#define UART_CH (momentum_settings.uart_esp_channel)    // UART channel
 #define TIMEOUT_DURATION_TICKS (6 * 1000) // 6 seconds
-#define BAUDRATE               (115200) // UART baudrate
-#define RX_BUF_SIZE            1024 // UART RX buffer size
-#define RX_LINE_BUFFER_SIZE    4096 // UART RX line buffer size (increase for large responses)
-#define MAX_FILE_SHOW          4096 // Maximum data from file to show
-#define FILE_BUFFER_SIZE       512 // File buffer size
+#define BAUDRATE (115200)                 // UART baudrate
+#define RX_BUF_SIZE 1024                  // UART RX buffer size
+#define RX_LINE_BUFFER_SIZE 4096          // UART RX line buffer size (increase for large responses)
+#define MAX_FILE_SHOW 4096                // Maximum data from file to show
+#define FILE_BUFFER_SIZE 512              // File buffer size
 
 // Forward declaration for callback
-typedef void (*FlipperHTTP_Callback)(const char* line, void* context);
+typedef void (*FlipperHTTP_Callback)(const char *line, void *context);
 
 // State variable to track the UART state
-typedef enum {
-    INACTIVE, // Inactive state
-    IDLE, // Default state
+typedef enum
+{
+    INACTIVE,  // Inactive state
+    IDLE,      // Default state
     RECEIVING, // Receiving data
-    SENDING, // Sending data
-    ISSUE, // Issue with connection
+    SENDING,   // Sending data
+    ISSUE,     // Issue with connection
 } SerialState;
 
 // Event Flags for UART Worker Thread
-typedef enum {
+typedef enum
+{
     WorkerEvtStop = (1 << 0),
     WorkerEvtRxDone = (1 << 1),
 } WorkerEvtFlags;
 
 // FlipperHTTP Structure
-typedef struct {
-    FuriStreamBuffer* flipper_http_stream; // Stream buffer for UART communication
-    FuriHalSerialHandle* serial_handle; // Serial handle for UART communication
-    FuriThread* rx_thread; // Worker thread for UART
-    FuriThreadId rx_thread_id; // Worker thread ID
+typedef struct
+{
+    FuriStreamBuffer *flipper_http_stream;  // Stream buffer for UART communication
+    FuriHalSerialHandle *serial_handle;     // Serial handle for UART communication
+    FuriThread *rx_thread;                  // Worker thread for UART
+    FuriThreadId rx_thread_id;              // Worker thread ID
     FlipperHTTP_Callback handle_rx_line_cb; // Callback for received lines
-    void* callback_context; // Context for the callback
-    SerialState state; // State of the UART
+    void *callback_context;                 // Context for the callback
+    SerialState state;                      // State of the UART
 
     // variable to store the last received data from the UART
-    char* last_response;
+    char *last_response;
     char file_path[256]; // Path to save the received data
 
     // Timer-related members
-    FuriTimer* get_timeout_timer; // Timer for HTTP request timeout
+    FuriTimer *get_timeout_timer; // Timer for HTTP request timeout
 
     bool started_receiving_get; // Indicates if a GET request has started
-    bool just_started_get; // Indicates if GET data reception has just started
+    bool just_started_get;      // Indicates if GET data reception has just started
 
     bool started_receiving_post; // Indicates if a POST request has started
-    bool just_started_post; // Indicates if POST data reception has just started
+    bool just_started_post;      // Indicates if POST data reception has just started
 
     bool started_receiving_put; // Indicates if a PUT request has started
-    bool just_started_put; // Indicates if PUT data reception has just started
+    bool just_started_put;      // Indicates if PUT data reception has just started
 
     bool started_receiving_delete; // Indicates if a DELETE request has started
-    bool just_started_delete; // Indicates if DELETE data reception has just started
+    bool just_started_delete;      // Indicates if DELETE data reception has just started
 
     // Buffer to hold the raw bytes received from the UART
-    uint8_t* received_bytes;
+    uint8_t *received_bytes;
     size_t received_bytes_len; // Length of the received bytes
-    bool is_bytes_request; // Flag to indicate if the request is for bytes
-    bool save_bytes; // Flag to save the received data to a file
-    bool save_received_data; // Flag to save the received data to a file
+    bool is_bytes_request;     // Flag to indicate if the request is for bytes
+    bool save_bytes;           // Flag to save the received data to a file
+    bool save_received_data;   // Flag to save the received data to a file
 
     bool just_started_bytes; // Indicates if bytes data reception has just started
 } FlipperHTTP;
@@ -93,12 +96,12 @@ extern size_t file_buffer_len;
 // Function to append received data to file
 // make sure to initialize the file path before calling this function
 bool flipper_http_append_to_file(
-    const void* data,
+    const void *data,
     size_t data_size,
     bool start_new_file,
-    char* file_path);
+    char *file_path);
 
-FuriString* flipper_http_load_from_file(char* file_path);
+FuriString *flipper_http_load_from_file(char *file_path);
 
 // UART worker thread
 /**
@@ -108,7 +111,7 @@ FuriString* flipper_http_load_from_file(char* file_path);
  * @note       This function will handle received data asynchronously via the callback.
  */
 // UART worker thread
-int32_t flipper_http_worker(void* context);
+int32_t flipper_http_worker(void *context);
 
 // Timer callback function
 /**
@@ -117,7 +120,7 @@ int32_t flipper_http_worker(void* context);
  * @param      context   The context to pass to the callback.
  * @note       This function will be called when the GET request times out.
  */
-void get_timeout_timer_callback(void* context);
+void get_timeout_timer_callback(void *context);
 
 // UART RX Handler Callback (Interrupt Context)
 /**
@@ -129,9 +132,9 @@ void get_timeout_timer_callback(void* context);
  * @note       This function will handle received data asynchronously via the callback.
  */
 void _flipper_http_rx_callback(
-    FuriHalSerialHandle* handle,
+    FuriHalSerialHandle *handle,
     FuriHalSerialRxEvent event,
-    void* context);
+    void *context);
 
 // UART initialization function
 /**
@@ -141,7 +144,7 @@ void _flipper_http_rx_callback(
  * @param      context   The context to pass to the callback.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_init(FlipperHTTP_Callback callback, void* context);
+bool flipper_http_init(FlipperHTTP_Callback callback, void *context);
 
 // Deinitialize UART
 /**
@@ -158,7 +161,7 @@ void flipper_http_deinit();
  * @param      data  The data to send over UART.
  * @note       The data will be sent over UART with a newline character appended.
  */
-bool flipper_http_send_data(const char* data);
+bool flipper_http_send_data(const char *data);
 
 // Function to send a PING request
 /**
@@ -202,7 +205,7 @@ bool flipper_http_led_off();
  * @param      json_data The JSON data to parse.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_parse_json(const char* key, const char* json_data);
+bool flipper_http_parse_json(const char *key, const char *json_data);
 
 // Function to parse JSON array data
 /**
@@ -213,7 +216,7 @@ bool flipper_http_parse_json(const char* key, const char* json_data);
  * @param      json_data The JSON array data to parse.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_parse_json_array(const char* key, int index, const char* json_data);
+bool flipper_http_parse_json_array(const char *key, int index, const char *json_data);
 
 // Function to scan for WiFi networks
 /**
@@ -229,7 +232,7 @@ bool flipper_http_scan_wifi();
  * @return     true if the request was successful, false otherwise.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_save_wifi(const char* ssid, const char* password);
+bool flipper_http_save_wifi(const char *ssid, const char *password);
 
 // Function to get IP address of WiFi Devboard
 /**
@@ -270,7 +273,7 @@ bool flipper_http_connect_wifi();
  * @param      url  The URL to send the GET request to.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request(const char* url);
+bool flipper_http_get_request(const char *url);
 
 // Function to send a GET request with headers
 /**
@@ -280,7 +283,7 @@ bool flipper_http_get_request(const char* url);
  * @param      headers  The headers to send with the GET request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request_with_headers(const char* url, const char* headers);
+bool flipper_http_get_request_with_headers(const char *url, const char *headers);
 
 // Function to send a GET request with headers and return bytes
 /**
@@ -290,7 +293,7 @@ bool flipper_http_get_request_with_headers(const char* url, const char* headers)
  * @param      headers  The headers to send with the GET request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request_bytes(const char* url, const char* headers);
+bool flipper_http_get_request_bytes(const char *url, const char *headers);
 
 // Function to send a POST request with headers
 /**
@@ -302,9 +305,9 @@ bool flipper_http_get_request_bytes(const char* url, const char* headers);
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_post_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to send a POST request with headers and return bytes
 /**
@@ -315,7 +318,7 @@ bool flipper_http_post_request_with_headers(
  * @param      payload  The data to send with the POST request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_post_request_bytes(const char* url, const char* headers, const char* payload);
+bool flipper_http_post_request_bytes(const char *url, const char *headers, const char *payload);
 
 // Function to send a PUT request with headers
 /**
@@ -327,9 +330,9 @@ bool flipper_http_post_request_bytes(const char* url, const char* headers, const
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_put_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to send a DELETE request with headers
 /**
@@ -341,9 +344,9 @@ bool flipper_http_put_request_with_headers(
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_delete_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to handle received data asynchronously
 /**
@@ -353,10 +356,10 @@ bool flipper_http_delete_request_with_headers(
  * @param      context  The context passed to the callback.
  * @note       The received data will be handled asynchronously via the callback and handles the state of the UART.
  */
-void flipper_http_rx_callback(const char* line, void* context);
+void flipper_http_rx_callback(const char *line, void *context);
 
 // Function to trim leading and trailing spaces and newlines from a constant string
-char* trim(const char* str);
+char *trim(const char *str);
 /**
  * @brief Process requests and parse JSON data asynchronously
  * @param http_request The function to send the request
@@ -374,11 +377,10 @@ bool flipper_http_process_response_async(bool (*http_request)(void), bool (*pars
  * @param view_dispatcher The view dispatcher to use
  * @return
  */
-void flipper_http_loading_task(
-    bool (*http_request)(void),
-    bool (*parse_response)(void),
-    uint32_t success_view_id,
-    uint32_t failure_view_id,
-    ViewDispatcher** view_dispatcher);
+void flipper_http_loading_task(bool (*http_request)(void),
+                               bool (*parse_response)(void),
+                               uint32_t success_view_id,
+                               uint32_t failure_view_id,
+                               ViewDispatcher **view_dispatcher);
 
 #endif // FLIPPER_HTTP_H

+ 217 - 136
flip_weather/jsmn/jsmn.c

@@ -13,11 +13,13 @@
 /**
  * Allocates a fresh unused token from the token pool.
  */
-static jsmntok_t*
-    jsmn_alloc_token(jsmn_parser* parser, jsmntok_t* tokens, const size_t num_tokens) {
-    jsmntok_t* tok;
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
+                                   const size_t num_tokens)
+{
+    jsmntok_t *tok;
 
-    if(parser->toknext >= num_tokens) {
+    if (parser->toknext >= num_tokens)
+    {
         return NULL;
     }
     tok = &tokens[parser->toknext++];
@@ -32,8 +34,9 @@ static jsmntok_t*
 /**
  * Fills token type and boundaries.
  */
-static void
-    jsmn_fill_token(jsmntok_t* token, const jsmntype_t type, const int start, const int end) {
+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
+                            const int start, const int end)
+{
     token->type = type;
     token->start = start;
     token->end = end;
@@ -43,19 +46,19 @@ static void
 /**
  * Fills next available token with JSON primitive.
  */
-static int jsmn_parse_primitive(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+                                const size_t len, jsmntok_t *tokens,
+                                const size_t num_tokens)
+{
+    jsmntok_t *token;
     int start;
 
     start = parser->pos;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-        switch(js[parser->pos]) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
+        switch (js[parser->pos])
+        {
 #ifndef JSMN_STRICT
         /* In strict mode primitive must be followed by "," or "}" or "]" */
         case ':':
@@ -72,7 +75,8 @@ static int jsmn_parse_primitive(
             /* to quiet a warning from gcc*/
             break;
         }
-        if(js[parser->pos] < 32 || js[parser->pos] >= 127) {
+        if (js[parser->pos] < 32 || js[parser->pos] >= 127)
+        {
             parser->pos = start;
             return JSMN_ERROR_INVAL;
         }
@@ -84,12 +88,14 @@ static int jsmn_parse_primitive(
 #endif
 
 found:
-    if(tokens == NULL) {
+    if (tokens == NULL)
+    {
         parser->pos--;
         return 0;
     }
     token = jsmn_alloc_token(parser, tokens, num_tokens);
-    if(token == NULL) {
+    if (token == NULL)
+    {
         parser->pos = start;
         return JSMN_ERROR_NOMEM;
     }
@@ -104,29 +110,31 @@ found:
 /**
  * Fills next token with JSON string.
  */
-static int jsmn_parse_string(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+                             const size_t len, jsmntok_t *tokens,
+                             const size_t num_tokens)
+{
+    jsmntok_t *token;
 
     int start = parser->pos;
 
     /* Skip starting quote */
     parser->pos++;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c = js[parser->pos];
 
         /* Quote: end of string */
-        if(c == '\"') {
-            if(tokens == NULL) {
+        if (c == '\"')
+        {
+            if (tokens == NULL)
+            {
                 return 0;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 parser->pos = start;
                 return JSMN_ERROR_NOMEM;
             }
@@ -138,10 +146,12 @@ static int jsmn_parse_string(
         }
 
         /* Backslash: Quoted symbol expected */
-        if(c == '\\' && parser->pos + 1 < len) {
+        if (c == '\\' && parser->pos + 1 < len)
+        {
             int i;
             parser->pos++;
-            switch(js[parser->pos]) {
+            switch (js[parser->pos])
+            {
             /* Allowed escaped symbols */
             case '\"':
             case '/':
@@ -155,11 +165,13 @@ static int jsmn_parse_string(
             /* Allows escaped symbol \uXXXX */
             case 'u':
                 parser->pos++;
-                for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+                for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++)
+                {
                     /* If it isn't a hex character we have an error */
-                    if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                         (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                         (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+                    if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+                          (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+                          (js[parser->pos] >= 97 && js[parser->pos] <= 102)))
+                    { /* a-f */
                         parser->pos = start;
                         return JSMN_ERROR_INVAL;
                     }
@@ -181,7 +193,8 @@ static int jsmn_parse_string(
 /**
  * Create JSON parser over an array of tokens
  */
-void jsmn_init(jsmn_parser* parser) {
+void jsmn_init(jsmn_parser *parser)
+{
     parser->pos = 0;
     parser->toknext = 0;
     parser->toksuper = -1;
@@ -190,38 +203,41 @@ void jsmn_init(jsmn_parser* parser) {
 /**
  * Parse JSON string and fill tokens.
  */
-int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens) {
+int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+               jsmntok_t *tokens, const unsigned int num_tokens)
+{
     int r;
     int i;
-    jsmntok_t* token;
+    jsmntok_t *token;
     int count = parser->toknext;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c;
         jsmntype_t type;
 
         c = js[parser->pos];
-        switch(c) {
+        switch (c)
+        {
         case '{':
         case '[':
             count++;
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 return JSMN_ERROR_NOMEM;
             }
-            if(parser->toksuper != -1) {
-                jsmntok_t* t = &tokens[parser->toksuper];
+            if (parser->toksuper != -1)
+            {
+                jsmntok_t *t = &tokens[parser->toksuper];
 #ifdef JSMN_STRICT
                 /* In strict mode an object or array can't become a key */
-                if(t->type == JSMN_OBJECT) {
+                if (t->type == JSMN_OBJECT)
+                {
                     return JSMN_ERROR_INVAL;
                 }
 #endif
@@ -236,26 +252,33 @@ int jsmn_parse(
             break;
         case '}':
         case ']':
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
 #ifdef JSMN_PARENT_LINKS
-            if(parser->toknext < 1) {
+            if (parser->toknext < 1)
+            {
                 return JSMN_ERROR_INVAL;
             }
             token = &tokens[parser->toknext - 1];
-            for(;;) {
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+            for (;;)
+            {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     token->end = parser->pos + 1;
                     parser->toksuper = token->parent;
                     break;
                 }
-                if(token->parent == -1) {
-                    if(token->type != type || parser->toksuper == -1) {
+                if (token->parent == -1)
+                {
+                    if (token->type != type || parser->toksuper == -1)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     break;
@@ -263,10 +286,13 @@ int jsmn_parse(
                 token = &tokens[token->parent];
             }
 #else
-            for(i = parser->toknext - 1; i >= 0; i--) {
+            for (i = parser->toknext - 1; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     parser->toksuper = -1;
@@ -275,12 +301,15 @@ int jsmn_parse(
                 }
             }
             /* Error if unmatched closing bracket */
-            if(i == -1) {
+            if (i == -1)
+            {
                 return JSMN_ERROR_INVAL;
             }
-            for(; i >= 0; i--) {
+            for (; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
+                if (token->start != -1 && token->end == -1)
+                {
                     parser->toksuper = i;
                     break;
                 }
@@ -289,11 +318,13 @@ int jsmn_parse(
             break;
         case '\"':
             r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -306,15 +337,19 @@ int jsmn_parse(
             parser->toksuper = parser->toknext - 1;
             break;
         case ',':
-            if(tokens != NULL && parser->toksuper != -1 &&
-               tokens[parser->toksuper].type != JSMN_ARRAY &&
-               tokens[parser->toksuper].type != JSMN_OBJECT) {
+            if (tokens != NULL && parser->toksuper != -1 &&
+                tokens[parser->toksuper].type != JSMN_ARRAY &&
+                tokens[parser->toksuper].type != JSMN_OBJECT)
+            {
 #ifdef JSMN_PARENT_LINKS
                 parser->toksuper = tokens[parser->toksuper].parent;
 #else
-                for(i = parser->toknext - 1; i >= 0; i--) {
-                    if(tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
-                        if(tokens[i].start != -1 && tokens[i].end == -1) {
+                for (i = parser->toknext - 1; i >= 0; i--)
+                {
+                    if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT)
+                    {
+                        if (tokens[i].start != -1 && tokens[i].end == -1)
+                        {
                             parser->toksuper = i;
                             break;
                         }
@@ -340,9 +375,12 @@ int jsmn_parse(
         case 'f':
         case 'n':
             /* And they must not be keys of the object */
-            if(tokens != NULL && parser->toksuper != -1) {
-                const jsmntok_t* t = &tokens[parser->toksuper];
-                if(t->type == JSMN_OBJECT || (t->type == JSMN_STRING && t->size != 0)) {
+            if (tokens != NULL && parser->toksuper != -1)
+            {
+                const jsmntok_t *t = &tokens[parser->toksuper];
+                if (t->type == JSMN_OBJECT ||
+                    (t->type == JSMN_STRING && t->size != 0))
+                {
                     return JSMN_ERROR_INVAL;
                 }
             }
@@ -351,11 +389,13 @@ int jsmn_parse(
         default:
 #endif
             r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -368,10 +408,13 @@ int jsmn_parse(
         }
     }
 
-    if(tokens != NULL) {
-        for(i = parser->toknext - 1; i >= 0; i--) {
+    if (tokens != NULL)
+    {
+        for (i = parser->toknext - 1; i >= 0; i--)
+        {
             /* Unmatched opened object or array */
-            if(tokens[i].start != -1 && tokens[i].end == -1) {
+            if (tokens[i].start != -1 && tokens[i].end == -1)
+            {
                 return JSMN_ERROR_PART;
             }
         }
@@ -381,10 +424,12 @@ int jsmn_parse(
 }
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value) {
-    int length = strlen(key) + strlen(value) + 8; // Calculate required length
-    char* result = (char*)malloc(length * sizeof(char)); // Allocate memory
-    if(result == NULL) {
+char *jsmn(const char *key, const char *value)
+{
+    int length = strlen(key) + strlen(value) + 8;         // Calculate required length
+    char *result = (char *)malloc(length * sizeof(char)); // Allocate memory
+    if (result == NULL)
+    {
         return NULL; // Handle memory allocation failure
     }
     snprintf(result, length, "{\"%s\":\"%s\"}", key, value);
@@ -392,30 +437,36 @@ char* jsmn(const char* key, const char* value) {
 }
 
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s) {
-    if(tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
-       strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+    if (tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
+        strncmp(json + tok->start, s, tok->end - tok->start) == 0)
+    {
         return 0;
     }
     return -1;
 }
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens)
+{
     // Parse the JSON feed
-    if(json_data != NULL) {
+    if (json_data != NULL)
+    {
         jsmn_parser parser;
         jsmn_init(&parser);
 
         // Allocate tokens array on the heap
-        jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-        if(tokens == NULL) {
+        jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+        if (tokens == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
             return NULL;
         }
 
         int ret = jsmn_parse(&parser, json_data, strlen(json_data), tokens, max_tokens);
-        if(ret < 0) {
+        if (ret < 0)
+        {
             // Handle parsing errors
             FURI_LOG_E("JSMM.H", "Failed to parse JSON: %d", ret);
             free(tokens);
@@ -423,19 +474,23 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
         }
 
         // Ensure that the root element is an object
-        if(ret < 1 || tokens[0].type != JSMN_OBJECT) {
+        if (ret < 1 || tokens[0].type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Root element is not an object.");
             free(tokens);
             return NULL;
         }
 
         // Loop through the tokens to find the key
-        for(int i = 1; i < ret; i++) {
-            if(jsoneq(json_data, &tokens[i], key) == 0) {
+        for (int i = 1; i < ret; i++)
+        {
+            if (jsoneq(json_data, &tokens[i], key) == 0)
+            {
                 // We found the key. Now, return the associated value.
                 int length = tokens[i + 1].end - tokens[i + 1].start;
-                char* value = malloc(length + 1);
-                if(value == NULL) {
+                char *value = malloc(length + 1);
+                if (value == NULL)
+                {
                     FURI_LOG_E("JSMM.H", "Failed to allocate memory for value.");
                     free(tokens);
                     return NULL;
@@ -450,7 +505,9 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 
         // Free the token array if key was not found
         free(tokens);
-    } else {
+    }
+    else
+    {
         FURI_LOG_E("JSMM.H", "JSON data is NULL");
     }
     FURI_LOG_E("JSMM.H", "Failed to find the key in the JSON.");
@@ -458,10 +515,12 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 }
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens) {
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -471,8 +530,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -480,7 +540,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -488,7 +549,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Ensure the root element is an array
-    if(ret < 1 || tokens[0].type != JSMN_ARRAY) {
+    if (ret < 1 || tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -496,12 +558,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Check if the index is within bounds
-    if(index >= (uint32_t)tokens[0].size) {
-        FURI_LOG_E(
-            "JSMM.H",
-            "Index %lu out of bounds for array with size %d.",
-            (unsigned long)index,
-            tokens[0].size);
+    if (index >= (uint32_t)tokens[0].size)
+    {
+        FURI_LOG_E("JSMM.H", "Index %lu out of bounds for array with size %d.", (unsigned long)index, tokens[0].size);
         free(tokens);
         free(array_str);
         return NULL;
@@ -509,20 +568,27 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Locate the token corresponding to the desired array element
     int current_token = 1; // Start after the array token
-    for(uint32_t i = 0; i < index; i++) {
-        if(tokens[current_token].type == JSMN_OBJECT) {
+    for (uint32_t i = 0; i < index; i++)
+    {
+        if (tokens[current_token].type == JSMN_OBJECT)
+        {
             // For objects, skip all key-value pairs
             current_token += 1 + 2 * tokens[current_token].size;
-        } else if(tokens[current_token].type == JSMN_ARRAY) {
+        }
+        else if (tokens[current_token].type == JSMN_ARRAY)
+        {
             // For nested arrays, skip all elements
             current_token += 1 + tokens[current_token].size;
-        } else {
+        }
+        else
+        {
             // For primitive types, simply move to the next token
             current_token += 1;
         }
 
         // Safety check to prevent out-of-bounds
-        if(current_token >= ret) {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             free(tokens);
             free(array_str);
@@ -533,8 +599,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     // Extract the array element
     jsmntok_t element = tokens[current_token];
     int length = element.end - element.start;
-    char* value = malloc(length + 1);
-    if(value == NULL) {
+    char *value = malloc(length + 1);
+    if (value == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
         free(tokens);
         free(array_str);
@@ -553,10 +620,12 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 }
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values) {
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -566,8 +635,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -575,7 +645,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -583,7 +654,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     }
 
     // Ensure the root element is an array
-    if(tokens[0].type != JSMN_ARRAY) {
+    if (tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -592,8 +664,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Allocate memory for the array of values (maximum possible)
     int array_size = tokens[0].size;
-    char** values = malloc(array_size * sizeof(char*));
-    if(values == NULL) {
+    char **values = malloc(array_size * sizeof(char *));
+    if (values == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array of values.");
         free(tokens);
         free(array_str);
@@ -604,15 +677,18 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Traverse the array and extract all object values
     int current_token = 1; // Start after the array token
-    for(int i = 0; i < array_size; i++) {
-        if(current_token >= ret) {
+    for (int i = 0; i < array_size; i++)
+    {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             break;
         }
 
         jsmntok_t element = tokens[current_token];
 
-        if(element.type != JSMN_OBJECT) {
+        if (element.type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Array element %d is not an object, skipping.", i);
             // Skip this element
             current_token += 1;
@@ -622,10 +698,12 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
         int length = element.end - element.start;
 
         // Allocate a new string for the value and copy the data
-        char* value = malloc(length + 1);
-        if(value == NULL) {
+        char *value = malloc(length + 1);
+        if (value == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
-            for(int j = 0; j < actual_num_values; j++) {
+            for (int j = 0; j < actual_num_values; j++)
+            {
                 free(values[j]);
             }
             free(values);
@@ -647,14 +725,17 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     *num_values = actual_num_values;
 
     // Reallocate the values array to actual_num_values if necessary
-    if(actual_num_values < array_size) {
-        char** reduced_values = realloc(values, actual_num_values * sizeof(char*));
-        if(reduced_values != NULL) {
+    if (actual_num_values < array_size)
+    {
+        char **reduced_values = realloc(values, actual_num_values * sizeof(char *));
+        if (reduced_values != NULL)
+        {
             values = reduced_values;
         }
 
         // Free the remaining values
-        for(int i = actual_num_values; i < array_size; i++) {
+        for (int i = actual_num_values; i < array_size; i++)
+        {
             free(values[i]);
         }
     }

+ 49 - 48
flip_weather/jsmn/jsmn.h

@@ -19,7 +19,8 @@
 #include <stddef.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
 #ifdef JSMN_STATIC
@@ -28,71 +29,71 @@ extern "C" {
 #define JSMN_API extern
 #endif
 
-/**
+    /**
      * JSON type identifier. Basic types are:
      * 	o Object
      * 	o Array
      * 	o String
      * 	o Other primitive: number, boolean (true/false) or null
      */
-typedef enum {
-    JSMN_UNDEFINED = 0,
-    JSMN_OBJECT = 1 << 0,
-    JSMN_ARRAY = 1 << 1,
-    JSMN_STRING = 1 << 2,
-    JSMN_PRIMITIVE = 1 << 3
-} jsmntype_t;
-
-enum jsmnerr {
-    /* Not enough tokens were provided */
-    JSMN_ERROR_NOMEM = -1,
-    /* Invalid character inside JSON string */
-    JSMN_ERROR_INVAL = -2,
-    /* The string is not a full JSON packet, more bytes expected */
-    JSMN_ERROR_PART = -3
-};
-
-/**
+    typedef enum
+    {
+        JSMN_UNDEFINED = 0,
+        JSMN_OBJECT = 1 << 0,
+        JSMN_ARRAY = 1 << 1,
+        JSMN_STRING = 1 << 2,
+        JSMN_PRIMITIVE = 1 << 3
+    } jsmntype_t;
+
+    enum jsmnerr
+    {
+        /* Not enough tokens were provided */
+        JSMN_ERROR_NOMEM = -1,
+        /* Invalid character inside JSON string */
+        JSMN_ERROR_INVAL = -2,
+        /* The string is not a full JSON packet, more bytes expected */
+        JSMN_ERROR_PART = -3
+    };
+
+    /**
      * JSON token description.
      * type		type (object, array, string etc.)
      * start	start position in JSON data string
      * end		end position in JSON data string
      */
-typedef struct {
-    jsmntype_t type;
-    int start;
-    int end;
-    int size;
+    typedef struct
+    {
+        jsmntype_t type;
+        int start;
+        int end;
+        int size;
 #ifdef JSMN_PARENT_LINKS
-    int parent;
+        int parent;
 #endif
-} jsmntok_t;
+    } jsmntok_t;
 
-/**
+    /**
      * JSON parser. Contains an array of token blocks available. Also stores
      * the string being parsed now and current position in that string.
      */
-typedef struct {
-    unsigned int pos; /* offset in the JSON string */
-    unsigned int toknext; /* next token to allocate */
-    int toksuper; /* superior token node, e.g. parent object or array */
-} jsmn_parser;
-
-/**
+    typedef struct
+    {
+        unsigned int pos;     /* offset in the JSON string */
+        unsigned int toknext; /* next token to allocate */
+        int toksuper;         /* superior token node, e.g. parent object or array */
+    } jsmn_parser;
+
+    /**
      * Create JSON parser over an array of tokens
      */
-JSMN_API void jsmn_init(jsmn_parser* parser);
+    JSMN_API void jsmn_init(jsmn_parser *parser);
 
-/**
+    /**
      * Run JSON parser. It parses a JSON data string into and array of tokens, each
      * describing a single JSON object.
      */
-JSMN_API int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens);
+    JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+                            jsmntok_t *tokens, const unsigned int num_tokens);
 
 #ifndef JSMN_HEADER
 /* Implementation has been moved to jsmn.c */
@@ -116,16 +117,16 @@ JSMN_API int jsmn_parse(
 #include <furi.h>
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value);
+char *jsmn(const char *key, const char *value);
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s);
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens);
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens);
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values);
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values);
 #endif /* JB_JSMN_EDIT */

+ 67 - 74
flip_weather/parse/flip_weather_parse.c

@@ -6,15 +6,17 @@ bool got_ip_address = false;
 bool geo_information_processed = false;
 bool weather_information_processed = false;
 
-bool send_geo_location_request() {
-    if(fhttp.state == INACTIVE) {
+bool send_geo_location_request()
+{
+    if (fhttp.state == INACTIVE)
+    {
         FURI_LOG_E(TAG, "Board is INACTIVE");
         flipper_http_ping(); // ping the device
         fhttp.state = ISSUE;
         return false;
     }
-    if(!flipper_http_get_request_with_headers(
-           "https://ipwhois.app/json/", "{\"Content-Type\": \"application/json\"}")) {
+    if (!flipper_http_get_request_with_headers("https://ipwhois.app/json/", "{\"Content-Type\": \"application/json\"}"))
+    {
         FURI_LOG_E(TAG, "Failed to send GET request");
         fhttp.state = ISSUE;
         return false;
@@ -23,18 +25,15 @@ bool send_geo_location_request() {
     return true;
 }
 
-bool send_geo_weather_request(DataLoaderModel* model) {
+bool send_geo_weather_request(DataLoaderModel *model)
+{
     UNUSED(model);
     char url[512];
-    char* lattitude = lat_data + 10;
-    char* longitude = lon_data + 11;
-    snprintf(
-        url,
-        512,
-        "https://api.open-meteo.com/v1/forecast?latitude=%s&longitude=%s&current=temperature_2m,precipitation,rain,showers,snowfall&temperature_unit=celsius&wind_speed_unit=mph&precipitation_unit=inch&forecast_days=1",
-        lattitude,
-        longitude);
-    if(!flipper_http_get_request_with_headers(url, "{\"Content-Type\": \"application/json\"}")) {
+    char *lattitude = lat_data + 10;
+    char *longitude = lon_data + 11;
+    snprintf(url, 512, "https://api.open-meteo.com/v1/forecast?latitude=%s&longitude=%s&current=temperature_2m,precipitation,rain,showers,snowfall&temperature_unit=celsius&wind_speed_unit=mph&precipitation_unit=inch&forecast_days=1", lattitude, longitude);
+    if (!flipper_http_get_request_with_headers(url, "{\"Content-Type\": \"application/json\"}"))
+    {
         FURI_LOG_E(TAG, "Failed to send GET request");
         fhttp.state = ISSUE;
         return false;
@@ -42,17 +41,19 @@ bool send_geo_weather_request(DataLoaderModel* model) {
     fhttp.state = RECEIVING;
     return true;
 }
-char* process_geo_location(DataLoaderModel* model) {
+char *process_geo_location(DataLoaderModel *model)
+{
     UNUSED(model);
-    if(fhttp.last_response != NULL) {
-        char* city = get_json_value("city", fhttp.last_response, MAX_TOKENS);
-        char* region = get_json_value("region", fhttp.last_response, MAX_TOKENS);
-        char* country = get_json_value("country", fhttp.last_response, MAX_TOKENS);
-        char* latitude = get_json_value("latitude", fhttp.last_response, MAX_TOKENS);
-        char* longitude = get_json_value("longitude", fhttp.last_response, MAX_TOKENS);
-
-        if(city == NULL || region == NULL || country == NULL || latitude == NULL ||
-           longitude == NULL) {
+    if (fhttp.last_response != NULL)
+    {
+        char *city = get_json_value("city", fhttp.last_response, MAX_TOKENS);
+        char *region = get_json_value("region", fhttp.last_response, MAX_TOKENS);
+        char *country = get_json_value("country", fhttp.last_response, MAX_TOKENS);
+        char *latitude = get_json_value("latitude", fhttp.last_response, MAX_TOKENS);
+        char *longitude = get_json_value("longitude", fhttp.last_response, MAX_TOKENS);
+
+        if (city == NULL || region == NULL || country == NULL || latitude == NULL || longitude == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to get geo location data");
             fhttp.state = ISSUE;
             return NULL;
@@ -61,23 +62,17 @@ char* process_geo_location(DataLoaderModel* model) {
         snprintf(lat_data, sizeof(lat_data), "Latitude: %s", latitude);
         snprintf(lon_data, sizeof(lon_data), "Longitude: %s", longitude);
 
-        if(!total_data) {
-            total_data = (char*)malloc(512);
-            if(!total_data) {
+        if (!total_data)
+        {
+            total_data = (char *)malloc(512);
+            if (!total_data)
+            {
                 FURI_LOG_E(TAG, "Failed to allocate memory for total_data");
                 fhttp.state = ISSUE;
                 return NULL;
             }
         }
-        snprintf(
-            total_data,
-            512,
-            "You are in %s, %s, %s. \nLatitude: %s, Longitude: %s",
-            city,
-            region,
-            country,
-            latitude,
-            longitude);
+        snprintf(total_data, 512, "You are in %s, %s, %s. \nLatitude: %s, Longitude: %s", city, region, country, latitude, longitude);
 
         fhttp.state = IDLE;
         free(city);
@@ -89,16 +84,18 @@ char* process_geo_location(DataLoaderModel* model) {
     return total_data;
 }
 
-bool process_geo_location_2() {
-    if(fhttp.last_response != NULL) {
-        char* city = get_json_value("city", fhttp.last_response, MAX_TOKENS);
-        char* region = get_json_value("region", fhttp.last_response, MAX_TOKENS);
-        char* country = get_json_value("country", fhttp.last_response, MAX_TOKENS);
-        char* latitude = get_json_value("latitude", fhttp.last_response, MAX_TOKENS);
-        char* longitude = get_json_value("longitude", fhttp.last_response, MAX_TOKENS);
-
-        if(city == NULL || region == NULL || country == NULL || latitude == NULL ||
-           longitude == NULL) {
+bool process_geo_location_2()
+{
+    if (fhttp.last_response != NULL)
+    {
+        char *city = get_json_value("city", fhttp.last_response, MAX_TOKENS);
+        char *region = get_json_value("region", fhttp.last_response, MAX_TOKENS);
+        char *country = get_json_value("country", fhttp.last_response, MAX_TOKENS);
+        char *latitude = get_json_value("latitude", fhttp.last_response, MAX_TOKENS);
+        char *longitude = get_json_value("longitude", fhttp.last_response, MAX_TOKENS);
+
+        if (city == NULL || region == NULL || country == NULL || latitude == NULL || longitude == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to get geo location data");
             fhttp.state = ISSUE;
             return false;
@@ -118,48 +115,44 @@ bool process_geo_location_2() {
     return false;
 }
 
-char* process_weather(DataLoaderModel* model) {
+char *process_weather(DataLoaderModel *model)
+{
     UNUSED(model);
-    if(fhttp.last_response != NULL) {
-        char* current_data = get_json_value("current", fhttp.last_response, MAX_TOKENS);
-        char* temperature = get_json_value("temperature_2m", current_data, MAX_TOKENS);
-        char* precipitation = get_json_value("precipitation", current_data, MAX_TOKENS);
-        char* rain = get_json_value("rain", current_data, MAX_TOKENS);
-        char* showers = get_json_value("showers", current_data, MAX_TOKENS);
-        char* snowfall = get_json_value("snowfall", current_data, MAX_TOKENS);
-        char* time = get_json_value("time", current_data, MAX_TOKENS);
-
-        if(current_data == NULL || temperature == NULL || precipitation == NULL || rain == NULL ||
-           showers == NULL || snowfall == NULL || time == NULL) {
+    if (fhttp.last_response != NULL)
+    {
+        char *current_data = get_json_value("current", fhttp.last_response, MAX_TOKENS);
+        char *temperature = get_json_value("temperature_2m", current_data, MAX_TOKENS);
+        char *precipitation = get_json_value("precipitation", current_data, MAX_TOKENS);
+        char *rain = get_json_value("rain", current_data, MAX_TOKENS);
+        char *showers = get_json_value("showers", current_data, MAX_TOKENS);
+        char *snowfall = get_json_value("snowfall", current_data, MAX_TOKENS);
+        char *time = get_json_value("time", current_data, MAX_TOKENS);
+
+        if (current_data == NULL || temperature == NULL || precipitation == NULL || rain == NULL || showers == NULL || snowfall == NULL || time == NULL)
+        {
             FURI_LOG_E(TAG, "Failed to get weather data");
             fhttp.state = ISSUE;
             return NULL;
         }
 
         // replace the "T" in time with a space
-        char* ptr = strstr(time, "T");
-        if(ptr != NULL) {
+        char *ptr = strstr(time, "T");
+        if (ptr != NULL)
+        {
             *ptr = ' ';
         }
 
-        if(!weather_data) {
-            weather_data = (char*)malloc(512);
-            if(!weather_data) {
+        if (!weather_data)
+        {
+            weather_data = (char *)malloc(512);
+            if (!weather_data)
+            {
                 FURI_LOG_E(TAG, "Failed to allocate memory for weather_data");
                 fhttp.state = ISSUE;
                 return NULL;
             }
         }
-        snprintf(
-            weather_data,
-            512,
-            "Temperature: %s C\nPrecipitation: %s\nRain: %s\nShowers: %s\nSnowfall: %s\nTime: %s",
-            temperature,
-            precipitation,
-            rain,
-            showers,
-            snowfall,
-            time);
+        snprintf(weather_data, 512, "Temperature: %s C\nPrecipitation: %s\nRain: %s\nShowers: %s\nSnowfall: %s\nTime: %s", temperature, precipitation, rain, showers, snowfall, time);
 
         fhttp.state = IDLE;
         free(current_data);
@@ -171,4 +164,4 @@ char* process_weather(DataLoaderModel* model) {
         free(time);
     }
     return weather_data;
-}
+}

+ 16 - 13
flip_weather/parse/flip_weather_parse.h

@@ -9,7 +9,8 @@ extern bool weather_information_processed;
 
 // Add edits by Derek Jamison
 typedef enum DataState DataState;
-enum DataState {
+enum DataState
+{
     DataStateInitial,
     DataStateRequested,
     DataStateReceived,
@@ -19,30 +20,32 @@ enum DataState {
 };
 
 typedef enum FlipWeatherCustomEvent FlipWeatherCustomEvent;
-enum FlipWeatherCustomEvent {
+enum FlipWeatherCustomEvent
+{
     FlipWeatherCustomEventProcess,
 };
 
 typedef struct DataLoaderModel DataLoaderModel;
-typedef bool (*DataLoaderFetch)(DataLoaderModel* model);
-typedef char* (*DataLoaderParser)(DataLoaderModel* model);
-struct DataLoaderModel {
-    char* title;
-    char* data_text;
+typedef bool (*DataLoaderFetch)(DataLoaderModel *model);
+typedef char *(*DataLoaderParser)(DataLoaderModel *model);
+struct DataLoaderModel
+{
+    char *title;
+    char *data_text;
     DataState data_state;
     DataLoaderFetch fetcher;
     DataLoaderParser parser;
-    void* parser_context;
+    void *parser_context;
     size_t request_index;
     size_t request_count;
     ViewNavigationCallback back_callback;
-    FuriTimer* timer;
+    FuriTimer *timer;
 };
 
 bool send_geo_location_request();
-char* process_geo_location(DataLoaderModel* model);
+char *process_geo_location(DataLoaderModel *model);
 bool process_geo_location_2();
-char* process_weather(DataLoaderModel* model);
-bool send_geo_weather_request(DataLoaderModel* model);
+char *process_weather(DataLoaderModel *model);
+bool send_geo_weather_request(DataLoaderModel *model);
 
-#endif
+#endif

+ 3 - 3
flip_wifi/callback/flip_wifi_callback.c

@@ -984,14 +984,14 @@ void flip_wifi_text_updated_add_ssid(void *context)
     app->uart_text_input_buffer[app->uart_text_input_buffer_size - 1] = '\0';
     save_char("wifi-ssid", app->uart_text_input_buffer);
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipWiFiViewSubmenuMain);
-    uart_text_input_reset(app->uart_text_input);
-    uart_text_input_set_header_text(app->uart_text_input, "Enter Password");
+    text_input_reset(app->uart_text_input);
+    text_input_set_header_text(app->uart_text_input, "Enter Password");
     app->uart_text_input_buffer_size = MAX_SSID_LENGTH;
     free(app->uart_text_input_buffer);
     free(app->uart_text_input_temp_buffer);
     easy_flipper_set_buffer(&app->uart_text_input_buffer, app->uart_text_input_buffer_size);
     easy_flipper_set_buffer(&app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size);
-    uart_text_input_set_result_callback(app->uart_text_input, flip_wifi_text_updated_add_password, app, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size, false);
+    text_input_set_result_callback(app->uart_text_input, flip_wifi_text_updated_add_password, app, app->uart_text_input_temp_buffer, app->uart_text_input_buffer_size, false);
     view_dispatcher_switch_to_view(app->view_dispatcher, FlipWiFiViewTextInput);
 }
 void flip_wifi_text_updated_add_password(void *context)

+ 1 - 0
flip_wifi/easy_flipper/easy_flipper.h

@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <jsmn/jsmn.h>
+#include <jsmn/jsmn_furi.h>
 
 #define EASY_TAG "EasyFlipper"
 

+ 176 - 272
web_crawler/alloc/web_crawler_alloc.c

@@ -4,25 +4,27 @@
  * @brief      Function to allocate resources for the WebCrawlerApp.
  * @return     Pointer to the initialized WebCrawlerApp, or NULL on failure.
  */
-WebCrawlerApp* web_crawler_app_alloc() {
+WebCrawlerApp *web_crawler_app_alloc()
+{
     // Initialize the entire structure to zero to prevent undefined behavior
-    WebCrawlerApp* app = (WebCrawlerApp*)malloc(sizeof(WebCrawlerApp));
+    WebCrawlerApp *app = (WebCrawlerApp *)malloc(sizeof(WebCrawlerApp));
 
     // Open GUI
-    Gui* gui = furi_record_open(RECORD_GUI);
+    Gui *gui = furi_record_open(RECORD_GUI);
 
     // Initialize UART with the correct callback
-    if(!flipper_http_init(flipper_http_rx_callback, app)) {
+    if (!flipper_http_init(flipper_http_rx_callback, app))
+    {
         FURI_LOG_E(TAG, "Failed to initialize UART");
         return NULL;
     }
 
     // Allocate ViewDispatcher
-    if(!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app)) {
+    if (!easy_flipper_set_view_dispatcher(&app->view_dispatcher, gui, app))
+    {
         return NULL;
     }
-    view_dispatcher_set_custom_event_callback(
-        app->view_dispatcher, web_crawler_custom_event_callback);
+    view_dispatcher_set_custom_event_callback(app->view_dispatcher, web_crawler_custom_event_callback);
 
     // Allocate and initialize temp_buffer and path
     app->temp_buffer_size_path = 128;
@@ -33,377 +35,281 @@ WebCrawlerApp* web_crawler_app_alloc() {
     app->temp_buffer_size_http_method = 16;
     app->temp_buffer_size_headers = 256;
     app->temp_buffer_size_payload = 256;
-    if(!easy_flipper_set_buffer(&app->temp_buffer_path, app->temp_buffer_size_path)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_path, app->temp_buffer_size_path))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->path, app->temp_buffer_size_path)) {
+    if (!easy_flipper_set_buffer(&app->path, app->temp_buffer_size_path))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_ssid, app->temp_buffer_size_ssid)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_ssid, app->temp_buffer_size_ssid))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->ssid, app->temp_buffer_size_ssid)) {
+    if (!easy_flipper_set_buffer(&app->ssid, app->temp_buffer_size_ssid))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_password, app->temp_buffer_size_password)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_password, app->temp_buffer_size_password))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->password, app->temp_buffer_size_password)) {
+    if (!easy_flipper_set_buffer(&app->password, app->temp_buffer_size_password))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_file_type, app->temp_buffer_size_file_type)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_file_type, app->temp_buffer_size_file_type))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->file_type, app->temp_buffer_size_file_type)) {
+    if (!easy_flipper_set_buffer(&app->file_type, app->temp_buffer_size_file_type))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_file_rename, app->temp_buffer_size_file_rename)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_file_rename, app->temp_buffer_size_file_rename))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->file_rename, app->temp_buffer_size_file_rename)) {
+    if (!easy_flipper_set_buffer(&app->file_rename, app->temp_buffer_size_file_rename))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_http_method, app->temp_buffer_size_http_method)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_http_method, app->temp_buffer_size_http_method))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->http_method, app->temp_buffer_size_http_method)) {
+    if (!easy_flipper_set_buffer(&app->http_method, app->temp_buffer_size_http_method))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_headers, app->temp_buffer_size_headers)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_headers, app->temp_buffer_size_headers))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->headers, app->temp_buffer_size_headers)) {
+    if (!easy_flipper_set_buffer(&app->headers, app->temp_buffer_size_headers))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->temp_buffer_payload, app->temp_buffer_size_payload)) {
+    if (!easy_flipper_set_buffer(&app->temp_buffer_payload, app->temp_buffer_size_payload))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_buffer(&app->payload, app->temp_buffer_size_payload)) {
+    if (!easy_flipper_set_buffer(&app->payload, app->temp_buffer_size_payload))
+    {
         return NULL;
     }
 
     // Allocate TextInput views
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_path,
-           WebCrawlerViewTextInput,
-           "Enter URL",
-           app->temp_buffer_path,
-           app->temp_buffer_size_path,
-           NULL,
-           web_crawler_back_to_request_callback,
-           &app->view_dispatcher,
-           app)) {
-        return NULL;
-    }
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_ssid,
-           WebCrawlerViewTextInputSSID,
-           "Enter SSID",
-           app->temp_buffer_ssid,
-           app->temp_buffer_size_ssid,
-           NULL,
-           web_crawler_back_to_wifi_callback,
-           &app->view_dispatcher,
-           app)) {
-        return NULL;
-    }
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_password,
-           WebCrawlerViewTextInputPassword,
-           "Enter Password",
-           app->temp_buffer_password,
-           app->temp_buffer_size_password,
-           NULL,
-           web_crawler_back_to_wifi_callback,
-           &app->view_dispatcher,
-           app)) {
-        return NULL;
-    }
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_file_type,
-           WebCrawlerViewTextInputFileType,
-           "Enter File Type",
-           app->temp_buffer_file_type,
-           app->temp_buffer_size_file_type,
-           NULL,
-           web_crawler_back_to_file_callback,
-           &app->view_dispatcher,
-           app)) {
-        return NULL;
-    }
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_file_rename,
-           WebCrawlerViewTextInputFileRename,
-           "Enter File Rename",
-           app->temp_buffer_file_rename,
-           app->temp_buffer_size_file_rename,
-           NULL,
-           web_crawler_back_to_file_callback,
-           &app->view_dispatcher,
-           app)) {
-        return NULL;
-    }
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_headers,
-           WebCrawlerViewTextInputHeaders,
-           "Enter Headers",
-           app->temp_buffer_headers,
-           app->temp_buffer_size_headers,
-           NULL,
-           web_crawler_back_to_request_callback,
-           &app->view_dispatcher,
-           app)) {
-        return NULL;
-    }
-    if(!easy_flipper_set_uart_text_input(
-           &app->text_input_payload,
-           WebCrawlerViewTextInputPayload,
-           "Enter Payload",
-           app->temp_buffer_payload,
-           app->temp_buffer_size_payload,
-           NULL,
-           web_crawler_back_to_request_callback,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_uart_text_input(&app->text_input_path, WebCrawlerViewTextInput, "Enter URL", app->temp_buffer_path, app->temp_buffer_size_path, NULL, web_crawler_back_to_request_callback, &app->view_dispatcher, app))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_uart_text_input(&app->text_input_ssid, WebCrawlerViewTextInputSSID, "Enter SSID", app->temp_buffer_ssid, app->temp_buffer_size_ssid, NULL, web_crawler_back_to_wifi_callback, &app->view_dispatcher, app))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_uart_text_input(&app->text_input_password, WebCrawlerViewTextInputPassword, "Enter Password", app->temp_buffer_password, app->temp_buffer_size_password, NULL, web_crawler_back_to_wifi_callback, &app->view_dispatcher, app))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_uart_text_input(&app->text_input_file_type, WebCrawlerViewTextInputFileType, "Enter File Type", app->temp_buffer_file_type, app->temp_buffer_size_file_type, NULL, web_crawler_back_to_file_callback, &app->view_dispatcher, app))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_uart_text_input(&app->text_input_file_rename, WebCrawlerViewTextInputFileRename, "Enter File Rename", app->temp_buffer_file_rename, app->temp_buffer_size_file_rename, NULL, web_crawler_back_to_file_callback, &app->view_dispatcher, app))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_uart_text_input(&app->text_input_headers, WebCrawlerViewTextInputHeaders, "Enter Headers", app->temp_buffer_headers, app->temp_buffer_size_headers, NULL, web_crawler_back_to_request_callback, &app->view_dispatcher, app))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_uart_text_input(&app->text_input_payload, WebCrawlerViewTextInputPayload, "Enter Payload", app->temp_buffer_payload, app->temp_buffer_size_payload, NULL, web_crawler_back_to_request_callback, &app->view_dispatcher, app))
+    {
         return NULL;
     }
 
     // Allocate VariableItemList views
-    if(!easy_flipper_set_variable_item_list(
-           &app->variable_item_list_wifi,
-           WebCrawlerViewVariableItemListWifi,
-           web_crawler_wifi_enter_callback,
-           web_crawler_back_to_configure_callback,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_variable_item_list(&app->variable_item_list_wifi, WebCrawlerViewVariableItemListWifi, web_crawler_wifi_enter_callback, web_crawler_back_to_configure_callback, &app->view_dispatcher, app))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_variable_item_list(
-           &app->variable_item_list_file,
-           WebCrawlerViewVariableItemListFile,
-           web_crawler_file_enter_callback,
-           web_crawler_back_to_configure_callback,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_variable_item_list(&app->variable_item_list_file, WebCrawlerViewVariableItemListFile, web_crawler_file_enter_callback, web_crawler_back_to_configure_callback, &app->view_dispatcher, app))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_variable_item_list(
-           &app->variable_item_list_request,
-           WebCrawlerViewVariableItemListRequest,
-           web_crawler_request_enter_callback,
-           web_crawler_back_to_configure_callback,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_variable_item_list(&app->variable_item_list_request, WebCrawlerViewVariableItemListRequest, web_crawler_request_enter_callback, web_crawler_back_to_configure_callback, &app->view_dispatcher, app))
+    {
         return NULL;
     }
 
     // set variable items
-    app->path_item =
-        variable_item_list_add(app->variable_item_list_request, "Path", 0, NULL, NULL);
-    app->http_method_item = variable_item_list_add(
-        app->variable_item_list_request, "HTTP Method", 5, web_crawler_http_method_change, app);
-    app->headers_item =
-        variable_item_list_add(app->variable_item_list_request, "Headers", 0, NULL, NULL);
-    app->payload_item =
-        variable_item_list_add(app->variable_item_list_request, "Payload", 0, NULL, NULL);
+    app->path_item = variable_item_list_add(app->variable_item_list_request, "Path", 0, NULL, NULL);
+    app->http_method_item = variable_item_list_add(app->variable_item_list_request, "HTTP Method", 5, web_crawler_http_method_change, app);
+    app->headers_item = variable_item_list_add(app->variable_item_list_request, "Headers", 0, NULL, NULL);
+    app->payload_item = variable_item_list_add(app->variable_item_list_request, "Payload", 0, NULL, NULL);
     //
-    app->ssid_item =
-        variable_item_list_add(app->variable_item_list_wifi, "SSID", 0, NULL, NULL); // index 0
-    app->password_item =
-        variable_item_list_add(app->variable_item_list_wifi, "Password", 0, NULL, NULL); // index 1
+    app->ssid_item = variable_item_list_add(app->variable_item_list_wifi, "SSID", 0, NULL, NULL);         // index 0
+    app->password_item = variable_item_list_add(app->variable_item_list_wifi, "Password", 0, NULL, NULL); // index 1
     //
-    app->file_read_item = variable_item_list_add(
-        app->variable_item_list_file, "Read File", 0, NULL, NULL); // index 0
-    app->file_type_item = variable_item_list_add(
-        app->variable_item_list_file, "Set File Type", 0, NULL, NULL); // index 1
-    app->file_rename_item = variable_item_list_add(
-        app->variable_item_list_file, "Rename File", 0, NULL, NULL); // index 2
-    app->file_delete_item = variable_item_list_add(
-        app->variable_item_list_file, "Delete File", 0, NULL, NULL); // index 3
+    app->file_read_item = variable_item_list_add(app->variable_item_list_file, "Read File", 0, NULL, NULL);     // index 0
+    app->file_type_item = variable_item_list_add(app->variable_item_list_file, "Set File Type", 0, NULL, NULL); // index 1
+    app->file_rename_item = variable_item_list_add(app->variable_item_list_file, "Rename File", 0, NULL, NULL); // index 2
+    app->file_delete_item = variable_item_list_add(app->variable_item_list_file, "Delete File", 0, NULL, NULL); // index 3
 
-    if(!app->ssid_item || !app->password_item || !app->file_type_item || !app->file_rename_item ||
-       !app->path_item || !app->file_read_item || !app->file_delete_item ||
-       !app->http_method_item || !app->headers_item || !app->payload_item) {
+    if (!app->ssid_item || !app->password_item || !app->file_type_item || !app->file_rename_item || !app->path_item || !app->file_read_item || !app->file_delete_item || !app->http_method_item || !app->headers_item || !app->payload_item)
+    {
         free_all(app, "Failed to add items to VariableItemList");
         return NULL;
     }
 
-    variable_item_set_current_value_text(app->path_item, ""); // Initialize
+    variable_item_set_current_value_text(app->path_item, "");        // Initialize
     variable_item_set_current_value_text(app->http_method_item, ""); // Initialize
-    variable_item_set_current_value_text(app->headers_item, ""); // Initialize
-    variable_item_set_current_value_text(app->payload_item, ""); // Initialize
-    variable_item_set_current_value_text(app->ssid_item, ""); // Initialize
-    variable_item_set_current_value_text(app->password_item, ""); // Initialize
-    variable_item_set_current_value_text(app->file_type_item, ""); // Initialize
+    variable_item_set_current_value_text(app->headers_item, "");     // Initialize
+    variable_item_set_current_value_text(app->payload_item, "");     // Initialize
+    variable_item_set_current_value_text(app->ssid_item, "");        // Initialize
+    variable_item_set_current_value_text(app->password_item, "");    // Initialize
+    variable_item_set_current_value_text(app->file_type_item, "");   // Initialize
     variable_item_set_current_value_text(app->file_rename_item, ""); // Initialize
-    variable_item_set_current_value_text(app->file_read_item, ""); // Initialize
+    variable_item_set_current_value_text(app->file_read_item, "");   // Initialize
     variable_item_set_current_value_text(app->file_delete_item, ""); // Initialize
 
     // Allocate Submenu views
-    if(!easy_flipper_set_submenu(
-           &app->submenu_main,
-           WebCrawlerViewSubmenuMain,
-           "Web Crawler v0.8",
-           web_crawler_exit_app_callback,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_submenu(&app->submenu_main, WebCrawlerViewSubmenuMain, "Web Crawler v0.8", web_crawler_exit_app_callback, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_submenu(
-           &app->submenu_config,
-           WebCrawlerViewSubmenuConfig,
-           "Settings",
-           web_crawler_back_to_main_callback,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_submenu(&app->submenu_config, WebCrawlerViewSubmenuConfig, "Settings", web_crawler_back_to_main_callback, &app->view_dispatcher))
+    {
         return NULL;
     }
 
     // Add Submenu items
-    submenu_add_item(
-        app->submenu_main, "Run", WebCrawlerSubmenuIndexRun, web_crawler_submenu_callback, app);
-    submenu_add_item(
-        app->submenu_main, "About", WebCrawlerSubmenuIndexAbout, web_crawler_submenu_callback, app);
-    submenu_add_item(
-        app->submenu_main,
-        "Settings",
-        WebCrawlerSubmenuIndexConfig,
-        web_crawler_submenu_callback,
-        app);
+    submenu_add_item(app->submenu_main, "Run", WebCrawlerSubmenuIndexRun, web_crawler_submenu_callback, app);
+    submenu_add_item(app->submenu_main, "About", WebCrawlerSubmenuIndexAbout, web_crawler_submenu_callback, app);
+    submenu_add_item(app->submenu_main, "Settings", WebCrawlerSubmenuIndexConfig, web_crawler_submenu_callback, app);
 
-    submenu_add_item(
-        app->submenu_config, "WiFi", WebCrawlerSubmenuIndexWifi, web_crawler_submenu_callback, app);
-    submenu_add_item(
-        app->submenu_config, "File", WebCrawlerSubmenuIndexFile, web_crawler_submenu_callback, app);
-    submenu_add_item(
-        app->submenu_config,
-        "Request",
-        WebCrawlerSubmenuIndexRequest,
-        web_crawler_submenu_callback,
-        app);
+    submenu_add_item(app->submenu_config, "WiFi", WebCrawlerSubmenuIndexWifi, web_crawler_submenu_callback, app);
+    submenu_add_item(app->submenu_config, "File", WebCrawlerSubmenuIndexFile, web_crawler_submenu_callback, app);
+    submenu_add_item(app->submenu_config, "Request", WebCrawlerSubmenuIndexRequest, web_crawler_submenu_callback, app);
 
     // Main view
-    if(!easy_flipper_set_view(
-           &app->view_loader,
-           WebCrawlerViewLoader,
-           web_crawler_loader_draw_callback,
-           NULL,
-           web_crawler_back_to_main_callback,
-           &app->view_dispatcher,
-           app)) {
+    if (!easy_flipper_set_view(&app->view_loader, WebCrawlerViewLoader, web_crawler_loader_draw_callback, NULL, web_crawler_back_to_main_callback, &app->view_dispatcher, app))
+    {
         return NULL;
     }
     web_crawler_loader_init(app->view_loader);
 
     //-- WIDGET ABOUT VIEW --
-    if(!easy_flipper_set_widget(
-           &app->widget_about,
-           WebCrawlerViewAbout,
-           "Web Crawler App\n---\nThis is a web crawler app for Flipper Zero.\n---\nVisit github.com/jblanked for more details.\n---\nPress BACK to return.",
-           web_crawler_back_to_main_callback,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_about, WebCrawlerViewAbout, "Web Crawler App\n---\nThis is a web crawler app for Flipper Zero.\n---\nVisit github.com/jblanked for more details.\n---\nPress BACK to return.", web_crawler_back_to_main_callback, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_widget(
-           &app->widget_file_read,
-           WebCrawlerViewFileRead,
-           "Data will be displayed here.",
-           web_crawler_back_to_file_callback,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_file_read, WebCrawlerViewFileRead, "Data will be displayed here.", web_crawler_back_to_file_callback, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_widget(
-           &app->widget_file_delete,
-           WebCrawlerViewFileDelete,
-           "File deleted.",
-           web_crawler_back_to_file_callback,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_file_delete, WebCrawlerViewFileDelete, "File deleted.", web_crawler_back_to_file_callback, &app->view_dispatcher))
+    {
         return NULL;
     }
-    if(!easy_flipper_set_widget(
-           &app->widget_result,
-           WebCrawlerViewWidgetResult,
-           "Error, try again.",
-           web_crawler_back_to_main_callback,
-           &app->view_dispatcher)) {
+    if (!easy_flipper_set_widget(&app->widget_result, WebCrawlerViewWidgetResult, "Error, try again.", web_crawler_back_to_main_callback, &app->view_dispatcher))
+    {
         return NULL;
     }
 
     // Load Settings and Update Views
-    if(!load_settings(
-           app->path,
-           app->temp_buffer_size_path,
-           app->ssid,
-           app->temp_buffer_size_ssid,
-           app->password,
-           app->temp_buffer_size_password,
-           app->file_rename,
-           app->temp_buffer_size_file_rename,
-           app->file_type,
-           app->temp_buffer_size_file_type,
-           app->http_method,
-           app->temp_buffer_size_http_method,
-           app->headers,
-           app->temp_buffer_size_headers,
-           app->payload,
-           app->temp_buffer_size_payload,
-           app)) {
+    if (!load_settings(
+            app->path,
+            app->temp_buffer_size_path,
+            app->ssid,
+            app->temp_buffer_size_ssid,
+            app->password,
+            app->temp_buffer_size_password,
+            app->file_rename,
+            app->temp_buffer_size_file_rename,
+            app->file_type,
+            app->temp_buffer_size_file_type,
+            app->http_method,
+            app->temp_buffer_size_http_method,
+            app->headers,
+            app->temp_buffer_size_headers,
+            app->payload,
+            app->temp_buffer_size_payload,
+            app))
+    {
         FURI_LOG_E(TAG, "Failed to load settings");
-    } else {
+    }
+    else
+    {
         // Update the configuration items based on loaded settings
-        if(app->path_item) {
+        if (app->path_item)
+        {
             variable_item_set_current_value_text(app->path_item, app->path);
-        } else {
-            variable_item_set_current_value_text(
-                app->path_item, "https://httpbin.org/get"); // Initialize
+        }
+        else
+        {
+            variable_item_set_current_value_text(app->path_item, "https://httpbin.org/get"); // Initialize
         }
 
-        if(app->ssid_item) {
+        if (app->ssid_item)
+        {
             variable_item_set_current_value_text(app->ssid_item, app->ssid);
-        } else {
+        }
+        else
+        {
             variable_item_set_current_value_text(app->ssid_item, ""); // Initialize
         }
 
-        if(app->file_type_item) {
+        if (app->file_type_item)
+        {
             variable_item_set_current_value_text(app->file_type_item, app->file_type);
-        } else {
+        }
+        else
+        {
             variable_item_set_current_value_text(app->file_type_item, ".txt"); // Initialize
         }
 
-        if(app->file_rename_item) {
+        if (app->file_rename_item)
+        {
             variable_item_set_current_value_text(app->file_rename_item, app->file_rename);
-        } else {
-            variable_item_set_current_value_text(
-                app->file_rename_item, "received_data"); // Initialize
+        }
+        else
+        {
+            variable_item_set_current_value_text(app->file_rename_item, "received_data"); // Initialize
         }
 
-        if(app->http_method_item) {
+        if (app->http_method_item)
+        {
             variable_item_set_current_value_text(app->http_method_item, app->http_method);
-        } else {
+        }
+        else
+        {
             variable_item_set_current_value_text(app->http_method_item, "GET"); // Initialize
         }
 
-        if(app->headers_item) {
+        if (app->headers_item)
+        {
             variable_item_set_current_value_text(app->headers_item, app->headers);
-        } else {
-            variable_item_set_current_value_text(
-                app->headers_item, "{\n\t\"Content-Type\": \"application/json\"\n}"); // Initialize
+        }
+        else
+        {
+            variable_item_set_current_value_text(app->headers_item, "{\n\t\"Content-Type\": \"application/json\"\n}"); // Initialize
         }
 
-        if(app->payload_item) {
+        if (app->payload_item)
+        {
             variable_item_set_current_value_text(app->payload_item, app->payload);
-        } else {
-            variable_item_set_current_value_text(
-                app->payload_item, "{\n\t\"key\": \"value\"\n}"); // Initialize
+        }
+        else
+        {
+            variable_item_set_current_value_text(app->payload_item, "{\n\t\"key\": \"value\"\n}"); // Initialize
         }
 
         // set the file path for fhttp.file_path
         char file_path[128];
-        snprintf(
-            file_path,
-            sizeof(file_path),
-            "%s%s%s",
-            RECEIVED_DATA_PATH,
-            app->file_rename,
-            app->file_type);
+        snprintf(file_path, sizeof(file_path), "%s%s%s", RECEIVED_DATA_PATH, app->file_rename, app->file_type);
         snprintf(fhttp.file_path, sizeof(fhttp.file_path), "%s", file_path);
 
         // update temp buffers
@@ -413,11 +319,9 @@ WebCrawlerApp* web_crawler_app_alloc() {
         app->temp_buffer_ssid[app->temp_buffer_size_ssid - 1] = '\0';
         strncpy(app->temp_buffer_file_type, app->file_type, app->temp_buffer_size_file_type - 1);
         app->temp_buffer_file_type[app->temp_buffer_size_file_type - 1] = '\0';
-        strncpy(
-            app->temp_buffer_file_rename, app->file_rename, app->temp_buffer_size_file_rename - 1);
+        strncpy(app->temp_buffer_file_rename, app->file_rename, app->temp_buffer_size_file_rename - 1);
         app->temp_buffer_file_rename[app->temp_buffer_size_file_rename - 1] = '\0';
-        strncpy(
-            app->temp_buffer_http_method, app->http_method, app->temp_buffer_size_http_method - 1);
+        strncpy(app->temp_buffer_http_method, app->http_method, app->temp_buffer_size_http_method - 1);
         app->temp_buffer_http_method[app->temp_buffer_size_http_method - 1] = '\0';
         strncpy(app->temp_buffer_headers, app->headers, app->temp_buffer_size_headers - 1);
         app->temp_buffer_headers[app->temp_buffer_size_headers - 1] = '\0';

+ 1 - 1
web_crawler/alloc/web_crawler_alloc.h

@@ -9,6 +9,6 @@
  * @brief      Function to allocate resources for the WebCrawlerApp.
  * @return     Pointer to the initialized WebCrawlerApp, or NULL on failure.
  */
-WebCrawlerApp* web_crawler_app_alloc();
+WebCrawlerApp *web_crawler_app_alloc();
 
 #endif // WEB_CRAWLER_I_H

+ 15 - 9
web_crawler/app.c

@@ -5,32 +5,38 @@
  * @param      p  Input parameter - unused
  * @return     0 to indicate success, -1 on failure
  */
-int32_t web_crawler_app(void* p) {
+int32_t web_crawler_app(void *p)
+{
     UNUSED(p);
 
     app_instance = web_crawler_app_alloc();
-    if(!app_instance) {
+    if (!app_instance)
+    {
         FURI_LOG_E(TAG, "Failed to allocate WebCrawlerApp");
         return -1;
     }
 
-    if(!flipper_http_ping()) {
+    if (!flipper_http_ping())
+    {
         FURI_LOG_E(TAG, "Failed to ping the device");
         return -1;
     }
 
     // Edit from Derek Jamison
-    if(app_instance->text_input_ssid != NULL && app_instance->text_input_password != NULL) {
+    if (app_instance->text_input_ssid != NULL && app_instance->text_input_password != NULL)
+    {
         // Try to wait for pong response.
         uint8_t counter = 10;
-        while(fhttp.state == INACTIVE && --counter > 0) {
+        while (fhttp.state == INACTIVE && --counter > 0)
+        {
             FURI_LOG_D(TAG, "Waiting for PONG");
             furi_delay_ms(100);
         }
 
-        if(counter == 0) {
-            DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
-            DialogMessage* message = dialog_message_alloc();
+        if (counter == 0)
+        {
+            DialogsApp *dialogs = furi_record_open(RECORD_DIALOGS);
+            DialogMessage *message = dialog_message_alloc();
             dialog_message_set_header(
                 message, "[FlipperHTTP Error]", 64, 0, AlignCenter, AlignTop);
             dialog_message_set_text(
@@ -53,4 +59,4 @@ int32_t web_crawler_app(void* p) {
     web_crawler_app_free(app_instance);
 
     return 0;
-}
+}

+ 1 - 1
web_crawler/application.fam

@@ -10,5 +10,5 @@ App(
     fap_description="Use Wi-Fi to access the internet and scrape data from the web.",
     fap_author="JBlanked",
     fap_weburl="https://github.com/jblanked/WebCrawler-FlipperZero",
-    fap_version="0.8",
+    fap_version = "0.8",
 )

File diff suppressed because it is too large
+ 275 - 245
web_crawler/callback/web_crawler_callback.c


+ 45 - 49
web_crawler/callback/web_crawler_callback.h

@@ -7,165 +7,166 @@ extern bool sent_http_request;
 extern bool get_success;
 extern bool already_success;
 
-void web_crawler_http_method_change(VariableItem* item);
+void web_crawler_http_method_change(VariableItem *item);
 
 /**
  * @brief      Navigation callback to handle exiting from other views to the submenu.
  * @param      context   The context - WebCrawlerApp object.
  * @return     WebCrawlerViewSubmenu
  */
-uint32_t web_crawler_back_to_configure_callback(void* context);
+uint32_t web_crawler_back_to_configure_callback(void *context);
 
 /**
  * @brief      Navigation callback to handle returning to the Wifi Settings screen.
  * @param      context   The context - WebCrawlerApp object.
  * @return     WebCrawlerViewSubmenu
  */
-uint32_t web_crawler_back_to_main_callback(void* context);
-uint32_t web_crawler_back_to_file_callback(void* context);
+uint32_t web_crawler_back_to_main_callback(void *context);
+uint32_t web_crawler_back_to_file_callback(void *context);
 
-uint32_t web_crawler_back_to_wifi_callback(void* context);
+uint32_t web_crawler_back_to_wifi_callback(void *context);
 
-uint32_t web_crawler_back_to_request_callback(void* context);
+uint32_t web_crawler_back_to_request_callback(void *context);
 
 /**
  * @brief      Navigation callback to handle exiting the app from the main submenu.
  * @param      context   The context - unused
  * @return     VIEW_NONE to exit the app
  */
-uint32_t web_crawler_exit_app_callback(void* context);
+uint32_t web_crawler_exit_app_callback(void *context);
 
 /**
  * @brief      Handle submenu item selection.
  * @param      context   The context - WebCrawlerApp object.
  * @param      index     The WebCrawlerSubmenuIndex item that was clicked.
  */
-void web_crawler_submenu_callback(void* context, uint32_t index);
+void web_crawler_submenu_callback(void *context, uint32_t index);
 
 /**
  * @brief      Configuration enter callback to handle different items.
  * @param      context   The context - WebCrawlerApp object.
  * @param      index     The index of the item that was clicked.
  */
-void web_crawler_wifi_enter_callback(void* context, uint32_t index);
+void web_crawler_wifi_enter_callback(void *context, uint32_t index);
 
 /**
  * @brief      Configuration enter callback to handle different items.
  * @param      context   The context - WebCrawlerApp object.
  * @param      index     The index of the item that was clicked.
  */
-void web_crawler_file_enter_callback(void* context, uint32_t index);
+void web_crawler_file_enter_callback(void *context, uint32_t index);
 
 /**
  * @brief      Configuration enter callback to handle different items.
  * @param      context   The context - WebCrawlerApp object.
  * @param      index     The index of the item that was clicked.
  */
-void web_crawler_request_enter_callback(void* context, uint32_t index);
+void web_crawler_request_enter_callback(void *context, uint32_t index);
 
 /**
  * @brief      Callback for when the user finishes entering the URL.
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_path_updated(void* context);
+void web_crawler_set_path_updated(void *context);
 
 /**
  * @brief      Callback for when the user finishes entering the headers
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_headers_updated(void* context);
+void web_crawler_set_headers_updated(void *context);
 
 /**
  * @brief      Callback for when the user finishes entering the payload.
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_payload_updated(void* context);
+void web_crawler_set_payload_updated(void *context);
 
 /**
  * @brief      Callback for when the user finishes entering the SSID.
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_ssid_updated(void* context);
+void web_crawler_set_ssid_updated(void *context);
 
 /**
  * @brief      Callback for when the user finishes entering the Password.
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_password_update(void* context);
+void web_crawler_set_password_update(void *context);
 
 /**
  * @brief      Callback for when the user finishes entering the File Type.
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_file_type_update(void* context);
+void web_crawler_set_file_type_update(void *context);
 
 /**
  * @brief      Callback for when the user finishes entering the File Rename.
  * @param      context   The context - WebCrawlerApp object.
  */
-void web_crawler_set_file_rename_update(void* context);
+void web_crawler_set_file_rename_update(void *context);
 
 /**
  * @brief      Handler for Path configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_path_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_path_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for headers configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_headers_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_headers_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for payload configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_payload_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_payload_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for SSID configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_ssid_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_ssid_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for Password configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_password_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_password_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for File Type configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_file_type_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_file_type_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for File Rename configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_file_rename_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_file_rename_clicked(void *context, uint32_t index);
 
 /**
  * @brief      Handler for File Delete configuration item click.
  * @param      context  The context - WebCrawlerApp object.
  * @param      index    The index of the item that was clicked.
  */
-void web_crawler_setting_item_file_delete_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_file_delete_clicked(void *context, uint32_t index);
 
-void web_crawler_setting_item_file_read_clicked(void* context, uint32_t index);
+void web_crawler_setting_item_file_read_clicked(void *context, uint32_t index);
 
 // Add edits by Derek Jamison
 typedef enum DataState DataState;
-enum DataState {
+enum DataState
+{
     DataStateInitial,
     DataStateRequested,
     DataStateReceived,
@@ -175,40 +176,35 @@ enum DataState {
 };
 
 typedef enum WebCrawlerCustomEvent WebCrawlerCustomEvent;
-enum WebCrawlerCustomEvent {
+enum WebCrawlerCustomEvent
+{
     WebCrawlerCustomEventProcess,
 };
 
 typedef struct DataLoaderModel DataLoaderModel;
-typedef bool (*DataLoaderFetch)(DataLoaderModel* model);
-typedef char* (*DataLoaderParser)(DataLoaderModel* model);
-struct DataLoaderModel {
-    char* title;
-    char* data_text;
+typedef bool (*DataLoaderFetch)(DataLoaderModel *model);
+typedef char *(*DataLoaderParser)(DataLoaderModel *model);
+struct DataLoaderModel
+{
+    char *title;
+    char *data_text;
     DataState data_state;
     DataLoaderFetch fetcher;
     DataLoaderParser parser;
-    void* parser_context;
+    void *parser_context;
     size_t request_index;
     size_t request_count;
     ViewNavigationCallback back_callback;
-    FuriTimer* timer;
+    FuriTimer *timer;
 };
 
-void web_crawler_generic_switch_to_view(
-    WebCrawlerApp* app,
-    char* title,
-    DataLoaderFetch fetcher,
-    DataLoaderParser parser,
-    size_t request_count,
-    ViewNavigationCallback back,
-    uint32_t view_id);
+void web_crawler_generic_switch_to_view(WebCrawlerApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id);
 
-void web_crawler_loader_draw_callback(Canvas* canvas, void* model);
+void web_crawler_loader_draw_callback(Canvas *canvas, void *model);
 
-void web_crawler_loader_init(View* view);
+void web_crawler_loader_init(View *view);
 
-void web_crawler_loader_free_model(View* view);
+void web_crawler_loader_free_model(View *view);
 
-bool web_crawler_custom_event_callback(void* context, uint32_t index);
-#endif
+bool web_crawler_custom_event_callback(void *context, uint32_t index);
+#endif

+ 198 - 139
web_crawler/easy_flipper/easy_flipper.c

@@ -5,9 +5,11 @@
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t easy_flipper_callback_exit_app(void* context) {
+uint32_t easy_flipper_callback_exit_app(void *context)
+{
     // Exit the application
-    if(!context) {
+    if (!context)
+    {
         FURI_LOG_E(EASY_TAG, "Context is NULL");
         return VIEW_NONE;
     }
@@ -21,13 +23,16 @@ uint32_t easy_flipper_callback_exit_app(void* context) {
  * @param buffer_size The size of the buffer
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size) {
-    if(!buffer) {
+bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size)
+{
+    if (!buffer)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer");
         return false;
     }
-    *buffer = (char*)malloc(buffer_size);
-    if(!*buffer) {
+    *buffer = (char *)malloc(buffer_size);
+    if (!*buffer)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate buffer");
         return false;
     }
@@ -46,32 +51,39 @@ bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size) {
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_view(
-    View** view,
+    View **view,
     int32_t view_id,
-    void draw_callback(Canvas*, void*),
-    bool input_callback(InputEvent*, void*),
-    uint32_t (*previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!view || !view_dispatcher) {
+    void draw_callback(Canvas *, void *),
+    bool input_callback(InputEvent *, void *),
+    uint32_t (*previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!view || !view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view");
         return false;
     }
     *view = view_alloc();
-    if(!*view) {
+    if (!*view)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate View");
         return false;
     }
-    if(draw_callback) {
+    if (draw_callback)
+    {
         view_set_draw_callback(*view, draw_callback);
     }
-    if(input_callback) {
+    if (input_callback)
+    {
         view_set_input_callback(*view, input_callback);
     }
-    if(context) {
+    if (context)
+    {
         view_set_context(*view, context);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(*view, previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, *view);
@@ -85,18 +97,22 @@ bool easy_flipper_set_view(
  * @param context The context to pass to the event callback
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui, void* context) {
-    if(!view_dispatcher) {
+bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context)
+{
+    if (!view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_view_dispatcher");
         return false;
     }
     *view_dispatcher = view_dispatcher_alloc();
-    if(!*view_dispatcher) {
+    if (!*view_dispatcher)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate ViewDispatcher");
         return false;
     }
     view_dispatcher_attach_to_gui(*view_dispatcher, gui, ViewDispatcherTypeFullscreen);
-    if(context) {
+    if (context)
+    {
         view_dispatcher_set_event_callback_context(*view_dispatcher, context);
     }
     return true;
@@ -113,24 +129,29 @@ bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_submenu(
-    Submenu** submenu,
+    Submenu **submenu,
     int32_t view_id,
-    char* title,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!submenu) {
+    char *title,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!submenu)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_submenu");
         return false;
     }
     *submenu = submenu_alloc();
-    if(!*submenu) {
+    if (!*submenu)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Submenu");
         return false;
     }
-    if(title) {
+    if (title)
+    {
         submenu_set_header(*submenu, title);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(submenu_get_view(*submenu), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, submenu_get_view(*submenu));
@@ -147,20 +168,24 @@ bool easy_flipper_set_submenu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_menu(
-    Menu** menu,
+    Menu **menu,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!menu) {
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!menu)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_menu");
         return false;
     }
     *menu = menu_alloc();
-    if(!*menu) {
+    if (!*menu)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Menu");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(menu_get_view(*menu), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, menu_get_view(*menu));
@@ -177,24 +202,29 @@ bool easy_flipper_set_menu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_widget(
-    Widget** widget,
+    Widget **widget,
     int32_t view_id,
-    char* text,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!widget) {
+    char *text,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!widget)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_widget");
         return false;
     }
     *widget = widget_alloc();
-    if(!*widget) {
+    if (!*widget)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Widget");
         return false;
     }
-    if(text) {
+    if (text)
+    {
         widget_add_text_scroll_element(*widget, 0, 0, 128, 64, text);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(widget_get_view(*widget), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, widget_get_view(*widget));
@@ -213,30 +243,33 @@ bool easy_flipper_set_widget(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_variable_item_list(
-    VariableItemList** variable_item_list,
+    VariableItemList **variable_item_list,
     int32_t view_id,
-    void (*enter_callback)(void*, uint32_t),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!variable_item_list) {
+    void (*enter_callback)(void *, uint32_t),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!variable_item_list)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_variable_item_list");
         return false;
     }
     *variable_item_list = variable_item_list_alloc();
-    if(!*variable_item_list) {
+    if (!*variable_item_list)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate VariableItemList");
         return false;
     }
-    if(enter_callback) {
+    if (enter_callback)
+    {
         variable_item_list_set_enter_callback(*variable_item_list, enter_callback, context);
     }
-    if(previous_callback) {
-        view_set_previous_callback(
-            variable_item_list_get_view(*variable_item_list), previous_callback);
+    if (previous_callback)
+    {
+        view_set_previous_callback(variable_item_list_get_view(*variable_item_list), previous_callback);
     }
-    view_dispatcher_add_view(
-        *view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
+    view_dispatcher_add_view(*view_dispatcher, view_id, variable_item_list_get_view(*variable_item_list));
     return true;
 }
 
@@ -249,38 +282,38 @@ bool easy_flipper_set_variable_item_list(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_text_input(
-    TextInput** text_input,
+    TextInput **text_input,
     int32_t view_id,
-    char* header_text,
-    char* text_input_temp_buffer,
+    char *header_text,
+    char *text_input_temp_buffer,
     uint32_t text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!text_input) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_text_input");
         return false;
     }
     *text_input = text_input_alloc();
-    if(!*text_input) {
+    if (!*text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate TextInput");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(text_input_get_view(*text_input), previous_callback);
     }
-    if(header_text) {
+    if (header_text)
+    {
         text_input_set_header_text(*text_input, header_text);
     }
-    if(text_input_temp_buffer && text_input_buffer_size && result_callback) {
-        text_input_set_result_callback(
-            *text_input,
-            result_callback,
-            context,
-            text_input_temp_buffer,
-            text_input_buffer_size,
-            false);
+    if (text_input_temp_buffer && text_input_buffer_size && result_callback)
+    {
+        text_input_set_result_callback(*text_input, result_callback, context, text_input_temp_buffer, text_input_buffer_size, false);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*text_input));
     return true;
@@ -295,38 +328,38 @@ bool easy_flipper_set_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    TextInput** uart_text_input,
+    TextInput **uart_text_input,
     int32_t view_id,
-    char* header_text,
-    char* uart_text_input_temp_buffer,
+    char *header_text,
+    char *uart_text_input_temp_buffer,
     uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!uart_text_input) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!uart_text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_uart_text_input");
         return false;
     }
     *uart_text_input = text_input_alloc();
-    if(!*uart_text_input) {
+    if (!*uart_text_input)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate UART_TextInput");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(text_input_get_view(*uart_text_input), previous_callback);
     }
-    if(header_text) {
+    if (header_text)
+    {
         text_input_set_header_text(*uart_text_input, header_text);
     }
-    if(uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback) {
-        text_input_set_result_callback(
-            *uart_text_input,
-            result_callback,
-            context,
-            uart_text_input_temp_buffer,
-            uart_text_input_buffer_size,
-            false);
+    if (uart_text_input_temp_buffer && uart_text_input_buffer_size && result_callback)
+    {
+        text_input_set_result_callback(*uart_text_input, result_callback, context, uart_text_input_temp_buffer, uart_text_input_buffer_size, false);
     }
     text_input_show_illegal_symbols(*uart_text_input, true);
     view_dispatcher_add_view(*view_dispatcher, view_id, text_input_get_view(*uart_text_input));
@@ -353,52 +386,63 @@ bool easy_flipper_set_uart_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_dialog_ex(
-    DialogEx** dialog_ex,
+    DialogEx **dialog_ex,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    char* left_button_text,
-    char* right_button_text,
-    char* center_button_text,
-    void (*result_callback)(DialogExResult, void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!dialog_ex) {
+    char *left_button_text,
+    char *right_button_text,
+    char *center_button_text,
+    void (*result_callback)(DialogExResult, void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!dialog_ex)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_dialog_ex");
         return false;
     }
     *dialog_ex = dialog_ex_alloc();
-    if(!*dialog_ex) {
+    if (!*dialog_ex)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate DialogEx");
         return false;
     }
-    if(header) {
+    if (header)
+    {
         dialog_ex_set_header(*dialog_ex, header, header_x, header_y, AlignLeft, AlignTop);
     }
-    if(text) {
+    if (text)
+    {
         dialog_ex_set_text(*dialog_ex, text, text_x, text_y, AlignLeft, AlignTop);
     }
-    if(left_button_text) {
+    if (left_button_text)
+    {
         dialog_ex_set_left_button_text(*dialog_ex, left_button_text);
     }
-    if(right_button_text) {
+    if (right_button_text)
+    {
         dialog_ex_set_right_button_text(*dialog_ex, right_button_text);
     }
-    if(center_button_text) {
+    if (center_button_text)
+    {
         dialog_ex_set_center_button_text(*dialog_ex, center_button_text);
     }
-    if(result_callback) {
+    if (result_callback)
+    {
         dialog_ex_set_result_callback(*dialog_ex, result_callback);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(dialog_ex_get_view(*dialog_ex), previous_callback);
     }
-    if(context) {
+    if (context)
+    {
         dialog_ex_set_context(*dialog_ex, context);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, dialog_ex_get_view(*dialog_ex));
@@ -422,40 +466,48 @@ bool easy_flipper_set_dialog_ex(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_popup(
-    Popup** popup,
+    Popup **popup,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context) {
-    if(!popup) {
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context)
+{
+    if (!popup)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_popup");
         return false;
     }
     *popup = popup_alloc();
-    if(!*popup) {
+    if (!*popup)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Popup");
         return false;
     }
-    if(header) {
+    if (header)
+    {
         popup_set_header(*popup, header, header_x, header_y, AlignLeft, AlignTop);
     }
-    if(text) {
+    if (text)
+    {
         popup_set_text(*popup, text, text_x, text_y, AlignLeft, AlignTop);
     }
-    if(result_callback) {
+    if (result_callback)
+    {
         popup_set_callback(*popup, result_callback);
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(popup_get_view(*popup), previous_callback);
     }
-    if(context) {
+    if (context)
+    {
         popup_set_context(*popup, context);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, popup_get_view(*popup));
@@ -471,20 +523,24 @@ bool easy_flipper_set_popup(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_loading(
-    Loading** loading,
+    Loading **loading,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher) {
-    if(!loading) {
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!loading)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_loading");
         return false;
     }
     *loading = loading_alloc();
-    if(!*loading) {
+    if (!*loading)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate Loading");
         return false;
     }
-    if(previous_callback) {
+    if (previous_callback)
+    {
         view_set_previous_callback(loading_get_view(*loading), previous_callback);
     }
     view_dispatcher_add_view(*view_dispatcher, view_id, loading_get_view(*loading));
@@ -497,16 +553,19 @@ bool easy_flipper_set_loading(
  * @param buffer The buffer to copy the string to
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_char_to_furi_string(FuriString** furi_string, char* buffer) {
-    if(!furi_string) {
+bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer)
+{
+    if (!furi_string)
+    {
         FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_buffer_to_furi_string");
         return false;
     }
     *furi_string = furi_string_alloc();
-    if(!furi_string) {
+    if (!furi_string)
+    {
         FURI_LOG_E(EASY_TAG, "Failed to allocate FuriString");
         return false;
     }
     furi_string_set_str(*furi_string, buffer);
     return true;
-}
+}

+ 61 - 61
web_crawler/easy_flipper/easy_flipper.h

@@ -30,14 +30,14 @@
  * @param context The context - unused
  * @return next view id (VIEW_NONE to exit the app)
  */
-uint32_t easy_flipper_callback_exit_app(void* context);
+uint32_t easy_flipper_callback_exit_app(void *context);
 /**
  * @brief Initialize a buffer
  * @param buffer The buffer to initialize
  * @param buffer_size The size of the buffer
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size);
+bool easy_flipper_set_buffer(char **buffer, uint32_t buffer_size);
 /**
  * @brief Initialize a View object
  * @param view The View object to initialize
@@ -49,13 +49,13 @@ bool easy_flipper_set_buffer(char** buffer, uint32_t buffer_size);
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_view(
-    View** view,
+    View **view,
     int32_t view_id,
-    void draw_callback(Canvas*, void*),
-    bool input_callback(InputEvent*, void*),
-    uint32_t (*previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void draw_callback(Canvas *, void *),
+    bool input_callback(InputEvent *, void *),
+    uint32_t (*previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a ViewDispatcher object
@@ -64,7 +64,7 @@ bool easy_flipper_set_view(
  * @param context The context to pass to the event callback
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui, void* context);
+bool easy_flipper_set_view_dispatcher(ViewDispatcher **view_dispatcher, Gui *gui, void *context);
 
 /**
  * @brief Initialize a Submenu object
@@ -77,11 +77,11 @@ bool easy_flipper_set_view_dispatcher(ViewDispatcher** view_dispatcher, Gui* gui
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_submenu(
-    Submenu** submenu,
+    Submenu **submenu,
     int32_t view_id,
-    char* title,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    char *title,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a Menu object
@@ -94,10 +94,10 @@ bool easy_flipper_set_submenu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_menu(
-    Menu** menu,
+    Menu **menu,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a Widget object
@@ -109,11 +109,11 @@ bool easy_flipper_set_menu(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_widget(
-    Widget** widget,
+    Widget **widget,
     int32_t view_id,
-    char* text,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    char *text,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Initialize a VariableItemList object
@@ -127,12 +127,12 @@ bool easy_flipper_set_widget(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_variable_item_list(
-    VariableItemList** variable_item_list,
+    VariableItemList **variable_item_list,
     int32_t view_id,
-    void (*enter_callback)(void*, uint32_t),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*enter_callback)(void *, uint32_t),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a TextInput object
@@ -143,15 +143,15 @@ bool easy_flipper_set_variable_item_list(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_text_input(
-    TextInput** text_input,
+    TextInput **text_input,
     int32_t view_id,
-    char* header_text,
-    char* text_input_temp_buffer,
+    char *header_text,
+    char *text_input_temp_buffer,
     uint32_t text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a TextInput object with extra symbols
@@ -162,15 +162,15 @@ bool easy_flipper_set_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_uart_text_input(
-    TextInput** uart_text_input,
+    TextInput **uart_text_input,
     int32_t view_id,
-    char* header_text,
-    char* uart_text_input_temp_buffer,
+    char *header_text,
+    char *uart_text_input_temp_buffer,
     uint32_t uart_text_input_buffer_size,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a DialogEx object
@@ -192,21 +192,21 @@ bool easy_flipper_set_uart_text_input(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_dialog_ex(
-    DialogEx** dialog_ex,
+    DialogEx **dialog_ex,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    char* left_button_text,
-    char* right_button_text,
-    char* center_button_text,
-    void (*result_callback)(DialogExResult, void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    char *left_button_text,
+    char *right_button_text,
+    char *center_button_text,
+    void (*result_callback)(DialogExResult, void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a Popup object
@@ -225,18 +225,18 @@ bool easy_flipper_set_dialog_ex(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_popup(
-    Popup** popup,
+    Popup **popup,
     int32_t view_id,
-    char* header,
+    char *header,
     uint16_t header_x,
     uint16_t header_y,
-    char* text,
+    char *text,
     uint16_t text_x,
     uint16_t text_y,
-    void (*result_callback)(void*),
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher,
-    void* context);
+    void (*result_callback)(void *),
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher,
+    void *context);
 
 /**
  * @brief Initialize a Loading object
@@ -247,10 +247,10 @@ bool easy_flipper_set_popup(
  * @return true if successful, false otherwise
  */
 bool easy_flipper_set_loading(
-    Loading** loading,
+    Loading **loading,
     int32_t view_id,
-    uint32_t(previous_callback)(void*),
-    ViewDispatcher** view_dispatcher);
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
 
 /**
  * @brief Set a char butter to a FuriString
@@ -258,6 +258,6 @@ bool easy_flipper_set_loading(
  * @param buffer The buffer to copy the string to
  * @return true if successful, false otherwise
  */
-bool easy_flipper_set_char_to_furi_string(FuriString** furi_string, char* buffer);
+bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer);
 
-#endif
+#endif

+ 127 - 98
web_crawler/flip_storage/web_crawler_storage.c

@@ -2,88 +2,98 @@
 
 // Function to save settings: path, SSID, and password
 void save_settings(
-    const char* path,
-    const char* ssid,
-    const char* password,
-    const char* file_rename,
-    const char* file_type,
-    const char* http_method,
-    const char* headers,
-    const char* payload) {
+    const char *path,
+    const char *ssid,
+    const char *password,
+    const char *file_rename,
+    const char *file_type,
+    const char *http_method,
+    const char *headers,
+    const char *payload)
+{
     // Create the directory for saving settings
     char directory_path[256];
-    snprintf(
-        directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler");
+    snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler");
 
     // Create the directory
-    Storage* storage = furi_record_open(RECORD_STORAGE);
+    Storage *storage = furi_record_open(RECORD_STORAGE);
     storage_common_mkdir(storage, directory_path);
 
     // Open the settings file
-    File* file = storage_file_alloc(storage);
-    if(!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
+    File *file = storage_file_alloc(storage);
+    if (!storage_file_open(file, SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS))
+    {
         FURI_LOG_E(TAG, "Failed to open settings file for writing: %s", SETTINGS_PATH);
         storage_file_free(file);
         furi_record_close(RECORD_STORAGE);
         return;
     }
 
-    if(file_type == NULL || strlen(file_type) == 0) {
+    if (file_type == NULL || strlen(file_type) == 0)
+    {
         file_type = ".txt";
     }
 
     // Save the SSID length and data
     size_t ssid_length = strlen(ssid) + 1; // Include null terminator
-    if(storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, ssid, ssid_length) != ssid_length) {
+    if (storage_file_write(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, ssid, ssid_length) != ssid_length)
+    {
         FURI_LOG_E(TAG, "Failed to write SSID");
     }
 
     // Save the password length and data
     size_t password_length = strlen(password) + 1; // Include null terminator
-    if(storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, password, password_length) != password_length) {
+    if (storage_file_write(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, password, password_length) != password_length)
+    {
         FURI_LOG_E(TAG, "Failed to write password");
     }
 
     // Save the path length and data
     size_t path_length = strlen(path) + 1; // Include null terminator
-    if(storage_file_write(file, &path_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, path, path_length) != path_length) {
+    if (storage_file_write(file, &path_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, path, path_length) != path_length)
+    {
         FURI_LOG_E(TAG, "Failed to write path");
     }
     // Save the file rename length and data
     size_t file_rename_length = strlen(file_rename) + 1; // Include null terminator
-    if(storage_file_write(file, &file_rename_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, file_rename, file_rename_length) != file_rename_length) {
+    if (storage_file_write(file, &file_rename_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, file_rename, file_rename_length) != file_rename_length)
+    {
         FURI_LOG_E(TAG, "Failed to write file rename");
     }
 
     // Save the file type length and data
     size_t file_type_length = strlen(file_type) + 1; // Include null terminator
-    if(storage_file_write(file, &file_type_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, file_type, file_type_length) != file_type_length) {
+    if (storage_file_write(file, &file_type_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, file_type, file_type_length) != file_type_length)
+    {
         FURI_LOG_E(TAG, "Failed to write file type");
     }
 
     // Save the http method length and data
     size_t http_method_length = strlen(http_method) + 1; // Include null terminator
-    if(storage_file_write(file, &http_method_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, http_method, http_method_length) != http_method_length) {
+    if (storage_file_write(file, &http_method_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, http_method, http_method_length) != http_method_length)
+    {
         FURI_LOG_E(TAG, "Failed to write http method");
     }
 
     // Save the headers length and data
     size_t headers_length = strlen(headers) + 1; // Include null terminator
-    if(storage_file_write(file, &headers_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, headers, headers_length) != headers_length) {
+    if (storage_file_write(file, &headers_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, headers, headers_length) != headers_length)
+    {
         FURI_LOG_E(TAG, "Failed to write headers");
     }
 
     // Save the payload length and data
     size_t payload_length = strlen(payload) + 1; // Include null terminator
-    if(storage_file_write(file, &payload_length, sizeof(size_t)) != sizeof(size_t) ||
-       storage_file_write(file, payload, payload_length) != payload_length) {
+    if (storage_file_write(file, &payload_length, sizeof(size_t)) != sizeof(size_t) ||
+        storage_file_write(file, payload, payload_length) != payload_length)
+    {
         FURI_LOG_E(TAG, "Failed to write payload");
     }
 
@@ -94,31 +104,34 @@ void save_settings(
 
 // Function to load settings (the variables must be opened in the order they were saved)
 bool load_settings(
-    char* path,
+    char *path,
     size_t path_size,
-    char* ssid,
+    char *ssid,
     size_t ssid_size,
-    char* password,
+    char *password,
     size_t password_size,
-    char* file_rename,
+    char *file_rename,
     size_t file_rename_size,
-    char* file_type,
+    char *file_type,
     size_t file_type_size,
-    char* http_method,
+    char *http_method,
     size_t http_method_size,
-    char* headers,
+    char *headers,
     size_t headers_size,
-    char* payload,
+    char *payload,
     size_t payload_size,
-    WebCrawlerApp* app) {
-    if(!app) {
+    WebCrawlerApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "WebCrawlerApp is NULL");
         return false;
     }
-    Storage* storage = furi_record_open(RECORD_STORAGE);
-    File* file = storage_file_alloc(storage);
+    Storage *storage = furi_record_open(RECORD_STORAGE);
+    File *file = storage_file_alloc(storage);
 
-    if(!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
+    if (!storage_file_open(file, SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING))
+    {
         FURI_LOG_E(TAG, "Failed to open settings file for reading: %s", SETTINGS_PATH);
         storage_file_free(file);
         furi_record_close(RECORD_STORAGE);
@@ -127,8 +140,9 @@ bool load_settings(
 
     // Load the SSID
     size_t ssid_length;
-    if(storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) ||
-       ssid_length > ssid_size || storage_file_read(file, ssid, ssid_length) != ssid_length) {
+    if (storage_file_read(file, &ssid_length, sizeof(size_t)) != sizeof(size_t) || ssid_length > ssid_size ||
+        storage_file_read(file, ssid, ssid_length) != ssid_length)
+    {
         FURI_LOG_E(TAG, "Failed to read SSID");
         storage_file_close(file);
         storage_file_free(file);
@@ -139,9 +153,9 @@ bool load_settings(
 
     // Load the password
     size_t password_length;
-    if(storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) ||
-       password_length > password_size ||
-       storage_file_read(file, password, password_length) != password_length) {
+    if (storage_file_read(file, &password_length, sizeof(size_t)) != sizeof(size_t) || password_length > password_size ||
+        storage_file_read(file, password, password_length) != password_length)
+    {
         FURI_LOG_E(TAG, "Failed to read password");
         storage_file_close(file);
         storage_file_free(file);
@@ -152,8 +166,9 @@ bool load_settings(
 
     // Load the path
     size_t path_length;
-    if(storage_file_read(file, &path_length, sizeof(size_t)) != sizeof(size_t) ||
-       path_length > path_size || storage_file_read(file, path, path_length) != path_length) {
+    if (storage_file_read(file, &path_length, sizeof(size_t)) != sizeof(size_t) || path_length > path_size ||
+        storage_file_read(file, path, path_length) != path_length)
+    {
         FURI_LOG_E(TAG, "Failed to read path");
         storage_file_close(file);
         storage_file_free(file);
@@ -164,9 +179,9 @@ bool load_settings(
 
     // Load the file rename
     size_t file_rename_length;
-    if(storage_file_read(file, &file_rename_length, sizeof(size_t)) != sizeof(size_t) ||
-       file_rename_length > file_rename_size ||
-       storage_file_read(file, file_rename, file_rename_length) != file_rename_length) {
+    if (storage_file_read(file, &file_rename_length, sizeof(size_t)) != sizeof(size_t) || file_rename_length > file_rename_size ||
+        storage_file_read(file, file_rename, file_rename_length) != file_rename_length)
+    {
         FURI_LOG_E(TAG, "Failed to read file rename");
         storage_file_close(file);
         storage_file_free(file);
@@ -177,9 +192,9 @@ bool load_settings(
 
     // Load the file type
     size_t file_type_length;
-    if(storage_file_read(file, &file_type_length, sizeof(size_t)) != sizeof(size_t) ||
-       file_type_length > file_type_size ||
-       storage_file_read(file, file_type, file_type_length) != file_type_length) {
+    if (storage_file_read(file, &file_type_length, sizeof(size_t)) != sizeof(size_t) || file_type_length > file_type_size ||
+        storage_file_read(file, file_type, file_type_length) != file_type_length)
+    {
         FURI_LOG_E(TAG, "Failed to read file type");
         storage_file_close(file);
         storage_file_free(file);
@@ -190,9 +205,9 @@ bool load_settings(
 
     // Load the http method
     size_t http_method_length;
-    if(storage_file_read(file, &http_method_length, sizeof(size_t)) != sizeof(size_t) ||
-       http_method_length > http_method_size ||
-       storage_file_read(file, http_method, http_method_length) != http_method_length) {
+    if (storage_file_read(file, &http_method_length, sizeof(size_t)) != sizeof(size_t) || http_method_length > http_method_size ||
+        storage_file_read(file, http_method, http_method_length) != http_method_length)
+    {
         FURI_LOG_E(TAG, "Failed to read http method");
         storage_file_close(file);
         storage_file_free(file);
@@ -202,9 +217,9 @@ bool load_settings(
 
     // Load the headers
     size_t headers_length;
-    if(storage_file_read(file, &headers_length, sizeof(size_t)) != sizeof(size_t) ||
-       headers_length > headers_size ||
-       storage_file_read(file, headers, headers_length) != headers_length) {
+    if (storage_file_read(file, &headers_length, sizeof(size_t)) != sizeof(size_t) || headers_length > headers_size ||
+        storage_file_read(file, headers, headers_length) != headers_length)
+    {
         FURI_LOG_E(TAG, "Failed to read headers");
         storage_file_close(file);
         storage_file_free(file);
@@ -214,9 +229,9 @@ bool load_settings(
 
     // Load the payload
     size_t payload_length;
-    if(storage_file_read(file, &payload_length, sizeof(size_t)) != sizeof(size_t) ||
-       payload_length > payload_size ||
-       storage_file_read(file, payload, payload_length) != payload_length) {
+    if (storage_file_read(file, &payload_length, sizeof(size_t)) != sizeof(size_t) || payload_length > payload_size ||
+        storage_file_read(file, payload, payload_length) != payload_length)
+    {
         FURI_LOG_E(TAG, "Failed to read payload");
         storage_file_close(file);
         storage_file_free(file);
@@ -240,46 +255,53 @@ bool load_settings(
     return true;
 }
 
-bool delete_received_data(WebCrawlerApp* app) {
-    if(app == NULL) {
+bool delete_received_data(WebCrawlerApp *app)
+{
+    if (app == NULL)
+    {
         FURI_LOG_E(TAG, "WebCrawlerApp is NULL");
         return false;
     }
     // Open the storage record
-    Storage* storage = furi_record_open(RECORD_STORAGE);
-    if(!storage) {
+    Storage *storage = furi_record_open(RECORD_STORAGE);
+    if (!storage)
+    {
         FURI_LOG_E(TAG, "Failed to open storage record");
         return false;
     }
 
-    if(!storage_simply_remove_recursive(storage, RECEIVED_DATA_PATH "received_data.txt")) {
+    if (!storage_simply_remove_recursive(storage, RECEIVED_DATA_PATH "received_data.txt"))
+    {
         FURI_LOG_E(TAG, "Failed to delete main file");
         furi_record_close(RECORD_STORAGE);
         return false;
     }
 
     // Allocate memory for new_path
-    char* new_path = malloc(256);
-    if(new_path == NULL) {
+    char *new_path = malloc(256);
+    if (new_path == NULL)
+    {
         FURI_LOG_E(TAG, "Memory allocation failed for paths");
         free(new_path);
         return false;
     }
 
-    if(app->file_type == NULL || strlen(app->file_type) == 0) {
+    if (app->file_type == NULL || strlen(app->file_type) == 0)
+    {
         app->file_type = ".txt";
     }
 
     // Format the new_path
-    int ret_new =
-        snprintf(new_path, 256, "%s%s%s", RECEIVED_DATA_PATH, app->file_rename, app->file_type);
-    if(ret_new < 0 || (size_t)ret_new >= 256) {
+    int ret_new = snprintf(new_path, 256, "%s%s%s", RECEIVED_DATA_PATH, app->file_rename, app->file_type);
+    if (ret_new < 0 || (size_t)ret_new >= 256)
+    {
         FURI_LOG_E(TAG, "Failed to create new_path");
         free(new_path);
         return false;
     }
 
-    if(!storage_simply_remove_recursive(storage, new_path)) {
+    if (!storage_simply_remove_recursive(storage, new_path))
+    {
         FURI_LOG_E(TAG, "Failed to delete duplicate file");
         furi_record_close(RECORD_STORAGE);
         return false;
@@ -290,37 +312,39 @@ bool delete_received_data(WebCrawlerApp* app) {
     return true;
 }
 
-bool rename_received_data(
-    const char* old_name,
-    const char* new_name,
-    const char* file_type,
-    const char* old_file_type) {
+bool rename_received_data(const char *old_name, const char *new_name, const char *file_type, const char *old_file_type)
+{
     // Open the storage record
-    Storage* storage = furi_record_open(RECORD_STORAGE);
-    if(!storage) {
+    Storage *storage = furi_record_open(RECORD_STORAGE);
+    if (!storage)
+    {
         FURI_LOG_E(TAG, "Failed to open storage record");
         return false;
     }
     // Allocate memory for old_path and new_path
-    char* new_path = malloc(256);
-    char* old_path = malloc(256);
-    if(new_path == NULL || old_path == NULL) {
+    char *new_path = malloc(256);
+    char *old_path = malloc(256);
+    if (new_path == NULL || old_path == NULL)
+    {
         FURI_LOG_E(TAG, "Memory allocation failed for paths");
         free(old_path);
         free(new_path);
         return false;
     }
 
-    if(file_type == NULL || strlen(file_type) == 0) {
+    if (file_type == NULL || strlen(file_type) == 0)
+    {
         file_type = ".txt";
     }
-    if(old_file_type == NULL || strlen(old_file_type) == 0) {
+    if (old_file_type == NULL || strlen(old_file_type) == 0)
+    {
         old_file_type = ".txt";
     }
 
     // Format the old_path
     int ret_old = snprintf(old_path, 256, "%s%s%s", RECEIVED_DATA_PATH, old_name, old_file_type);
-    if(ret_old < 0 || (size_t)ret_old >= 256) {
+    if (ret_old < 0 || (size_t)ret_old >= 256)
+    {
         FURI_LOG_E(TAG, "Failed to create old_path");
         free(old_path);
         free(new_path);
@@ -329,7 +353,8 @@ bool rename_received_data(
 
     // Format the new_path
     int ret_new = snprintf(new_path, 256, "%s%s%s", RECEIVED_DATA_PATH, new_name, file_type);
-    if(ret_new < 0 || (size_t)ret_new >= 256) {
+    if (ret_new < 0 || (size_t)ret_new >= 256)
+    {
         FURI_LOG_E(TAG, "Failed to create new_path");
         free(old_path);
         free(new_path);
@@ -337,22 +362,26 @@ bool rename_received_data(
     }
 
     // Check if the file exists
-    if(!storage_file_exists(storage, old_path)) {
-        if(!storage_file_exists(storage, RECEIVED_DATA_PATH "received_data.txt")) {
+    if (!storage_file_exists(storage, old_path))
+    {
+        if (!storage_file_exists(storage, RECEIVED_DATA_PATH "received_data.txt"))
+        {
             FURI_LOG_E(TAG, "No saved file exists");
             free(old_path);
             free(new_path);
             furi_record_close(RECORD_STORAGE);
             return false;
-        } else {
-            bool renamed =
-                storage_common_copy(storage, RECEIVED_DATA_PATH "received_data.txt", new_path) ==
-                FSE_OK;
+        }
+        else
+        {
+            bool renamed = storage_common_copy(storage, RECEIVED_DATA_PATH "received_data.txt", new_path) == FSE_OK;
 
             furi_record_close(RECORD_STORAGE);
             return renamed;
         }
-    } else {
+    }
+    else
+    {
         bool renamed = storage_common_rename(storage, old_path, new_path) == FSE_OK;
         storage_simply_remove_recursive(storage, old_path);
         furi_record_close(RECORD_STORAGE);

+ 21 - 27
web_crawler/flip_storage/web_crawler_storage.h

@@ -5,45 +5,39 @@
 #include <storage/storage.h>
 
 #define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/" http_tag "/settings.bin"
-#define RECEIVED_DATA_PATH                         \
-    STORAGE_EXT_PATH_PREFIX "/apps_data/" http_tag \
-                            "/" // add the file name to the end (e.g. "received_data.txt")
+#define RECEIVED_DATA_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/" http_tag "/" // add the file name to the end (e.g. "received_data.txt")
 
 // Function to save settings: path, SSID, and password
 void save_settings(
-    const char* path,
-    const char* ssid,
-    const char* password,
-    const char* file_rename,
-    const char* file_type,
-    const char* http_method,
-    const char* headers,
-    const char* payload);
+    const char *path,
+    const char *ssid,
+    const char *password,
+    const char *file_rename,
+    const char *file_type,
+    const char *http_method,
+    const char *headers,
+    const char *payload);
 
 // Function to load settings (the variables must be opened in the order they were saved)
 bool load_settings(
-    char* path,
+    char *path,
     size_t path_size,
-    char* ssid,
+    char *ssid,
     size_t ssid_size,
-    char* password,
+    char *password,
     size_t password_size,
-    char* file_rename,
+    char *file_rename,
     size_t file_rename_size,
-    char* file_type,
+    char *file_type,
     size_t file_type_size,
-    char* http_method,
+    char *http_method,
     size_t http_method_size,
-    char* headers,
+    char *headers,
     size_t headers_size,
-    char* payload,
+    char *payload,
     size_t payload_size,
-    WebCrawlerApp* app);
+    WebCrawlerApp *app);
 
-bool delete_received_data(WebCrawlerApp* app);
-bool rename_received_data(
-    const char* old_name,
-    const char* new_name,
-    const char* file_type,
-    const char* old_file_type);
-#endif // WEB_CRAWLER_STORAGE_H
+bool delete_received_data(WebCrawlerApp *app);
+bool rename_received_data(const char *old_name, const char *new_name, const char *file_type, const char *old_file_type);
+#endif // WEB_CRAWLER_STORAGE_H

File diff suppressed because it is too large
+ 291 - 165
web_crawler/flipper_http/flipper_http.c


+ 62 - 59
web_crawler/flipper_http/flipper_http.h

@@ -11,69 +11,72 @@
 
 // STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext
 
-#define HTTP_TAG               "Web Crawler" // change this to your app name
-#define http_tag               "web_crawler" // change this to your app id
-#define UART_CH                (momentum_settings.uart_esp_channel) // UART channel
+#define HTTP_TAG "Web Crawler"            // change this to your app name
+#define http_tag "web_crawler"            // change this to your app id
+#define UART_CH (momentum_settings.uart_esp_channel)    // UART channel
 #define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds
-#define BAUDRATE               (115200) // UART baudrate
-#define RX_BUF_SIZE            2048 // UART RX buffer size
-#define RX_LINE_BUFFER_SIZE    2048 // UART RX line buffer size (increase for large responses)
-#define MAX_FILE_SHOW          4096 // Maximum data from file to show
-#define FILE_BUFFER_SIZE       512 // File buffer size
+#define BAUDRATE (115200)                 // UART baudrate
+#define RX_BUF_SIZE 2048                  // UART RX buffer size
+#define RX_LINE_BUFFER_SIZE 2048          // UART RX line buffer size (increase for large responses)
+#define MAX_FILE_SHOW 4096                // Maximum data from file to show
+#define FILE_BUFFER_SIZE 512              // File buffer size
 
 // Forward declaration for callback
-typedef void (*FlipperHTTP_Callback)(const char* line, void* context);
+typedef void (*FlipperHTTP_Callback)(const char *line, void *context);
 
 // State variable to track the UART state
-typedef enum {
-    INACTIVE, // Inactive state
-    IDLE, // Default state
+typedef enum
+{
+    INACTIVE,  // Inactive state
+    IDLE,      // Default state
     RECEIVING, // Receiving data
-    SENDING, // Sending data
-    ISSUE, // Issue with connection
+    SENDING,   // Sending data
+    ISSUE,     // Issue with connection
 } SerialState;
 
 // Event Flags for UART Worker Thread
-typedef enum {
+typedef enum
+{
     WorkerEvtStop = (1 << 0),
     WorkerEvtRxDone = (1 << 1),
 } WorkerEvtFlags;
 
 // FlipperHTTP Structure
-typedef struct {
-    FuriStreamBuffer* flipper_http_stream; // Stream buffer for UART communication
-    FuriHalSerialHandle* serial_handle; // Serial handle for UART communication
-    FuriThread* rx_thread; // Worker thread for UART
-    FuriThreadId rx_thread_id; // Worker thread ID
+typedef struct
+{
+    FuriStreamBuffer *flipper_http_stream;  // Stream buffer for UART communication
+    FuriHalSerialHandle *serial_handle;     // Serial handle for UART communication
+    FuriThread *rx_thread;                  // Worker thread for UART
+    FuriThreadId rx_thread_id;              // Worker thread ID
     FlipperHTTP_Callback handle_rx_line_cb; // Callback for received lines
-    void* callback_context; // Context for the callback
-    SerialState state; // State of the UART
+    void *callback_context;                 // Context for the callback
+    SerialState state;                      // State of the UART
 
     // variable to store the last received data from the UART
-    char* last_response;
+    char *last_response;
     char file_path[256]; // Path to save the received data
 
     // Timer-related members
-    FuriTimer* get_timeout_timer; // Timer for HTTP request timeout
+    FuriTimer *get_timeout_timer; // Timer for HTTP request timeout
 
     bool started_receiving_get; // Indicates if a GET request has started
-    bool just_started_get; // Indicates if GET data reception has just started
+    bool just_started_get;      // Indicates if GET data reception has just started
 
     bool started_receiving_post; // Indicates if a POST request has started
-    bool just_started_post; // Indicates if POST data reception has just started
+    bool just_started_post;      // Indicates if POST data reception has just started
 
     bool started_receiving_put; // Indicates if a PUT request has started
-    bool just_started_put; // Indicates if PUT data reception has just started
+    bool just_started_put;      // Indicates if PUT data reception has just started
 
     bool started_receiving_delete; // Indicates if a DELETE request has started
-    bool just_started_delete; // Indicates if DELETE data reception has just started
+    bool just_started_delete;      // Indicates if DELETE data reception has just started
 
     // Buffer to hold the raw bytes received from the UART
-    uint8_t* received_bytes;
+    uint8_t *received_bytes;
     size_t received_bytes_len; // Length of the received bytes
-    bool is_bytes_request; // Flag to indicate if the request is for bytes
-    bool save_bytes; // Flag to save the received data to a file
-    bool save_received_data; // Flag to save the received data to a file
+    bool is_bytes_request;     // Flag to indicate if the request is for bytes
+    bool save_bytes;           // Flag to save the received data to a file
+    bool save_received_data;   // Flag to save the received data to a file
 
     bool just_started_bytes; // Indicates if bytes data reception has just started
 } FlipperHTTP;
@@ -89,12 +92,12 @@ extern size_t file_buffer_len;
 // Function to append received data to file
 // make sure to initialize the file path before calling this function
 bool flipper_http_append_to_file(
-    const void* data,
+    const void *data,
     size_t data_size,
     bool start_new_file,
-    char* file_path);
+    char *file_path);
 
-FuriString* flipper_http_load_from_file(char* file_path);
+FuriString *flipper_http_load_from_file(char *file_path);
 
 // UART worker thread
 /**
@@ -104,7 +107,7 @@ FuriString* flipper_http_load_from_file(char* file_path);
  * @note       This function will handle received data asynchronously via the callback.
  */
 // UART worker thread
-int32_t flipper_http_worker(void* context);
+int32_t flipper_http_worker(void *context);
 
 // Timer callback function
 /**
@@ -113,7 +116,7 @@ int32_t flipper_http_worker(void* context);
  * @param      context   The context to pass to the callback.
  * @note       This function will be called when the GET request times out.
  */
-void get_timeout_timer_callback(void* context);
+void get_timeout_timer_callback(void *context);
 
 // UART RX Handler Callback (Interrupt Context)
 /**
@@ -125,9 +128,9 @@ void get_timeout_timer_callback(void* context);
  * @note       This function will handle received data asynchronously via the callback.
  */
 void _flipper_http_rx_callback(
-    FuriHalSerialHandle* handle,
+    FuriHalSerialHandle *handle,
     FuriHalSerialRxEvent event,
-    void* context);
+    void *context);
 
 // UART initialization function
 /**
@@ -137,7 +140,7 @@ void _flipper_http_rx_callback(
  * @param      context   The context to pass to the callback.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_init(FlipperHTTP_Callback callback, void* context);
+bool flipper_http_init(FlipperHTTP_Callback callback, void *context);
 
 // Deinitialize UART
 /**
@@ -154,7 +157,7 @@ void flipper_http_deinit();
  * @param      data  The data to send over UART.
  * @note       The data will be sent over UART with a newline character appended.
  */
-bool flipper_http_send_data(const char* data);
+bool flipper_http_send_data(const char *data);
 
 // Function to send a PING request
 /**
@@ -198,7 +201,7 @@ bool flipper_http_led_off();
  * @param      json_data The JSON data to parse.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_parse_json(const char* key, const char* json_data);
+bool flipper_http_parse_json(const char *key, const char *json_data);
 
 // Function to parse JSON array data
 /**
@@ -209,7 +212,7 @@ bool flipper_http_parse_json(const char* key, const char* json_data);
  * @param      json_data The JSON array data to parse.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_parse_json_array(const char* key, int index, const char* json_data);
+bool flipper_http_parse_json_array(const char *key, int index, const char *json_data);
 
 // Function to scan for WiFi networks
 /**
@@ -225,7 +228,7 @@ bool flipper_http_scan_wifi();
  * @return     true if the request was successful, false otherwise.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_save_wifi(const char* ssid, const char* password);
+bool flipper_http_save_wifi(const char *ssid, const char *password);
 
 // Function to get IP address of WiFi Devboard
 /**
@@ -266,7 +269,7 @@ bool flipper_http_connect_wifi();
  * @param      url  The URL to send the GET request to.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request(const char* url);
+bool flipper_http_get_request(const char *url);
 
 // Function to send a GET request with headers
 /**
@@ -276,7 +279,7 @@ bool flipper_http_get_request(const char* url);
  * @param      headers  The headers to send with the GET request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request_with_headers(const char* url, const char* headers);
+bool flipper_http_get_request_with_headers(const char *url, const char *headers);
 
 // Function to send a GET request with headers and return bytes
 /**
@@ -286,7 +289,7 @@ bool flipper_http_get_request_with_headers(const char* url, const char* headers)
  * @param      headers  The headers to send with the GET request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_get_request_bytes(const char* url, const char* headers);
+bool flipper_http_get_request_bytes(const char *url, const char *headers);
 
 // Function to send a POST request with headers
 /**
@@ -298,9 +301,9 @@ bool flipper_http_get_request_bytes(const char* url, const char* headers);
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_post_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to send a POST request with headers and return bytes
 /**
@@ -311,7 +314,7 @@ bool flipper_http_post_request_with_headers(
  * @param      payload  The data to send with the POST request.
  * @note       The received data will be handled asynchronously via the callback.
  */
-bool flipper_http_post_request_bytes(const char* url, const char* headers, const char* payload);
+bool flipper_http_post_request_bytes(const char *url, const char *headers, const char *payload);
 
 // Function to send a PUT request with headers
 /**
@@ -323,9 +326,9 @@ bool flipper_http_post_request_bytes(const char* url, const char* headers, const
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_put_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to send a DELETE request with headers
 /**
@@ -337,9 +340,9 @@ bool flipper_http_put_request_with_headers(
  * @note       The received data will be handled asynchronously via the callback.
  */
 bool flipper_http_delete_request_with_headers(
-    const char* url,
-    const char* headers,
-    const char* payload);
+    const char *url,
+    const char *headers,
+    const char *payload);
 
 // Function to handle received data asynchronously
 /**
@@ -349,10 +352,10 @@ bool flipper_http_delete_request_with_headers(
  * @param      context  The context passed to the callback.
  * @note       The received data will be handled asynchronously via the callback and handles the state of the UART.
  */
-void flipper_http_rx_callback(const char* line, void* context);
+void flipper_http_rx_callback(const char *line, void *context);
 
 // Function to trim leading and trailing spaces and newlines from a constant string
-char* trim(const char* str);
+char *trim(const char *str);
 /**
  * @brief Process requests and parse JSON data asynchronously
  * @param http_request The function to send the request

+ 217 - 136
web_crawler/jsmn/jsmn.c

@@ -13,11 +13,13 @@
 /**
  * Allocates a fresh unused token from the token pool.
  */
-static jsmntok_t*
-    jsmn_alloc_token(jsmn_parser* parser, jsmntok_t* tokens, const size_t num_tokens) {
-    jsmntok_t* tok;
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
+                                   const size_t num_tokens)
+{
+    jsmntok_t *tok;
 
-    if(parser->toknext >= num_tokens) {
+    if (parser->toknext >= num_tokens)
+    {
         return NULL;
     }
     tok = &tokens[parser->toknext++];
@@ -32,8 +34,9 @@ static jsmntok_t*
 /**
  * Fills token type and boundaries.
  */
-static void
-    jsmn_fill_token(jsmntok_t* token, const jsmntype_t type, const int start, const int end) {
+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
+                            const int start, const int end)
+{
     token->type = type;
     token->start = start;
     token->end = end;
@@ -43,19 +46,19 @@ static void
 /**
  * Fills next available token with JSON primitive.
  */
-static int jsmn_parse_primitive(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+                                const size_t len, jsmntok_t *tokens,
+                                const size_t num_tokens)
+{
+    jsmntok_t *token;
     int start;
 
     start = parser->pos;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-        switch(js[parser->pos]) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
+        switch (js[parser->pos])
+        {
 #ifndef JSMN_STRICT
         /* In strict mode primitive must be followed by "," or "}" or "]" */
         case ':':
@@ -72,7 +75,8 @@ static int jsmn_parse_primitive(
             /* to quiet a warning from gcc*/
             break;
         }
-        if(js[parser->pos] < 32 || js[parser->pos] >= 127) {
+        if (js[parser->pos] < 32 || js[parser->pos] >= 127)
+        {
             parser->pos = start;
             return JSMN_ERROR_INVAL;
         }
@@ -84,12 +88,14 @@ static int jsmn_parse_primitive(
 #endif
 
 found:
-    if(tokens == NULL) {
+    if (tokens == NULL)
+    {
         parser->pos--;
         return 0;
     }
     token = jsmn_alloc_token(parser, tokens, num_tokens);
-    if(token == NULL) {
+    if (token == NULL)
+    {
         parser->pos = start;
         return JSMN_ERROR_NOMEM;
     }
@@ -104,29 +110,31 @@ found:
 /**
  * Fills next token with JSON string.
  */
-static int jsmn_parse_string(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const size_t num_tokens) {
-    jsmntok_t* token;
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+                             const size_t len, jsmntok_t *tokens,
+                             const size_t num_tokens)
+{
+    jsmntok_t *token;
 
     int start = parser->pos;
 
     /* Skip starting quote */
     parser->pos++;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c = js[parser->pos];
 
         /* Quote: end of string */
-        if(c == '\"') {
-            if(tokens == NULL) {
+        if (c == '\"')
+        {
+            if (tokens == NULL)
+            {
                 return 0;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 parser->pos = start;
                 return JSMN_ERROR_NOMEM;
             }
@@ -138,10 +146,12 @@ static int jsmn_parse_string(
         }
 
         /* Backslash: Quoted symbol expected */
-        if(c == '\\' && parser->pos + 1 < len) {
+        if (c == '\\' && parser->pos + 1 < len)
+        {
             int i;
             parser->pos++;
-            switch(js[parser->pos]) {
+            switch (js[parser->pos])
+            {
             /* Allowed escaped symbols */
             case '\"':
             case '/':
@@ -155,11 +165,13 @@ static int jsmn_parse_string(
             /* Allows escaped symbol \uXXXX */
             case 'u':
                 parser->pos++;
-                for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+                for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++)
+                {
                     /* If it isn't a hex character we have an error */
-                    if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                         (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                         (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+                    if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+                          (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+                          (js[parser->pos] >= 97 && js[parser->pos] <= 102)))
+                    { /* a-f */
                         parser->pos = start;
                         return JSMN_ERROR_INVAL;
                     }
@@ -181,7 +193,8 @@ static int jsmn_parse_string(
 /**
  * Create JSON parser over an array of tokens
  */
-void jsmn_init(jsmn_parser* parser) {
+void jsmn_init(jsmn_parser *parser)
+{
     parser->pos = 0;
     parser->toknext = 0;
     parser->toksuper = -1;
@@ -190,38 +203,41 @@ void jsmn_init(jsmn_parser* parser) {
 /**
  * Parse JSON string and fill tokens.
  */
-int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens) {
+int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+               jsmntok_t *tokens, const unsigned int num_tokens)
+{
     int r;
     int i;
-    jsmntok_t* token;
+    jsmntok_t *token;
     int count = parser->toknext;
 
-    for(; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++)
+    {
         char c;
         jsmntype_t type;
 
         c = js[parser->pos];
-        switch(c) {
+        switch (c)
+        {
         case '{':
         case '[':
             count++;
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             token = jsmn_alloc_token(parser, tokens, num_tokens);
-            if(token == NULL) {
+            if (token == NULL)
+            {
                 return JSMN_ERROR_NOMEM;
             }
-            if(parser->toksuper != -1) {
-                jsmntok_t* t = &tokens[parser->toksuper];
+            if (parser->toksuper != -1)
+            {
+                jsmntok_t *t = &tokens[parser->toksuper];
 #ifdef JSMN_STRICT
                 /* In strict mode an object or array can't become a key */
-                if(t->type == JSMN_OBJECT) {
+                if (t->type == JSMN_OBJECT)
+                {
                     return JSMN_ERROR_INVAL;
                 }
 #endif
@@ -236,26 +252,33 @@ int jsmn_parse(
             break;
         case '}':
         case ']':
-            if(tokens == NULL) {
+            if (tokens == NULL)
+            {
                 break;
             }
             type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
 #ifdef JSMN_PARENT_LINKS
-            if(parser->toknext < 1) {
+            if (parser->toknext < 1)
+            {
                 return JSMN_ERROR_INVAL;
             }
             token = &tokens[parser->toknext - 1];
-            for(;;) {
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+            for (;;)
+            {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     token->end = parser->pos + 1;
                     parser->toksuper = token->parent;
                     break;
                 }
-                if(token->parent == -1) {
-                    if(token->type != type || parser->toksuper == -1) {
+                if (token->parent == -1)
+                {
+                    if (token->type != type || parser->toksuper == -1)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     break;
@@ -263,10 +286,13 @@ int jsmn_parse(
                 token = &tokens[token->parent];
             }
 #else
-            for(i = parser->toknext - 1; i >= 0; i--) {
+            for (i = parser->toknext - 1; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
-                    if(token->type != type) {
+                if (token->start != -1 && token->end == -1)
+                {
+                    if (token->type != type)
+                    {
                         return JSMN_ERROR_INVAL;
                     }
                     parser->toksuper = -1;
@@ -275,12 +301,15 @@ int jsmn_parse(
                 }
             }
             /* Error if unmatched closing bracket */
-            if(i == -1) {
+            if (i == -1)
+            {
                 return JSMN_ERROR_INVAL;
             }
-            for(; i >= 0; i--) {
+            for (; i >= 0; i--)
+            {
                 token = &tokens[i];
-                if(token->start != -1 && token->end == -1) {
+                if (token->start != -1 && token->end == -1)
+                {
                     parser->toksuper = i;
                     break;
                 }
@@ -289,11 +318,13 @@ int jsmn_parse(
             break;
         case '\"':
             r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -306,15 +337,19 @@ int jsmn_parse(
             parser->toksuper = parser->toknext - 1;
             break;
         case ',':
-            if(tokens != NULL && parser->toksuper != -1 &&
-               tokens[parser->toksuper].type != JSMN_ARRAY &&
-               tokens[parser->toksuper].type != JSMN_OBJECT) {
+            if (tokens != NULL && parser->toksuper != -1 &&
+                tokens[parser->toksuper].type != JSMN_ARRAY &&
+                tokens[parser->toksuper].type != JSMN_OBJECT)
+            {
 #ifdef JSMN_PARENT_LINKS
                 parser->toksuper = tokens[parser->toksuper].parent;
 #else
-                for(i = parser->toknext - 1; i >= 0; i--) {
-                    if(tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
-                        if(tokens[i].start != -1 && tokens[i].end == -1) {
+                for (i = parser->toknext - 1; i >= 0; i--)
+                {
+                    if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT)
+                    {
+                        if (tokens[i].start != -1 && tokens[i].end == -1)
+                        {
                             parser->toksuper = i;
                             break;
                         }
@@ -340,9 +375,12 @@ int jsmn_parse(
         case 'f':
         case 'n':
             /* And they must not be keys of the object */
-            if(tokens != NULL && parser->toksuper != -1) {
-                const jsmntok_t* t = &tokens[parser->toksuper];
-                if(t->type == JSMN_OBJECT || (t->type == JSMN_STRING && t->size != 0)) {
+            if (tokens != NULL && parser->toksuper != -1)
+            {
+                const jsmntok_t *t = &tokens[parser->toksuper];
+                if (t->type == JSMN_OBJECT ||
+                    (t->type == JSMN_STRING && t->size != 0))
+                {
                     return JSMN_ERROR_INVAL;
                 }
             }
@@ -351,11 +389,13 @@ int jsmn_parse(
         default:
 #endif
             r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-            if(r < 0) {
+            if (r < 0)
+            {
                 return r;
             }
             count++;
-            if(parser->toksuper != -1 && tokens != NULL) {
+            if (parser->toksuper != -1 && tokens != NULL)
+            {
                 tokens[parser->toksuper].size++;
             }
             break;
@@ -368,10 +408,13 @@ int jsmn_parse(
         }
     }
 
-    if(tokens != NULL) {
-        for(i = parser->toknext - 1; i >= 0; i--) {
+    if (tokens != NULL)
+    {
+        for (i = parser->toknext - 1; i >= 0; i--)
+        {
             /* Unmatched opened object or array */
-            if(tokens[i].start != -1 && tokens[i].end == -1) {
+            if (tokens[i].start != -1 && tokens[i].end == -1)
+            {
                 return JSMN_ERROR_PART;
             }
         }
@@ -381,10 +424,12 @@ int jsmn_parse(
 }
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value) {
-    int length = strlen(key) + strlen(value) + 8; // Calculate required length
-    char* result = (char*)malloc(length * sizeof(char)); // Allocate memory
-    if(result == NULL) {
+char *jsmn(const char *key, const char *value)
+{
+    int length = strlen(key) + strlen(value) + 8;         // Calculate required length
+    char *result = (char *)malloc(length * sizeof(char)); // Allocate memory
+    if (result == NULL)
+    {
         return NULL; // Handle memory allocation failure
     }
     snprintf(result, length, "{\"%s\":\"%s\"}", key, value);
@@ -392,30 +437,36 @@ char* jsmn(const char* key, const char* value) {
 }
 
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s) {
-    if(tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
-       strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
+int jsoneq(const char *json, jsmntok_t *tok, const char *s)
+{
+    if (tok->type == JSMN_STRING && (int)strlen(s) == tok->end - tok->start &&
+        strncmp(json + tok->start, s, tok->end - tok->start) == 0)
+    {
         return 0;
     }
     return -1;
 }
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens)
+{
     // Parse the JSON feed
-    if(json_data != NULL) {
+    if (json_data != NULL)
+    {
         jsmn_parser parser;
         jsmn_init(&parser);
 
         // Allocate tokens array on the heap
-        jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-        if(tokens == NULL) {
+        jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+        if (tokens == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
             return NULL;
         }
 
         int ret = jsmn_parse(&parser, json_data, strlen(json_data), tokens, max_tokens);
-        if(ret < 0) {
+        if (ret < 0)
+        {
             // Handle parsing errors
             FURI_LOG_E("JSMM.H", "Failed to parse JSON: %d", ret);
             free(tokens);
@@ -423,19 +474,23 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
         }
 
         // Ensure that the root element is an object
-        if(ret < 1 || tokens[0].type != JSMN_OBJECT) {
+        if (ret < 1 || tokens[0].type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Root element is not an object.");
             free(tokens);
             return NULL;
         }
 
         // Loop through the tokens to find the key
-        for(int i = 1; i < ret; i++) {
-            if(jsoneq(json_data, &tokens[i], key) == 0) {
+        for (int i = 1; i < ret; i++)
+        {
+            if (jsoneq(json_data, &tokens[i], key) == 0)
+            {
                 // We found the key. Now, return the associated value.
                 int length = tokens[i + 1].end - tokens[i + 1].start;
-                char* value = malloc(length + 1);
-                if(value == NULL) {
+                char *value = malloc(length + 1);
+                if (value == NULL)
+                {
                     FURI_LOG_E("JSMM.H", "Failed to allocate memory for value.");
                     free(tokens);
                     return NULL;
@@ -450,7 +505,9 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 
         // Free the token array if key was not found
         free(tokens);
-    } else {
+    }
+    else
+    {
         FURI_LOG_E("JSMM.H", "JSON data is NULL");
     }
     FURI_LOG_E("JSMM.H", "Failed to find the key in the JSON.");
@@ -458,10 +515,12 @@ char* get_json_value(char* key, char* json_data, uint32_t max_tokens) {
 }
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens) {
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -471,8 +530,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens);
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens);
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -480,7 +540,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -488,7 +549,8 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Ensure the root element is an array
-    if(ret < 1 || tokens[0].type != JSMN_ARRAY) {
+    if (ret < 1 || tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -496,12 +558,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     }
 
     // Check if the index is within bounds
-    if(index >= (uint32_t)tokens[0].size) {
-        FURI_LOG_E(
-            "JSMM.H",
-            "Index %lu out of bounds for array with size %d.",
-            (unsigned long)index,
-            tokens[0].size);
+    if (index >= (uint32_t)tokens[0].size)
+    {
+        FURI_LOG_E("JSMM.H", "Index %lu out of bounds for array with size %d.", (unsigned long)index, tokens[0].size);
         free(tokens);
         free(array_str);
         return NULL;
@@ -509,20 +568,27 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 
     // Locate the token corresponding to the desired array element
     int current_token = 1; // Start after the array token
-    for(uint32_t i = 0; i < index; i++) {
-        if(tokens[current_token].type == JSMN_OBJECT) {
+    for (uint32_t i = 0; i < index; i++)
+    {
+        if (tokens[current_token].type == JSMN_OBJECT)
+        {
             // For objects, skip all key-value pairs
             current_token += 1 + 2 * tokens[current_token].size;
-        } else if(tokens[current_token].type == JSMN_ARRAY) {
+        }
+        else if (tokens[current_token].type == JSMN_ARRAY)
+        {
             // For nested arrays, skip all elements
             current_token += 1 + tokens[current_token].size;
-        } else {
+        }
+        else
+        {
             // For primitive types, simply move to the next token
             current_token += 1;
         }
 
         // Safety check to prevent out-of-bounds
-        if(current_token >= ret) {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             free(tokens);
             free(array_str);
@@ -533,8 +599,9 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
     // Extract the array element
     jsmntok_t element = tokens[current_token];
     int length = element.end - element.start;
-    char* value = malloc(length + 1);
-    if(value == NULL) {
+    char *value = malloc(length + 1);
+    if (value == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
         free(tokens);
         free(array_str);
@@ -553,10 +620,12 @@ char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t
 }
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values) {
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values)
+{
     // Retrieve the array string for the given key
-    char* array_str = get_json_value(key, json_data, max_tokens);
-    if(array_str == NULL) {
+    char *array_str = get_json_value(key, json_data, max_tokens);
+    if (array_str == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to get array for key: %s", key);
         return NULL;
     }
@@ -566,8 +635,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     jsmn_init(&parser);
 
     // Allocate memory for JSON tokens
-    jsmntok_t* tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
-    if(tokens == NULL) {
+    jsmntok_t *tokens = malloc(sizeof(jsmntok_t) * max_tokens); // Allocate on the heap
+    if (tokens == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for JSON tokens.");
         free(array_str);
         return NULL;
@@ -575,7 +645,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Parse the JSON array
     int ret = jsmn_parse(&parser, array_str, strlen(array_str), tokens, max_tokens);
-    if(ret < 0) {
+    if (ret < 0)
+    {
         FURI_LOG_E("JSMM.H", "Failed to parse JSON array: %d", ret);
         free(tokens);
         free(array_str);
@@ -583,7 +654,8 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     }
 
     // Ensure the root element is an array
-    if(tokens[0].type != JSMN_ARRAY) {
+    if (tokens[0].type != JSMN_ARRAY)
+    {
         FURI_LOG_E("JSMM.H", "Value for key '%s' is not an array.", key);
         free(tokens);
         free(array_str);
@@ -592,8 +664,9 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Allocate memory for the array of values (maximum possible)
     int array_size = tokens[0].size;
-    char** values = malloc(array_size * sizeof(char*));
-    if(values == NULL) {
+    char **values = malloc(array_size * sizeof(char *));
+    if (values == NULL)
+    {
         FURI_LOG_E("JSMM.H", "Failed to allocate memory for array of values.");
         free(tokens);
         free(array_str);
@@ -604,15 +677,18 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
 
     // Traverse the array and extract all object values
     int current_token = 1; // Start after the array token
-    for(int i = 0; i < array_size; i++) {
-        if(current_token >= ret) {
+    for (int i = 0; i < array_size; i++)
+    {
+        if (current_token >= ret)
+        {
             FURI_LOG_E("JSMM.H", "Unexpected end of tokens while traversing array.");
             break;
         }
 
         jsmntok_t element = tokens[current_token];
 
-        if(element.type != JSMN_OBJECT) {
+        if (element.type != JSMN_OBJECT)
+        {
             FURI_LOG_E("JSMM.H", "Array element %d is not an object, skipping.", i);
             // Skip this element
             current_token += 1;
@@ -622,10 +698,12 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
         int length = element.end - element.start;
 
         // Allocate a new string for the value and copy the data
-        char* value = malloc(length + 1);
-        if(value == NULL) {
+        char *value = malloc(length + 1);
+        if (value == NULL)
+        {
             FURI_LOG_E("JSMM.H", "Failed to allocate memory for array element.");
-            for(int j = 0; j < actual_num_values; j++) {
+            for (int j = 0; j < actual_num_values; j++)
+            {
                 free(values[j]);
             }
             free(values);
@@ -647,14 +725,17 @@ char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, in
     *num_values = actual_num_values;
 
     // Reallocate the values array to actual_num_values if necessary
-    if(actual_num_values < array_size) {
-        char** reduced_values = realloc(values, actual_num_values * sizeof(char*));
-        if(reduced_values != NULL) {
+    if (actual_num_values < array_size)
+    {
+        char **reduced_values = realloc(values, actual_num_values * sizeof(char *));
+        if (reduced_values != NULL)
+        {
             values = reduced_values;
         }
 
         // Free the remaining values
-        for(int i = actual_num_values; i < array_size; i++) {
+        for (int i = actual_num_values; i < array_size; i++)
+        {
             free(values[i]);
         }
     }

+ 49 - 48
web_crawler/jsmn/jsmn.h

@@ -19,7 +19,8 @@
 #include <stddef.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
 #ifdef JSMN_STATIC
@@ -28,71 +29,71 @@ extern "C" {
 #define JSMN_API extern
 #endif
 
-/**
+    /**
      * JSON type identifier. Basic types are:
      * 	o Object
      * 	o Array
      * 	o String
      * 	o Other primitive: number, boolean (true/false) or null
      */
-typedef enum {
-    JSMN_UNDEFINED = 0,
-    JSMN_OBJECT = 1 << 0,
-    JSMN_ARRAY = 1 << 1,
-    JSMN_STRING = 1 << 2,
-    JSMN_PRIMITIVE = 1 << 3
-} jsmntype_t;
-
-enum jsmnerr {
-    /* Not enough tokens were provided */
-    JSMN_ERROR_NOMEM = -1,
-    /* Invalid character inside JSON string */
-    JSMN_ERROR_INVAL = -2,
-    /* The string is not a full JSON packet, more bytes expected */
-    JSMN_ERROR_PART = -3
-};
-
-/**
+    typedef enum
+    {
+        JSMN_UNDEFINED = 0,
+        JSMN_OBJECT = 1 << 0,
+        JSMN_ARRAY = 1 << 1,
+        JSMN_STRING = 1 << 2,
+        JSMN_PRIMITIVE = 1 << 3
+    } jsmntype_t;
+
+    enum jsmnerr
+    {
+        /* Not enough tokens were provided */
+        JSMN_ERROR_NOMEM = -1,
+        /* Invalid character inside JSON string */
+        JSMN_ERROR_INVAL = -2,
+        /* The string is not a full JSON packet, more bytes expected */
+        JSMN_ERROR_PART = -3
+    };
+
+    /**
      * JSON token description.
      * type		type (object, array, string etc.)
      * start	start position in JSON data string
      * end		end position in JSON data string
      */
-typedef struct {
-    jsmntype_t type;
-    int start;
-    int end;
-    int size;
+    typedef struct
+    {
+        jsmntype_t type;
+        int start;
+        int end;
+        int size;
 #ifdef JSMN_PARENT_LINKS
-    int parent;
+        int parent;
 #endif
-} jsmntok_t;
+    } jsmntok_t;
 
-/**
+    /**
      * JSON parser. Contains an array of token blocks available. Also stores
      * the string being parsed now and current position in that string.
      */
-typedef struct {
-    unsigned int pos; /* offset in the JSON string */
-    unsigned int toknext; /* next token to allocate */
-    int toksuper; /* superior token node, e.g. parent object or array */
-} jsmn_parser;
-
-/**
+    typedef struct
+    {
+        unsigned int pos;     /* offset in the JSON string */
+        unsigned int toknext; /* next token to allocate */
+        int toksuper;         /* superior token node, e.g. parent object or array */
+    } jsmn_parser;
+
+    /**
      * Create JSON parser over an array of tokens
      */
-JSMN_API void jsmn_init(jsmn_parser* parser);
+    JSMN_API void jsmn_init(jsmn_parser *parser);
 
-/**
+    /**
      * Run JSON parser. It parses a JSON data string into and array of tokens, each
      * describing a single JSON object.
      */
-JSMN_API int jsmn_parse(
-    jsmn_parser* parser,
-    const char* js,
-    const size_t len,
-    jsmntok_t* tokens,
-    const unsigned int num_tokens);
+    JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+                            jsmntok_t *tokens, const unsigned int num_tokens);
 
 #ifndef JSMN_HEADER
 /* Implementation has been moved to jsmn.c */
@@ -116,16 +117,16 @@ JSMN_API int jsmn_parse(
 #include <furi.h>
 
 // Helper function to create a JSON object
-char* jsmn(const char* key, const char* value);
+char *jsmn(const char *key, const char *value);
 // Helper function to compare JSON keys
-int jsoneq(const char* json, jsmntok_t* tok, const char* s);
+int jsoneq(const char *json, jsmntok_t *tok, const char *s);
 
 // Return the value of the key in the JSON data
-char* get_json_value(char* key, char* json_data, uint32_t max_tokens);
+char *get_json_value(char *key, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_value function
-char* get_json_array_value(char* key, uint32_t index, char* json_data, uint32_t max_tokens);
+char *get_json_array_value(char *key, uint32_t index, char *json_data, uint32_t max_tokens);
 
 // Revised get_json_array_values function with correct token skipping
-char** get_json_array_values(char* key, char* json_data, uint32_t max_tokens, int* num_values);
+char **get_json_array_values(char *key, char *json_data, uint32_t max_tokens, int *num_values);
 #endif /* JB_JSMN_EDIT */

+ 127 - 65
web_crawler/web_crawler.c

@@ -1,95 +1,115 @@
 #include <web_crawler.h>
 
-void web_crawler_loader_free_model(View* view);
+void web_crawler_loader_free_model(View *view);
 
-void free_buffers(WebCrawlerApp* app) {
-    if(!app) {
+void free_buffers(WebCrawlerApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "Invalid app context");
         return;
     }
-    if(app->path) {
+    if (app->path)
+    {
         free(app->path);
         app->path = NULL;
     }
 
-    if(app->temp_buffer_path) {
+    if (app->temp_buffer_path)
+    {
         free(app->temp_buffer_path);
         app->temp_buffer_path = NULL;
     }
 
-    if(app->ssid) {
+    if (app->ssid)
+    {
         free(app->ssid);
         app->ssid = NULL;
     }
 
-    if(app->temp_buffer_ssid) {
+    if (app->temp_buffer_ssid)
+    {
         free(app->temp_buffer_ssid);
         app->temp_buffer_ssid = NULL;
     }
 
-    if(app->password) {
+    if (app->password)
+    {
         free(app->password);
         app->password = NULL;
     }
 
-    if(app->temp_buffer_password) {
+    if (app->temp_buffer_password)
+    {
         free(app->temp_buffer_password);
         app->temp_buffer_password = NULL;
     }
 
-    if(app->file_type) {
+    if (app->file_type)
+    {
         free(app->file_type);
         app->file_type = NULL;
     }
 
-    if(app->temp_buffer_file_type) {
+    if (app->temp_buffer_file_type)
+    {
         free(app->temp_buffer_file_type);
         app->temp_buffer_file_type = NULL;
     }
 
-    if(app->file_rename) {
+    if (app->file_rename)
+    {
         free(app->file_rename);
         app->file_rename = NULL;
     }
 
-    if(app->temp_buffer_file_rename) {
+    if (app->temp_buffer_file_rename)
+    {
         free(app->temp_buffer_file_rename);
         app->temp_buffer_file_rename = NULL;
     }
 
-    if(app->temp_buffer_http_method) {
+    if (app->temp_buffer_http_method)
+    {
         free(app->temp_buffer_http_method);
         app->temp_buffer_http_method = NULL;
     }
 
-    if(app->temp_buffer_headers) {
+    if (app->temp_buffer_headers)
+    {
         free(app->temp_buffer_headers);
         app->temp_buffer_headers = NULL;
     }
 
-    if(app->temp_buffer_payload) {
+    if (app->temp_buffer_payload)
+    {
         free(app->temp_buffer_payload);
         app->temp_buffer_payload = NULL;
     }
 
-    if(app->http_method) {
+    if (app->http_method)
+    {
         free(app->http_method);
         app->http_method = NULL;
     }
 
-    if(app->headers) {
+    if (app->headers)
+    {
         free(app->headers);
         app->headers = NULL;
     }
 
-    if(app->payload) {
+    if (app->payload)
+    {
         free(app->payload);
         app->payload = NULL;
     }
 }
 
-void free_resources(WebCrawlerApp* app) {
-    if(!app) {
+void free_resources(WebCrawlerApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "Invalid app context");
         return;
     }
@@ -97,32 +117,52 @@ void free_resources(WebCrawlerApp* app) {
     free_buffers(app);
 }
 
-void free_all(WebCrawlerApp* app, char* reason) {
-    if(!app) {
+void free_all(WebCrawlerApp *app, char *reason)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "Invalid app context");
         return;
     }
-    if(reason) {
+    if (reason)
+    {
         FURI_LOG_I(TAG, reason);
     }
 
-    if(app->view_loader) view_free(app->view_loader);
-    if(app->submenu_main) submenu_free(app->submenu_main);
-    if(app->submenu_config) submenu_free(app->submenu_config);
-    if(app->variable_item_list_wifi) variable_item_list_free(app->variable_item_list_wifi);
-    if(app->variable_item_list_file) variable_item_list_free(app->variable_item_list_file);
-    if(app->variable_item_list_request) variable_item_list_free(app->variable_item_list_request);
-    if(app->view_dispatcher) view_dispatcher_free(app->view_dispatcher);
-    if(app->widget_about) widget_free(app->widget_about);
-    if(app->widget_file_read) widget_free(app->widget_file_read);
-    if(app->widget_file_delete) widget_free(app->widget_file_delete);
-    if(app->text_input_path) text_input_free(app->text_input_path);
-    if(app->text_input_ssid) text_input_free(app->text_input_ssid);
-    if(app->text_input_password) text_input_free(app->text_input_password);
-    if(app->text_input_file_type) text_input_free(app->text_input_file_type);
-    if(app->text_input_file_rename) text_input_free(app->text_input_file_rename);
-    if(app->text_input_headers) text_input_free(app->text_input_headers);
-    if(app->text_input_payload) text_input_free(app->text_input_payload);
+    if (app->view_loader)
+        view_free(app->view_loader);
+    if (app->submenu_main)
+        submenu_free(app->submenu_main);
+    if (app->submenu_config)
+        submenu_free(app->submenu_config);
+    if (app->variable_item_list_wifi)
+        variable_item_list_free(app->variable_item_list_wifi);
+    if (app->variable_item_list_file)
+        variable_item_list_free(app->variable_item_list_file);
+    if (app->variable_item_list_request)
+        variable_item_list_free(app->variable_item_list_request);
+    if (app->view_dispatcher)
+        view_dispatcher_free(app->view_dispatcher);
+    if (app->widget_about)
+        widget_free(app->widget_about);
+    if (app->widget_file_read)
+        widget_free(app->widget_file_read);
+    if (app->widget_file_delete)
+        widget_free(app->widget_file_delete);
+    if (app->text_input_path)
+        text_input_free(app->text_input_path);
+    if (app->text_input_ssid)
+        text_input_free(app->text_input_ssid);
+    if (app->text_input_password)
+        text_input_free(app->text_input_password);
+    if (app->text_input_file_type)
+        text_input_free(app->text_input_file_type);
+    if (app->text_input_file_rename)
+        text_input_free(app->text_input_file_rename);
+    if (app->text_input_headers)
+        text_input_free(app->text_input_headers);
+    if (app->text_input_payload)
+        text_input_free(app->text_input_payload);
 
     furi_record_close(RECORD_GUI);
     free_resources(app);
@@ -131,19 +171,23 @@ void free_all(WebCrawlerApp* app, char* reason) {
  * @brief      Function to free the resources used by WebCrawlerApp.
  * @param      app  The WebCrawlerApp object to free.
  */
-void web_crawler_app_free(WebCrawlerApp* app) {
-    if(!app) {
+void web_crawler_app_free(WebCrawlerApp *app)
+{
+    if (!app)
+    {
         FURI_LOG_E(TAG, "Invalid app context");
         return;
     }
 
-    if(!app->view_dispatcher) {
+    if (!app->view_dispatcher)
+    {
         FURI_LOG_E(TAG, "Invalid view dispatcher");
         return;
     }
 
     // Free View(s)
-    if(app->view_loader) {
+    if (app->view_loader)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewLoader);
         web_crawler_loader_free_model(app->view_loader);
         view_free(app->view_loader);
@@ -152,24 +196,29 @@ void web_crawler_app_free(WebCrawlerApp* app) {
     flipper_http_deinit();
 
     // Remove and free Submenu
-    if(app->submenu_main) {
+    if (app->submenu_main)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewSubmenuMain);
         submenu_free(app->submenu_main);
     }
-    if(app->submenu_config) {
+    if (app->submenu_config)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewSubmenuConfig);
         submenu_free(app->submenu_config);
     }
     // Remove and free Variable Item Lists
-    if(app->variable_item_list_wifi) {
+    if (app->variable_item_list_wifi)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewVariableItemListWifi);
         variable_item_list_free(app->variable_item_list_wifi);
     }
-    if(app->variable_item_list_file) {
+    if (app->variable_item_list_file)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewVariableItemListFile);
         variable_item_list_free(app->variable_item_list_file);
     }
-    if(app->variable_item_list_request) {
+    if (app->variable_item_list_request)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewVariableItemListRequest);
         variable_item_list_free(app->variable_item_list_request);
     }
@@ -182,40 +231,53 @@ void web_crawler_app_free(WebCrawlerApp* app) {
     view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewTextInputFileRename);
     view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewTextInputHeaders);
     view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewTextInputPayload);
-    if(app->text_input_path) text_input_free(app->text_input_path);
-    if(app->text_input_ssid) text_input_free(app->text_input_ssid);
-    if(app->text_input_password) text_input_free(app->text_input_password);
-    if(app->text_input_file_type) text_input_free(app->text_input_file_type);
-    if(app->text_input_file_rename) text_input_free(app->text_input_file_rename);
-    if(app->text_input_headers) text_input_free(app->text_input_headers);
-    if(app->text_input_payload) text_input_free(app->text_input_payload);
+    if (app->text_input_path)
+        text_input_free(app->text_input_path);
+    if (app->text_input_ssid)
+        text_input_free(app->text_input_ssid);
+    if (app->text_input_password)
+        text_input_free(app->text_input_password);
+    if (app->text_input_file_type)
+        text_input_free(app->text_input_file_type);
+    if (app->text_input_file_rename)
+        text_input_free(app->text_input_file_rename);
+    if (app->text_input_headers)
+        text_input_free(app->text_input_headers);
+    if (app->text_input_payload)
+        text_input_free(app->text_input_payload);
 
     // Remove and free Widgets
-    if(app->widget_about) {
+    if (app->widget_about)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewAbout);
         widget_free(app->widget_about);
     }
-    if(app->widget_file_read) {
+    if (app->widget_file_read)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewFileRead);
         widget_free(app->widget_file_read);
     }
-    if(app->widget_file_delete) {
+    if (app->widget_file_delete)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewFileDelete);
         widget_free(app->widget_file_delete);
     }
-    if(app->widget_result) {
+    if (app->widget_result)
+    {
         view_dispatcher_remove_view(app->view_dispatcher, WebCrawlerViewWidgetResult);
         widget_free(app->widget_result);
     }
 
     // Free the ViewDispatcher and close GUI
-    if(app->view_dispatcher) view_dispatcher_free(app->view_dispatcher);
+    if (app->view_dispatcher)
+        view_dispatcher_free(app->view_dispatcher);
 
     // Free the application structure
-    if(app) {
+    if (app)
+    {
         free(app);
     }
 }
 
-WebCrawlerApp* app_instance = NULL;
-char* http_method_names[] = {"GET", "POST", "PUT", "DELETE", "DOWNLOAD"};
+WebCrawlerApp *app_instance = NULL;
+char *http_method_names[] = {"GET", "POST", "PUT", "DELETE", "DOWNLOAD"};

+ 85 - 82
web_crawler/web_crawler.h

@@ -9,124 +9,127 @@
 #include <storage/storage.h>
 
 #define TAG "Web Crawler"
-extern char* http_method_names[];
+extern char *http_method_names[];
 
 // Define the submenu items for our WebCrawler application
-typedef enum {
-    WebCrawlerSubmenuIndexRun, // click to go to Run the GET request
-    WebCrawlerSubmenuIndexAbout, // click to go to About screen
-    WebCrawlerSubmenuIndexConfig, // click to go to Config submenu (Wifi, File)
+typedef enum
+{
+    WebCrawlerSubmenuIndexRun,     // click to go to Run the GET request
+    WebCrawlerSubmenuIndexAbout,   // click to go to About screen
+    WebCrawlerSubmenuIndexConfig,  // click to go to Config submenu (Wifi, File)
     WebCrawlerSubmenuIndexRequest, // click to go to Request submenu (Set URL, HTTP Method, Headers)
-    WebCrawlerSubmenuIndexWifi, // click to go to Wifi submenu (SSID, Password)
-    WebCrawlerSubmenuIndexFile, // click to go to file submenu (Read, File Type, Rename, Delete)
+    WebCrawlerSubmenuIndexWifi,    // click to go to Wifi submenu (SSID, Password)
+    WebCrawlerSubmenuIndexFile,    // click to go to file submenu (Read, File Type, Rename, Delete)
 } WebCrawlerSubmenuIndex;
 
-typedef enum {
-    WebCrawlerViewAbout, // About screen
-    WebCrawlerViewSubmenuConfig, // Submenu Config view for App (Wifi, File)
+typedef enum
+{
+    WebCrawlerViewAbout,                   // About screen
+    WebCrawlerViewSubmenuConfig,           // Submenu Config view for App (Wifi, File)
     WebCrawlerViewVariableItemListRequest, // Submenu for URL (Set URL, HTTP Method, Headers)
-    WebCrawlerViewVariableItemListWifi, // Wifi Configuration screen (Submenu for SSID, Password)
-    WebCrawlerViewVariableItemListFile, // Submenu for File (Read, File Type, Rename, Delete)
-    WebCrawlerViewSubmenuMain, // Submenu Main view for App (Run, About, Config)
-    WebCrawlerViewTextInput, // Text input for Path
-    WebCrawlerViewTextInputSSID, // Text input for SSID
-    WebCrawlerViewTextInputPassword, // Text input for Password
-    WebCrawlerViewFileRead, // File Read
-    WebCrawlerViewTextInputFileType, // Text input for File Type
-    WebCrawlerViewTextInputFileRename, // Text input for File Rename
-    WebCrawlerViewTextInputHeaders, // Text input for Headers
-    WebCrawlerViewTextInputPayload, // Text input for Payload
-    WebCrawlerViewFileDelete, // File Delete
+    WebCrawlerViewVariableItemListWifi,    // Wifi Configuration screen (Submenu for SSID, Password)
+    WebCrawlerViewVariableItemListFile,    // Submenu for File (Read, File Type, Rename, Delete)
+    WebCrawlerViewSubmenuMain,             // Submenu Main view for App (Run, About, Config)
+    WebCrawlerViewTextInput,               // Text input for Path
+    WebCrawlerViewTextInputSSID,           // Text input for SSID
+    WebCrawlerViewTextInputPassword,       // Text input for Password
+    WebCrawlerViewFileRead,                // File Read
+    WebCrawlerViewTextInputFileType,       // Text input for File Type
+    WebCrawlerViewTextInputFileRename,     // Text input for File Rename
+    WebCrawlerViewTextInputHeaders,        // Text input for Headers
+    WebCrawlerViewTextInputPayload,        // Text input for Payload
+    WebCrawlerViewFileDelete,              // File Delete
     //
     WebCrawlerViewWidgetResult, // The text box that displays the random fact
-    WebCrawlerViewLoader, // The loader screen retrieves data from the internet
+    WebCrawlerViewLoader,       // The loader screen retrieves data from the internet
 } WebCrawlerViewIndex;
 
 // Define the application structure
-typedef struct {
-    ViewDispatcher* view_dispatcher;
-    View* view_main;
-    View* view_run;
-    View* view_loader;
-    Submenu* submenu_main;
-    Submenu* submenu_config;
-    Widget* widget_about;
-    Widget* widget_result; // The widget that displays the result
-
-    TextInput* text_input_path;
-    TextInput* text_input_ssid;
-    TextInput* text_input_password;
-    TextInput* text_input_file_type;
-    TextInput* text_input_file_rename;
+typedef struct
+{
+    ViewDispatcher *view_dispatcher;
+    View *view_main;
+    View *view_run;
+    View *view_loader;
+    Submenu *submenu_main;
+    Submenu *submenu_config;
+    Widget *widget_about;
+    Widget *widget_result; // The widget that displays the result
+
+    TextInput *text_input_path;
+    TextInput *text_input_ssid;
+    TextInput *text_input_password;
+    TextInput *text_input_file_type;
+    TextInput *text_input_file_rename;
     //
-    TextInput* text_input_headers;
-    TextInput* text_input_payload;
-
-    Widget* widget_file_read;
-    Widget* widget_file_delete;
-
-    VariableItemList* variable_item_list_wifi;
-    VariableItemList* variable_item_list_file;
-    VariableItemList* variable_item_list_request;
-
-    VariableItem* path_item;
-    VariableItem* ssid_item;
-    VariableItem* password_item;
-    VariableItem* file_type_item;
-    VariableItem* file_rename_item;
-    VariableItem* file_read_item;
-    VariableItem* file_delete_item;
+    TextInput *text_input_headers;
+    TextInput *text_input_payload;
+
+    Widget *widget_file_read;
+    Widget *widget_file_delete;
+
+    VariableItemList *variable_item_list_wifi;
+    VariableItemList *variable_item_list_file;
+    VariableItemList *variable_item_list_request;
+
+    VariableItem *path_item;
+    VariableItem *ssid_item;
+    VariableItem *password_item;
+    VariableItem *file_type_item;
+    VariableItem *file_rename_item;
+    VariableItem *file_read_item;
+    VariableItem *file_delete_item;
     //
-    VariableItem* http_method_item;
-    VariableItem* headers_item;
-    VariableItem* payload_item;
-
-    char* path;
-    char* ssid;
-    char* password;
-    char* file_type;
-    char* file_rename;
-    char* http_method;
-    char* headers;
-    char* payload;
-
-    char* temp_buffer_path;
+    VariableItem *http_method_item;
+    VariableItem *headers_item;
+    VariableItem *payload_item;
+
+    char *path;
+    char *ssid;
+    char *password;
+    char *file_type;
+    char *file_rename;
+    char *http_method;
+    char *headers;
+    char *payload;
+
+    char *temp_buffer_path;
     uint32_t temp_buffer_size_path;
 
-    char* temp_buffer_ssid;
+    char *temp_buffer_ssid;
     uint32_t temp_buffer_size_ssid;
 
-    char* temp_buffer_password;
+    char *temp_buffer_password;
     uint32_t temp_buffer_size_password;
 
-    char* temp_buffer_file_type;
+    char *temp_buffer_file_type;
     uint32_t temp_buffer_size_file_type;
 
-    char* temp_buffer_file_rename;
+    char *temp_buffer_file_rename;
     uint32_t temp_buffer_size_file_rename;
 
-    char* temp_buffer_http_method;
+    char *temp_buffer_http_method;
     uint32_t temp_buffer_size_http_method;
 
-    char* temp_buffer_headers;
+    char *temp_buffer_headers;
     uint32_t temp_buffer_size_headers;
 
-    char* temp_buffer_payload;
+    char *temp_buffer_payload;
     uint32_t temp_buffer_size_payload;
 } WebCrawlerApp;
 
-void free_buffers(WebCrawlerApp* app);
+void free_buffers(WebCrawlerApp *app);
 
-void free_resources(WebCrawlerApp* app);
+void free_resources(WebCrawlerApp *app);
 
-void free_all(WebCrawlerApp* app, char* reason);
+void free_all(WebCrawlerApp *app, char *reason);
 
 /**
  * @brief      Function to free the resources used by WebCrawlerApp.
  * @param      app  The WebCrawlerApp object to free.
  */
-void web_crawler_app_free(WebCrawlerApp* app);
+void web_crawler_app_free(WebCrawlerApp *app);
 
-extern WebCrawlerApp* app_instance;
+extern WebCrawlerApp *app_instance;
 
-#endif // WEB_CRAWLER_E
+#endif // WEB_CRAWLER_E

Some files were not shown because too many files changed in this diff