app.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <web_crawler.h>
  2. #include <alloc/web_crawler_alloc.h>
  3. /**
  4. * @brief Entry point for the WebCrawler application.
  5. * @param p Input parameter - unused
  6. * @return 0 to indicate success, -1 on failure
  7. */
  8. int32_t web_crawler_app(void* p) {
  9. UNUSED(p);
  10. app_instance = web_crawler_app_alloc();
  11. if(!app_instance) {
  12. FURI_LOG_E(TAG, "Failed to allocate WebCrawlerApp");
  13. return -1;
  14. }
  15. if(!flipper_http_ping()) {
  16. FURI_LOG_E(TAG, "Failed to ping the device");
  17. return -1;
  18. }
  19. // Edit from Derek Jamison
  20. if(app_instance->text_input_ssid != NULL && app_instance->text_input_password != NULL) {
  21. // Try to wait for pong response.
  22. uint8_t counter = 10;
  23. while(fhttp.state == INACTIVE && --counter > 0) {
  24. FURI_LOG_D(TAG, "Waiting for PONG");
  25. furi_delay_ms(100);
  26. }
  27. if(counter == 0) {
  28. DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
  29. DialogMessage* message = dialog_message_alloc();
  30. dialog_message_set_header(
  31. message, "[FlipperHTTP Error]", 64, 0, AlignCenter, AlignTop);
  32. dialog_message_set_text(
  33. message,
  34. "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.",
  35. 0,
  36. 63,
  37. AlignLeft,
  38. AlignBottom);
  39. dialog_message_show(dialogs, message);
  40. dialog_message_free(message);
  41. furi_record_close(RECORD_DIALOGS);
  42. }
  43. }
  44. // Run the application
  45. view_dispatcher_run(app_instance->view_dispatcher);
  46. // Free resources after the application loop ends
  47. web_crawler_app_free(app_instance);
  48. return 0;
  49. }