This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf52 (sdk2.0 v11) alert notification and android gatt server

Hi.

I've played around with the android application (based around google gatt example, but used in gatt server -mode).

How is the example expected to be handled? In proper central mode the nrf would do the scanning and connecting and android would be the peripheral and just host the gatt server (with Alert notification service + necessary characteristics) and advertise.

However as the nrf needs to be scanned by the android device, I first connect the device via regular gatt. At this point I've already opened gatt server connection and registered callback to it. I've also created the service and added characteristics to it and added those to gatt server. I also got onServiceAdded-callsto my BluetoothGattServerCallback.

After connection call I can get onConnectionStateChanged - and onCharacteristicRead -calls to BluetoothGattServerCallback. However if I try to write to said characteristic or do notify call, I can see no response on the nrf device. I've enabled read&write&notify priviledges on the characteristics and also I have enabled all notifications from the control point characteristic.

log from terminal:

[DB]: Discovery of service with UUID 0x1811 completed with success for Connectionhandle 0
[ANS] Found supported new alert category 
[ANS] Found New Alert 
[ANS] Found supported unread alert category 
[ANS] Found Unread Alert 
[ANS] Found Ctrlpt 
hox evt  
hox ansc disco
[main] alert_ns
[ANS] ble_event
[ANS] ...default id: 51
[ANS] ble_event
[ANS] ...read rsp
[ANS] read_rsp len 5
hox evt
hox read resp
[ANS] ble_event
[ANS] ...read rsp
[ANS] read_rsp len 5
hox evt
hox read resp
[ANS] ble_event
[ANS] ...default id: 18
[ANS] ble_event
[ANS] ...default id: 58
[ANS] ble_event
[ANS] ...disconnected
hox evt
hox disco comp
[ANS] ble_event
[ANS] ...default id: 27

Android side:

 04-08 17:00:23.571 BluetoothLeService: onServiceAdded
 04-08 17:00:23.577 BluetoothGatt: onClientRegistered() - status=0 clientIf=11
 04-08 17:00:23.644 BluetoothGattServer: onServerConnectionState() - status=0 serverIf=6 device=CE:CE:67:C2:71:FE
 04-08 17:00:23.644 BluetoothLeService: onConnectionStateChage device CE:CE:67:C2:71:FE
 04-08 17:00:23.645 BluetoothGattServer: onServerConnectionState() - status=0 serverIf=7 device=CE:CE:67:C2:71:FE
 04-08 17:00:23.645 BluetoothLeService: onConnectionStateChage device CE:CE:67:C2:71:FE
 04-08 17:00:23.646 BluetoothGattServer: onServerConnectionState() - status=0 serverIf=8 device=CE:CE:67:C2:71:FE
 04-08 17:00:23.646 BluetoothLeService: onConnectionStateChage device CE:CE:67:C2:71:FE
 04-08 17:00:23.647 BluetoothGattServer: onServerConnectionState() - status=0 serverIf=9 device=CE:CE:67:C2:71:FE
 04-08 17:00:23.647 BluetoothLeService: onConnectionStateChage device CE:CE:67:C2:71:FE
 04-08 17:00:23.662 BluetoothGattServer: onServerConnectionState() - status=0 serverIf=10 device=CE:CE:67:C2:71:FE
 04-08 17:00:23.662 /BluetoothLeService: onConnectionStateChage device CE:CE:67:C2:71:FE
 04-08 17:00:23.663 BluetoothGatt: onClientConnectionState() - status=0 clientIf=11 device=CE:CE:67:C2:71:FE
 04-08 17:00:23.663 BluetoothGatt: onConnectionStateChange
 04-08 17:00:23.663 BluetoothGatt: status connected
 04-08 17:00:23.663 BluetoothGatt: discoverServices() - device: CE:CE:67:C2:71:FE
 04-08 17:00:23.671 BluetoothGatt: onSearchComplete() = Device=CE:CE:67:C2:71:FE Status=0
 04-08 17:00:23.691 Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2ebcc89a time:102305919
 04-08 17:00:24.132 BluetoothLeService: onCharacteristicReadRequest UUID: 00002a47-0000-1000-8000-00805f9b34fb from device: CE:CE:67:C2:71:FE
 04-08 17:00:24.224 BluetoothLeService: onCharacteristicReadRequest UUID: 00002a48-0000-1000-8000-00805f9b34fb from device: CE:CE:67:C2:71:FE
 04-08 17:00:24.322 /BluetoothLeService: ondescriptorwriterequest UUID: 00002902-0000-1000-8000-00805f9b34fbValue: 1
 04-08 17:00:24.322 BluetoothLeService: sending nofication!

I checked the ans callback values from softdevice header, and they seem to be reporting non-faulty statuses (and pardon the traces I've added there).

Ideas where to go from here? There isn't really many examples on this sorf of usecase, altough the notifications from android to embedded device is quite used usecase.

Parents
  • Hi Matts,

    It's a little bit unclear for me on what you did on the nRF52 side. Did you do service discovery, and when you have the characteristic's handle ID, did you do a write to the CCCD to enable notification ?

    Note that there is no nCharacteristicRead event with BluetoothGattServerCallback.

    Have you called notifyCharacteristicChanged() from Android to start sending notification ?

Reply
  • Hi Matts,

    It's a little bit unclear for me on what you did on the nRF52 side. Did you do service discovery, and when you have the characteristic's handle ID, did you do a write to the CCCD to enable notification ?

    Note that there is no nCharacteristicRead event with BluetoothGattServerCallback.

    Have you called notifyCharacteristicChanged() from Android to start sending notification ?

Children
No Data
Related