title: Android BLE Gatt Server with multiple services - onCharacteristicWriteRequest() no char for handle
body: <p>I am trying to build a BLE Gatt Server with multiple custom services and multiple characteristics. </p>
  
  <p>To begin with I used the Google Example: <a href="https://github.com/androidthings/sample-bluetooth-le-gattserver/tree/master/kotlin" rel="nofollow noreferrer">https://github.com/androidthings/sample-bluetooth-le-gattserver/tree/master/kotlin</a></p>
  
  <p>This was straight forward and worked very well. I modified the UUIDs to fit mine and I could receive notifications and write to the chars with no problem.</p>
  
  <p>This is where I define the services and chars:</p>
  
  <pre><code>fun createTimeService(): BluetoothGattService {
          val service = BluetoothGattService(TIME_SERVICE,
                  BluetoothGattService.SERVICE_TYPE_PRIMARY)
  
          // Current Time characteristic
          val currentTime = BluetoothGattCharacteristic(CURRENT_TIME,
                  //Read-only characteristic, supports notifications
                  BluetoothGattCharacteristic.PROPERTY_READ or BluetoothGattCharacteristic.PROPERTY_NOTIFY,
                  BluetoothGattCharacteristic.PERMISSION_READ)
          val configDescriptor = BluetoothGattDescriptor(CLIENT_CONFIG,
                  //Read/write descriptor
                  BluetoothGattDescriptor.PERMISSION_READ or BluetoothGattDescriptor.PERMISSION_WRITE)
          currentTime.addDescriptor(configDescriptor)
  
          // Local Time Information characteristic
          val localTime = BluetoothGattCharacteristic(LOCAL_TIME_INFO,
                  BluetoothGattCharacteristic.PROPERTY_WRITE,
                  BluetoothGattCharacteristic.PERMISSION_WRITE)
  
          service.addCharacteristic(currentTime)
          service.addCharacteristic(localTime)
  
          return service
      }
  
      fun createSerialService(): BluetoothGattService {
          val service = BluetoothGattService(serialPortServiceID,
                  BluetoothGattService.SERVICE_TYPE_PRIMARY)
  
          val serialData = BluetoothGattCharacteristic(serialDataCharacteristicID,
          BluetoothGattCharacteristic.PROPERTY_WRITE,
          BluetoothGattCharacteristic.PERMISSION_WRITE)
  
          service.addCharacteristic(serialData)
  
          return service
      }
  </code></pre>
  
  <p>And here I am applying them to my server:</p>
  
  <pre><code> private fun startServer() {
          bluetoothGattServer = bluetoothManager.openGattServer(this, gattServerCallback)
  
          bluetoothGattServer?.addService(TimeProfile.createTimeService())
                  ?: Log.w(TAG, "Unable to create GATT server")
  
          bluetoothGattServer?.addService(TimeProfile.createSerialService())
                  ?: Log.w(TAG, "Unable to create GATT server")
  
          // Initialize the local UI
          updateLocalUi(System.currentTimeMillis())
      }
  </code></pre>
  
  <p>I would expect that everything would be working like before after adding the second service. But now if I try to write/subscribe to any of the characteristics (doesn't matter in which service) I just receive this:</p>
  
  <pre><code>W/BluetoothGattServer: onCharacteristicWriteRequest() no char for handle 42
  W/BluetoothGattServer: onDescriptorWriteRequest() no desc for handle 43
  </code></pre>