BLE and App inventor data transfer issues

Good day Friends, I have a couple of challenges with my on going project.

  1. i can not receive data from mit app inventor app to esp32; here i'm using two timer for the delays before the data transfer, when BLE is connected it set time interval and anable "Clock_sendDevice_ID timer and when Clock_sendDevice_ID is anable it suppose to send the data but esp32 can't receive the data

2.i can receive value data from esp32 to the app however "combinedData" data is bigger than BLE default data rate so I'm requesting for MTU change and that is done i can only received the combineData data.
these are two issues i"m trying to resolve.
these are the codes for esp32 and the app inventor.

#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

// create pointers
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
BLECharacteristic* pCharacteristic_1 = NULL;
BLECharacteristic* pCharacteristic_2 = NULL;
BLECharacteristic* pCharacteristic_3 = NULL;
BLECharacteristic* pCharacteristic_4 = NULL;

BLEDescriptor *pDescr;
BLE2902 *pBLE2902;

bool deviceConnected = false;
bool oldDeviceConnected = false;
uint32_t value = 0;

//>>>>>>>>>>>>>>>>>>>> variables'content will be send to app <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
String logitude_cordinate = "140321000";
String latitude_cordinat = "2.4675765";
uint32_t Reci_cellSite_Dist = 8500;
String Reci_cellSite_Name = "globA1";      
byte Tracer_cellSite_Dist = 6;      
String Tracer_cellSite_Name = "globB5";   
byte ReciToTracker_Dist = 9;
float Tracker_batteryRemaining = 86.54;
float Reciever_BattRemain = 93.33;
int TotalMemory = 256;
float MemoryRemain = 188.65;
bool trackerBattery_chargingStatus = 0;
byte radio_RSSI = 88;
byte bluetooth_RSSI = 74;

String deviceID_received = "";

String deviceID = "";
float default_frequency = 0;
String userPhone_number = "";
String trackerPhone_number = "";

static BLEUUID BLESERVICE_UUID("4fafc201-1fb5-459e-8fcc-c5c9c331914b");   // this allow the use of more than four services
#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHAR_UUID          "beb5483e-36e1-4688-b7f5-ea07361b26a8"
#define CHAR1_UUID          "e3223119-9445-4e96-a4a1-85358c4046a2"
#define CHAR2_UUID          "8a73ddbb-3fdd-4c04-9f0e-606546d8d36d"   
#define CHAR3_UUID          "9d4f2a6b-d642-40c2-8dad-1badfbb1abc3" 
#define CHAR4_UUID          "1ad44ffe-d29a-4a95-8577-56ffb0a03161" 

class MyServerCallbacks: public BLEServerCallbacks {
    void onConnect(BLEServer* pServer) {
      deviceConnected = true;
    };
    
    void onDisconnect(BLEServer* pServer) {
      deviceConnected = false;
    }
};

class CharacteristicCallBack: public BLECharacteristicCallbacks {
  void onWrite(BLECharacteristic *pChar) override {
    String pChar2_value_stdstr = pChar -> getValue(); 
    String pChar2_value_string = String (pChar2_value_stdstr.c_str());
   // try{
    int pChar2_value_int = pChar2_value_string.toInt(); //`````````````` at this piont we can transmit "pChar2_value_int" variable content
                                                          // via RADIO transmiter ````````````````````````` 
    // Use pChar2_value_int as needed
    Serial.println("pChar2: " + String(pChar2_value_string));
  
  }
};

class CharacteristicCallBack_4: public BLECharacteristicCallbacks {
  void onWrite(BLECharacteristic *pChar) /*override  */{
    String deviceid = pChar -> getValue(); 
     deviceID_received = String (deviceid.c_str());
      Serial.print("Device ID.........");
     Serial.println(deviceID_received); 
  }
  };

