nfc_maker_scene_wifi.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "../nfc_maker.h"
  2. enum TextInputResult {
  3. TextInputResultOk,
  4. };
  5. static void nfc_maker_scene_wifi_text_input_callback(void* context) {
  6. NfcMaker* app = context;
  7. view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
  8. }
  9. void nfc_maker_scene_wifi_on_enter(void* context) {
  10. NfcMaker* app = context;
  11. TextInput* text_input = app->text_input;
  12. text_input_set_header_text(text_input, "Enter WiFi SSID:");
  13. strlcpy(app->small_buf1, "Bill Wi the Science Fi", sizeof(app->small_buf1));
  14. text_input_set_result_callback(
  15. text_input,
  16. nfc_maker_scene_wifi_text_input_callback,
  17. app,
  18. app->small_buf1,
  19. sizeof(app->small_buf1),
  20. true);
  21. text_input_show_illegal_symbols(text_input, true);
  22. view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
  23. }
  24. bool nfc_maker_scene_wifi_on_event(void* context, SceneManagerEvent event) {
  25. NfcMaker* app = context;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. consumed = true;
  29. switch(event.event) {
  30. case TextInputResultOk:
  31. scene_manager_set_scene_state(
  32. app->scene_manager, NfcMakerSceneWifiAuth, WifiAuthenticationWpa2Personal);
  33. scene_manager_next_scene(app->scene_manager, NfcMakerSceneWifiAuth);
  34. break;
  35. default:
  36. break;
  37. }
  38. }
  39. return consumed;
  40. }
  41. void nfc_maker_scene_wifi_on_exit(void* context) {
  42. NfcMaker* app = context;
  43. text_input_reset(app->text_input);
  44. }