Please Help me this function doesn't fire from the periperical?

excuse me. I 'm new here...

void loopToConfigLedAndBle() {
  // listen for BLE peripherals to connect:
  BLEDevice central = BLE.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    if(central.hasLocalName()){
      Serial.print("Connected to central: ");
      Serial.println(central.localName());
      
    }

    // while the central is still connected to peripheral:
    while (central.connected()) {
      // if the remote device wrote to the characteristic,
      // use the value to control the LED:
      if (switchCharacteristic.written()) {
        int value  = switchCharacteristic.value();
        Serial.print("value: "+value);
        if (value ==1) {   // any value other than 0
          Serial.println("LED on");
          digitalWrite(ledPin, HIGH);         // will turn the LED on
        } else {                              // a 0 value
          Serial.println(F("LED off"));
          digitalWrite(ledPin, LOW);          // will turn the LED off
        }
      }else{
         //Serial.println("is connected:"+central.address());
      }
      //delay(1000);
    }

    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}