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

  • No we don't have code with UART and other service at the same time. Please follow the steps I stated above and let me know at which step you have an issue ? I assume at step 3 ? Please try to capture the sniffer trace.

  • You are not understanding our problem. We are facing problem at multiple reception. while receiving HRS data , no characteristics found on broadcast Update to read value. only UART Service characteristics are identified and can read value. is that ok with broadcastUpdate funtion we have written? is there is missing in onCharacteristicsRead function? is there is another mService object require to read other service? i will see sniffer details and try to test and give details. but i think the problem must be in coding.

  • To really solve the problem you need to understand how the code works. And it should be noted that, we, Nordic, don't make Bluetooth API on Android, we only make the chip and the Bluetooth stack on it, not on Android.

    The Android apps we provide is just a reference to help you. You still need to dig in, study and understand how Android Bluetooth api works.

    For sure it's the issue with the coding not the hardware /stack issue, I requested the sniffer to understand what could be wrong with your code.

    I kept asked you if you write to CCCD for HRM characterstic or not , but you never answered. This part should be called for your HRS characteristic:

            mBluetoothGatt.setCharacteristicNotification(TxChar,true);
            BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            mBluetoothGatt.writeDescriptor(descriptor);
    

    Please post your code, full code.

  • Yes sir, I have given you details of enableTXNotification function. there i have updated above CCCD code for HRS profile, i will rewrite here,

    public static final UUID CCCDTS = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
    
    BluetoothGattService RxServiceHRS = mBluetoothGatt.getService(RX_TSSERVICE_UUID);
            if (RxServiceHRS == null) {
                showMessage("Rx service not found!");
                broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                return;
            }
            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(CCCDTS);
                descriptor1.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                mBluetoothGatt.writeDescriptor(descriptor1);
    

    I am working on sniffer , to get some details to post. but when i debug above code, all variable RxserviceHRS, TxcharTS initialises. notification will be enabled. but still in broadcastUpdate function characteristics UUID do not match with TxcharHRS UUID. because all time UART Txchar UUID data is available.

  • Hi Shrikant,

    Please post your full code, whole project. If you don't want the code be confidential please send it via PM or open a support case in "My Page" on our website.

    You need to enable CCCD before you can receive any notification. This could be the reason why you don't receive any HRS characteristic in broadcastUpdate. BroadcastUpdate is called when there is a change in characteristic, and if you don't enable CCCD (the code I posted above) , there will be no change can be notify.

Related