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

  • yes it is getting. I have debugged the code. service object get initialised.

  • If the service object is returned, have you check which characteristics are belong to that service ? You can call RxServiceHRS.getCharacteristics() to get the list.

    One thing I noticed from your code, you call :

      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;
            }
    

    Shouldn't it be:

      BluetoothGattCharacteristic TxCharHRS = RxServiceHRS.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;
            }
    

    RxServiceHRS instead of RxService ?

  • yes , i have told already before your first comment. i have changed that code and replaced RxService by RxServiceHRS , so now it initialise service but now i had debug the code, i got both separate services and their own characteristics but still cant get TxCharHRS read

  • sorry but that comment is not updated. but i have thanks and i thought it is solved only because of null service it has problem

  • public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { if (status == BluetoothGatt.GATT_SUCCESS) { broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic); ListServices = gatt.getServices(); // gatt.readCharacteristic(chars.get(chars.size()-1)); gatt.readCharacteristic(Services.get(2).getCharacteristics().get(0)); gatt.readCharacteristic(Services.get(3).getCharacteristics().get(0)); //gatt.readCharacteristic(services.get(1).getCharacteristics().get(2)); // chars.remove(chars.get(chars.size()-1)); // if (chars.size() > 0) { // gatt.readCharacteristic(chars.get(chars.size()-1)); // } else { // gatt.disconnect(); // }

      }
      }
    

    I have tried to get read, but still is display some alohanumeric value. actually it should display byte array

Related