app.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <flip_store.h>
  2. #include <alloc/flip_store_alloc.h>
  3. // Entry point for the Hello World application
  4. int32_t main_flip_store(void *p)
  5. {
  6. // Suppress unused parameter warning
  7. UNUSED(p);
  8. // Initialize the Hello World application
  9. app_instance = flip_store_app_alloc();
  10. if (!app_instance)
  11. {
  12. FURI_LOG_E(TAG, "Failed to allocate FlipStoreApp");
  13. return -1;
  14. }
  15. // check if board is connected (Derek Jamison)
  16. // initialize the http
  17. if (flipper_http_init(flipper_http_rx_callback, app_instance))
  18. {
  19. if (!flipper_http_ping())
  20. {
  21. FURI_LOG_E(TAG, "Failed to ping the device");
  22. return -1;
  23. }
  24. // Try to wait for pong response.
  25. uint8_t counter = 10;
  26. while (fhttp.state == INACTIVE && --counter > 0)
  27. {
  28. FURI_LOG_D(TAG, "Waiting for PONG");
  29. furi_delay_ms(100);
  30. }
  31. if (counter == 0)
  32. easy_flipper_dialog("FlipperHTTP Error", "Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.");
  33. flipper_http_deinit();
  34. }
  35. else
  36. {
  37. easy_flipper_dialog("FlipperHTTP Error", "The UART is likely busy.\nEnsure you have the correct\nflash for your board then\nrestart your Flipper Zero.");
  38. }
  39. // Run the view dispatcher
  40. view_dispatcher_run(app_instance->view_dispatcher);
  41. // Free the resources used by the Hello World application
  42. flip_store_app_free(app_instance);
  43. // Return 0 to indicate success
  44. return 0;
  45. }