writeRemoteCharacteristic Arduino to Android

Hello;

We are developing a project to communicate with the mobile application with ble gatt service.

I’ve examined all the samples.
I can connect to the mobile service. But I can’t write to the service.

That’s our code.

Can you help me?
Thanks

#include <BLECentralRole.h>

BLECentralRole                   bleCentral                     = BLECentralRole();
BLERemoteService                 remoteService                  = BLERemoteService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
BLERemoteCharacteristic          remoteCharacteristic           = BLERemoteCharacteristic("6E400001-B5A3-F393-E0A9-E50E24DCCA9E", BLEWrite);

static unsigned long timer=0,msec=0;
void setup() {
  Serial.begin(9600);

  bleCentral.addRemoteAttribute(remoteService);
  bleCentral.addRemoteAttribute(remoteCharacteristic);
  bleCentral.setEventHandler(BLEScanReceived, receiveAdvPck);  
  bleCentral.setEventHandler(BLEConnected, bleCentralConnectHandler);
  bleCentral.setEventHandler(BLEDisconnected, bleCentralDisconnectHandler);
  bleCentral.setEventHandler(BLERemoteServicesDiscovered, bleCentralRemoteServicesDiscoveredHandler);
  bleCentral.setScanInterval(3200); // 2 sec
  bleCentral.setScanWindow(800);  // 0.5 sec
  bleCentral.begin(); 
  
  Serial.println("Scanning...");
}

void loop() {
 
 if(bleCentral.connected()){
    Serial.println("Connected...");
      timer-=msec;
      msec=millis();
      timer+=msec;
      if (timer>=3000) {
          timer=0;
          int len = 0;
    unsigned char testmsg[] = "00";
    bleCentral.writeRemoteCharacteristic(remoteCharacteristic, testmsg, sizeof(testmsg));
    Serial.println("Sending data every 3 seconds...");
    }
 
  }
}


void receiveAdvPck(BLEPeripheralPeer& peer){
  char scannedUuid[31];
  byte len;
  // search for the NUS's uuid
  peer.getFieldInAdvPck(BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE, scannedUuid, len);
  if(len == 0) // field not found
    peer.getFieldInAdvPck(BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, scannedUuid, len);
  if(len != 0){ // the field was found
    if(!strcmp(scannedUuid, remoteService.rawUuid()))
      // the uuids match. Connect to the peripheral
      bleCentral.connect(peer);
   } 
}

void bleCentralConnectHandler(BLEPeripheralPeer& peer) {
  // peer connected event handler
  Serial.print("Connected event, peripheral: ");
  Serial.println(peer.address());
}

void bleCentralDisconnectHandler(BLEPeripheralPeer& peer) {
  // peer disconnected event handler
  Serial.print("Disconnected event, peripheral: ");
  Serial.println(peer.address());
}

void bleCentralRemoteServicesDiscoveredHandler(BLEPeripheralPeer& peer) {
  // peer remote services discovered event handler
  Serial.print("Remote services discovered event, peer: ");
  Serial.println(peer.address());

  // subscribe Tx characteristic in order to automatically receive
  // messages sent from peripheral
  if (remoteCharacteristic.canSubscribe()) {
    remoteCharacteristic.subscribe();
  }
}

void bleRemoteTxCharacteristicValueUpdatedHandle(BLEPeripheralPeer& peer, BLERemoteCharacteristic& characteristic) {
  // print the incoming message
  char * message = (char *)remoteCharacteristic.value();
  for(int i=0; i<remoteCharacteristic.valueLength(); i++)
    Serial.print(message[i]);
  Serial.println();
 }

Mobile code

 private fun createTimeService(): BluetoothGattService {
        val service = BluetoothGattService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E",
            BluetoothGattService.SERVICE_TYPE_PRIMARY)

        
        val localTime = BluetoothGattCharacteristic("6E400001-B5A3-F393-E0A9-E50E24DCCA9E",
            //Read-only characteristic
            BluetoothGattCharacteristic.PROPERTY_WRITE,
            BluetoothGattCharacteristic.PERMISSION_WRITE)

        service.addCharacteristic(localTime)

        return service
    }


private val gattServerCallback = object : BluetoothGattServerCallback() {
        override fun onDescriptorReadRequest(
            device: BluetoothDevice?,
            requestId: Int,
            offset: Int,
            descriptor: BluetoothGattDescriptor?
        ) {
            super.onDescriptorReadRequest(device, requestId, offset, descriptor)
            Log.d("logg","onDescriptorReadRequest")
        }

        override fun onNotificationSent(device: BluetoothDevice?, status: Int) {
            super.onNotificationSent(device, status)
            Log.d("logg","onNotificationSent")
        }

        override fun onMtuChanged(device: BluetoothDevice?, mtu: Int) {
            super.onMtuChanged(device, mtu)
            Log.d("logg","onMtuChanged")
        }

        override fun onPhyUpdate(device: BluetoothDevice?, txPhy: Int, rxPhy: Int, status: Int) {
            super.onPhyUpdate(device, txPhy, rxPhy, status)
            Log.d("logg","onPhyUpdate")
        }

        override fun onExecuteWrite(device: BluetoothDevice?, requestId: Int, execute: Boolean) {
            super.onExecuteWrite(device, requestId, execute)
            Log.d("logg","onExecuteWrite")
        }

        override fun onCharacteristicWriteRequest(
            device: BluetoothDevice?,
            requestId: Int,
            characteristic: BluetoothGattCharacteristic?,
            preparedWrite: Boolean,
            responseNeeded: Boolean,
            offset: Int,
            value: ByteArray?
        ) {
            super.onCharacteristicWriteRequest(
                device,
                requestId,
                characteristic,
                preparedWrite,
                responseNeeded,
                offset,
                value
            )
            Log.d("logg","onCharacteristicWriteRequest")
        }

        override fun onCharacteristicReadRequest(
            device: BluetoothDevice?,
            requestId: Int,
            offset: Int,
            characteristic: BluetoothGattCharacteristic?
        ) {
            super.onCharacteristicReadRequest(device, requestId, offset, characteristic)
            Log.d("logg","onCharacteristicReadRequest")
        }

        override fun onConnectionStateChange(device: BluetoothDevice?, status: Int, newState: Int) {
            super.onConnectionStateChange(device, status, newState)
            if  (newState==2)
            {


            }
            Log.d("logg","onConnectionStateChange")
        }

        override fun onPhyRead(device: BluetoothDevice?, txPhy: Int, rxPhy: Int, status: Int) {
            super.onPhyRead(device, txPhy, rxPhy, status)
            Log.d("logg","onPhyRead")
        }

        override fun onDescriptorWriteRequest(
            device: BluetoothDevice?,
            requestId: Int,
            descriptor: BluetoothGattDescriptor?,
            preparedWrite: Boolean,
            responseNeeded: Boolean,
            offset: Int,
            value: ByteArray?
        ) {
            super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, responseNeeded, offset, value)
            Log.d("logg","onDescriptorWriteRequest")
        }

        override fun onServiceAdded(status: Int, service: BluetoothGattService?) {
            super.onServiceAdded(status, service)
            Log.d("logg","onServiceAdded")
        }
    }