This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Nordik UART app with Multiple service reception

I need to receive both UART Service data and HRS service data on the app.

Currently I have seen on Nordik Connect app , both the services can be found and can connect and receive data.

I need to do same with my app using nordik UART App code.

I have changed UART profile to HRS profile and code was working, i was receiving Nordik HRS service data.

But i want both services should be used and receives data. so i have prepare separate UARTService_HRS for hrs profile in the same code.also added needed changed.but it gives error null pointer exception on BLEGattService.

Please help

  • Hello,

    I faced the same problem. I am unable to get both services at a time. I have tried to get first only HRS data and it is working. Then I also tried to get UART data individually ,it is also working. But when I use both services at a time,only UART data is received. When I debug the app both services are found. But when I debug the broadcastUpdate function only one if condition get executed either UART or HRS. So, please let me know how to solve this? Thanks in advance.

  • @PriyankaB: Please capture a sniffer trace. And please check in your application if .._hvx() function (send notification) for both services are called.

  • Yes,I will capture a sniffer trace once all necessary things are available to me.

    As I debug the code,I found below function status as true:

    D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: true D/BluetoothGatt: setCharacteristicNotification() - uuid: 00002a37-0000-1000-8000-00805f9b34fb enable: true

    Is this function you are asking about?

    Or should I send you the .java file for the same through PM?

  • I mean in the nRF5 application , please check if the sd_ble_gatts_hvx() for both services are called and returned NRF_SUCCESS. Yes you can send the .java , but it would take some time to dig into your code.

  • For Android ,

    I have resolve this issue with the following code.

    BluetoothGattCharacteristic TxCharHRS = RxServiceHRS.getCharacteristic(TX_TSCHAR_UUID); Log.d("CHAR"," "+RxServiceHRS.getCharacteristics()); if (TxCharHRS == null) { showMessage("Tx charateristic not found!"); Log.d("no tx char ","Tx charateristic not found!"); broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART); return; }

                mBluetoothGatt.setCharacteristicNotification(TxCharHRS,true);
                BluetoothGattDescriptor descriptor1 = TxCharHRS.getDescriptor(CCCD);
                descriptor1.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                mBluetoothGatt.writeDescriptor(descriptor1);
    
                Thread.sleep(500);
    
    
                BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
                if (RxService == null) {
                    showMessage("Rx service not found!");
                    broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                    return;
                }
                BluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);
    
                if (TxChar == null) {
                    showMessage("Tx charateristic not found!");
                    Log.d("no tx char ","Tx charateristic not found!");
                    broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                    return;
                }
    
                mBluetoothGatt.setCharacteristicNotification(TxChar,true);
                BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
                descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                mBluetoothGatt.writeDescriptor(descriptor);
    

    only the 500ms delay got resolved my issue. but same implementation problem in iOS not working.when first service transmission and reception characteristics is ON everything (transmission and reception) is working fine,after second HRS RX characteristics ON,my first service transmission characteristics execution goes on toss. it takes delay of 2 seconds to 10 seconds for transmission happens.How to have both services and there characteristics work without delay.

Related