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
  • 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.

Reply
  • 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.

Children
No Data
Related