title: Android BLE GATT Peripheral Mode Notifications
body: <p>I'm trying to set up an app to behave as a BLE peripheral device using the Android 5.0 (21) api. So far, I've set up the server, got advertising and connections working, set up custom GATT services and characteristics, and can read and write between the peripheral device and other testing devices. Now I'm trying to add notifications to a few of the parameters but simply put; they're not working.</p>
  
  <p>When defining these characteristics, they include the notify property:</p>
  
  <pre><code>BluetoothGattService battService = new BluetoothGattService(BatteryProfile.UUID_BATTERY_SERVICE, BluetoothGattService.SERVICE_TYPE_PRIMARY);
  
  BluetoothGattCharacteristic batteryLevelCharacteristic =
          new BluetoothGattCharacteristic(BatteryProfile.UUID_BATTERY_LEVEL,
                  BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY,
                  BluetoothGattCharacteristic.PERMISSION_READ);
  battService.addCharacteristic(batteryLevelCharacteristic);
  
  mGattServer.addService(battService);
  </code></pre>
  
  <p>In my <code>BluetoothGattServerCallback</code>, I included the method:</p>
  
  <pre><code>@Override
  public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
      Log.d(TAG, "Descriptor write: " + descriptor.toString());
      if (responseNeeded) {
          mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, value);
      }
      super.onDescriptorWriteRequest(device, requestId, descriptor, preparedWrite, responseNeeded, offset, value);
  }
  </code></pre>
  
  <p>which I expect to log the "Descriptor write: " message whenever a client enables notifications (or writes to any descriptor for that matter); but no such message is ever logged (nor does the debugger ever get into that function).</p>
  
  <p>I later try to send notifications using:</p>
  
  <pre><code>BluetoothGattCharacteristic batteryLevelCharacteristic = service.getCharacteristic(BatteryProfile.UUID_BATTERY_LEVEL);
  batteryLevelCharacteristic.setValue(new byte[]{ mBatteryLevel });
  mGattServer.notifyCharacteristicChanged(mConnectedDevice, batteryLevelCharacteristic, false);
  </code></pre>
  
  <p>Which, although it updates the value; it does not send a notification to the connected client.</p>
  
  <p>I've tested this using Android 6.0.1 on a Nexus 5X (unfortunately the only Android device I have available to test with). There aren't really many examples of using the peripheral / BluetoothGattServer API out there, so I'm a little lost. Is there some method I'm forgetting to call, or something I need to do in some undocumented order to get notifications to work?</p>
  
  <p>Any help would be greatly appreciated!</p>