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

Parents
  • I need UART Service and HRS service both data at a same time. to get UART profile data, i have accessed service and characteristics in enableTXNotification() function in UARTService.java I have same tried with HRS profile in same function , but it is not working.

    sample code below:

    public void enableTXNotification()
        {
            try {
            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);
    
            BluetoothGattService RxServiceHRS = mBluetoothGatt.getService(RX_TSSERVICE_UUID);
            if (RxServiceHRS == null) {
                showMessage("Rx service not found!");
                broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                return;
            }
            BluetoothGattCharacteristic TxCharHRS = RxService.getCharacteristic(RX_TSCHAR_UUID);
            if (TxCharHRS == null) {
                showMessage("Tx charateristic not found!");
                Log.d("no tx char ","Tx charateristic not found!");
                broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                return;
            }
    
Reply
  • I need UART Service and HRS service both data at a same time. to get UART profile data, i have accessed service and characteristics in enableTXNotification() function in UARTService.java I have same tried with HRS profile in same function , but it is not working.

    sample code below:

    public void enableTXNotification()
        {
            try {
            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);
    
            BluetoothGattService RxServiceHRS = mBluetoothGatt.getService(RX_TSSERVICE_UUID);
            if (RxServiceHRS == null) {
                showMessage("Rx service not found!");
                broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                return;
            }
            BluetoothGattCharacteristic TxCharHRS = RxService.getCharacteristic(RX_TSCHAR_UUID);
            if (TxCharHRS == null) {
                showMessage("Tx charateristic not found!");
                Log.d("no tx char ","Tx charateristic not found!");
                broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
                return;
            }
    
Children
No Data
Related