void setup() {
  Serial.begin(115200);

  // Create the BLE Device
  BLEDevice::init("ESP32");
  BLEDevice::setMTU(100);
  
  // Create the BLE Server
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());


  //BLEService *pService = pServer->createService(SERVICE_UUID);
   BLEService *pService = pServer->createService(BLESERVICE_UUID, 20, 0);       // this is the continuetion of the code that 
                                                                                // allow's the use of more than four services
  // Create a BLE Characteristic
  pCharacteristic = pService->createCharacteristic(
                      CHAR_UUID,
                      BLECharacteristic::PROPERTY_NOTIFY
                    );                   

  pCharacteristic_1 = pService->createCharacteristic(
                      CHAR1_UUID,
                      //BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_INDICATE 
                     // BLECharacteristic::PROPERTY_READ   |
                      //BLECharacteristic::PROPERTY_WRITE  
                    ); 
  pCharacteristic_2 = pService->createCharacteristic(
                      CHAR2_UUID,
                      BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_INDICATE |
                      BLECharacteristic::PROPERTY_READ   |
                      BLECharacteristic::PROPERTY_WRITE  
                    ); 
  pCharacteristic_3 = pService->createCharacteristic(
                      CHAR3_UUID,
                      BLECharacteristic::PROPERTY_INDICATE |
                      BLECharacteristic::PROPERTY_READ   |
                      BLECharacteristic::PROPERTY_WRITE  
                    );                                      
pCharacteristic_4 = pService->createCharacteristic(
                      CHAR4_UUID,
                      BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_READ   |
                      BLECharacteristic::PROPERTY_WRITE  
                    );
// Create a BLE Descriptor
  
  pDescr = new BLEDescriptor((uint16_t)0x2901);
  pDescr->setValue("A very interesting Setup");
  pCharacteristic->addDescriptor(pDescr);
  
  pBLE2902 = new BLE2902();
  pBLE2902->setNotifications(true);
  
  // Add all Descriptors here
  pCharacteristic->addDescriptor(pBLE2902);
  pCharacteristic_1->addDescriptor(new BLE2902());
  // After defining the desriptors, set the callback functions
  pCharacteristic_1->setCallbacks(new CharacteristicCallBack());

  pCharacteristic_2->addDescriptor(new BLE2902());
  pCharacteristic_2->setCallbacks(new CharacteristicCallBack());   //Charateristics Callback for the descriptor
                                                                   // do same for rest of descriptors  
  pCharacteristic_3->addDescriptor(new BLE2902());
  pCharacteristic_3->setCallbacks(new CharacteristicCallBack());

  pCharacteristic_4->addDescriptor(new BLE2902());
  pCharacteristic_4->setCallbacks(new CharacteristicCallBack_4());

 // Start the service
  pService->start();

  // Start advertising
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(false);
  pAdvertising->setMinPreferred(0x0);  // set value to 0x00 to not advertise this parameter
  BLEDevice::startAdvertising(); 
  pServer->getAdvertising()->start();  
  Serial.println("Waiting a client connection to notify...");
}

void loop() {
  if(Serial.available() > 0){
    logitude_cordinate = Serial.read();
    logitude_cordinate.c_str();
  }
   // notify changed value
    if (deviceConnected) {
        pCharacteristic->setValue(value);
        pCharacteristic->notify();
        value++;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% data sending and recieving if it work
   String combinedData = logitude_cordinate +"|"+ latitude_cordinat +"|"+
     Reci_cellSite_Dist +"|"+ Reci_cellSite_Name +"|"+ Tracer_cellSite_Dist +"|"+ 
     Tracer_cellSite_Name +"|"+ ReciToTracker_Dist +"|"+ Tracker_batteryRemaining+"|"+ 
     Reciever_BattRemain +"|"+ TotalMemory +"|"+ MemoryRemain +"|"+ trackerBattery_chargingStatus +"|"+
      radio_RSSI +"|"+ bluetooth_RSSI;
pCharacteristic_1->setValue(combinedData.c_str());
pCharacteristic_1->indicate(); 

delay(1000);
    }

// disconnecting
    if (!deviceConnected && oldDeviceConnected) {
        delay(500); // give the bluetooth stack the chance to get things ready
        pServer->startAdvertising(); // restart advertising
        Serial.println("start advertising");
        oldDeviceConnected = deviceConnected;
    }
    // connecting
    if (deviceConnected && !oldDeviceConnected) {
        // do stuff here on connecting
        oldDeviceConnected = deviceConnected;
    }
}

BLE_controller (1).aia (720.9 KB)

This is an enormous app you made!
It goes against the first rule in software development: Start small and keep it simple!
Make a really small app that establishes connection with your BLE device and when that succeeds, gradually expand it. It would also be a lot easier to help you then.