BLE + WiFi_Manager by Tzapu

I' am asking for help regarding my MIT App. I want to integrate two connectivity options where the user can choose either “CONNECT BLUETOOTH” or “CONNECT WI-FI.”

I cannot use regular Bluetooth because it shares the same radio as WiFi, which means I cannot initialize both in the Arduino sketch code at the same time. If I initialize one first, the other crashes. That is why I plan to use BLE instead of Bluetooth Classic.

I have been working on this for weeks and have tried using multiple AI tools, but I still have not been able to solve it. (It's a simple logic but i can't do it.)

This is what i did for the couple of weeks

  1. Tried using TinyDB for storing data for returning users.
  2. Installed 2 extension (TaifunWifi), and BLE Extension Version 20240822

*Since im still quite new to mit app i am not sure where to place my blocks ( i need help with that, because i am not sure if i am doing it right.)

Below is the app flow:

MIT APP INVENTOR Code Blocks and ESP32 Sketch Code

I have only 2 buttons on screen1 which is "CONNECT BLUETOOTH" and "CONNECT WI-FI", 1 LABEL STATUS AND 1 Retry for Wifi if the user wants to choose another network, Assume 2 buttons, 1 Label Status, 1 Button for Retry Wifi, and screen 2 is already created.

we will not use bluetooth client classic because it cant coexist with wifi, Instead use BLE

Case 1 for BLUETOOTH(use BLE not BluetoothClassic):

  1. User Clicks "CONNECT BLUETOOTH"
  2. Users Bluetooth is not open.
  3. Notifer (Please open Bluetooth and connect to FarmMonitor_BLE) (user manually connects and pairs).
  4. User Returns to app
  5. (Label Status Changed to BLUETOOTH CONNECTED.)
  6. User Clicks "CONNECT BLUETOOTH" again.
  7. Listpicker, USER picks FarmMonitor_BLE or We can proceed immediately to screen2(Dashboard) without listpicker up to you which is easier to do.
  8. If user is already connected to and paired to FarmMonitor_BT then auto reconnection.

Case 2 for WIFI(WifiManager Library by Tzapu):

  1. User Clicks "CONNECT WIFI"
  2. Users WIFi is not open
  3. Notifer (Please open WIFI and Connect to FarmMonitor_Setup)
  4. (User connects to FarmMonitor_Setup, user will be directed to wifi web portal configuration, user configures his network, network changed to his desired network, esp32 save the users chosen network).
  5. User returns to app
  6. User Click "CONNECT WI-FI"
  7. Proceed to screen2 (Dashboard).
  8. if user wants to change different network, user clicks "Retry Wi-Fi" on Screen 1 then step step 3 to 6 starts again.

BLUETOOTH(BLE) LOCAL Connection
WIFI(ANYWHERE CONNECTION)

ESP32 INFO:
Chip type: ESP32-D0WD-V3 (revision v3.1)
Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None
Crystal frequency: 40MHz
MAC: d4:e9:f4:c3:a0:9c