1

I'm trying to send a notification from a Tizen watch Wearable App (peripheral device as server) to an Android Smartphone App (central device as client). But I got an error when sending the notification from the wearable App.

In tizen Wearable App (using .net API) I send the notification like this :

string remoteDeviceAddress = "10:C7:53:50:C4:E5";
server.SendNotification(charc, remoteDeviceAddress);

Which raise the error below :

11-25 10:46:05.969  Error   8874    8874    CAPI_NETWORK_BLUETOOTH  bluetooth-gatt.c: bt_gatt_server_notify_characteristic_changed_value(2964) > [bt_gatt_server_notify_characteristic_changed_value] INVALID_PARAMETER(0callback=NULL)

11-25 17:20:18.225  Error   15042   15042   Tizen.Network.Bluetooth BluetoothGattImpl.cs: SendNotification(113) > Failed to send value changed notification for characteristic uuid 00000002-1000-2000-3000-111122223333, err: InvalidParameter

In Android App side, I subscribe to notifications as below :

mBluetoothGatt.setCharacteristicNotification(characteristic, true);

BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                    UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);

I don't understand why this error is raised. I checked that :

  • the Android client device is connected to the BLE watch device.
  • the Gatt service exposed by the Gatt server App is find by the client App.
  • the remote device bluetooth address of the watch device is exactly that is display by Android in bluetooth settings.

The error seems to mean that the .net API call the native API function bt_gatt_server_notify_characteristic_changed_value() which expect a callback but the .net API method SendNotification() does not require a such callback in its specifications as here API specifications

Does anyone has an idea why the error above is raised ?

Thanks in advance !

Yann31
  • 11
  • 1

2 Answers2

1

Maybe, the sequence is not proper or,, the value is not changed.

Can you follow next step for it?

1) Register notification state changed callback (On GATT server side) -> Using this (charc.NotificationStateChanged += Charc_NotificationStateChanged;) 2) Enable the notification (On GATT client side) 3) After receiving "NotificationStateChanged" event a) Change the value (charc.SetValue(_valueChanged);) b) Calls SendIndicationAsync (_server.SendIndicationAsync(charc, null);)

You can refer this procedure in next URL. (public async Task ClientAddress_PROPERTY_READ_ONLY() function) https://review.tizen.org/gerrit/gitweb?p=test/tct/csharp/api.git;a=blob;f=tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationSentEventArg.cs;h=10a88576e7c86fc49d88490a83489aa8f92b2460;hb=refs/heads/tizen

                EventHandler<NotificationSentEventArg> Server_NotificationSent = null;

            Server_NotificationSent = (sender, e) => {
                _server.NotificationSent -= Server_NotificationSent;
                Assert.IsNotNull(e.ClientAddress, "[TestCase][ClientAddress_PROPERTY_READ_ONLY] Failed");
                Assert.IsInstanceOf<string>(e.ClientAddress, "[TestCase][ClientAddress_PROPERTY_READ_ONLY] Failed");
                BluetoothHelper.DisplayPassLabel("ClientAddress_PROPERTY_READ_ONLY");
            };

            EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;

            Charc_NotificationStateChanged = (sender, e) => {
                try
                {
                    Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
                    _server.NotificationSent += Server_NotificationSent;

                    origin_val = charc.GetValue(0);
                    charc.SetValue(_valueChanged);
                    _server.SendIndicationAsync(charc, null);

                    charc.SetValue(origin_val);
                }
                catch (Exception ex)
                {
                    Assert.Fail("[TestCase][ClientAddress_PROPERTY_READ_ONLY] FAIL " + ex.Message);
                }
            };

            srv = _server.GetService(_svcUuid);
            charc = srv.GetCharacteristic(_charUuid);

            charc.NotificationStateChanged += Charc_NotificationStateChanged;
DoHyun Pyun
  • 146
  • 2
0

Can you use "SendIndicationAsync" method instead of SendNotification?

Ex)

server.SendIndicationAsync(charc, null);

DoHyun Pyun
  • 146
  • 2
  • I tryed but nothing is received in the client side. I only get this on the server app side in logs : 11-26 15:17:52.249 Info 11804 11804 BLUETOOTH_FRWK_SERVICE bt-service-event-receiver.c: __bt_gatt_char_property_changed_event(1850) > Notifying is enabled – Yann31 Nov 26 '19 at 13:38
  • I mean the method onCharacteristicChanged() is never called on client side after the call of server.SendIndicationAsync(charc, null) on server side. – Yann31 Nov 26 '19 at 14:03