Skip to content

Writing to the Bluno : Null error #22

Open
@AudeGr

Description

@AudeGr

I want to add to my android project a ble bluno connection ( target sdk : 26, min sdk : 21, compile sdk : 28). I followed the demo but i had a problem with the scan (obselete?) so i found a solution, i connected directly with a paired device using the "connect" function. But now i want to write something to the bluno using the "serialSend" function and it says :
"serialSend: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothGattCharacteristic.setValue(java.lang.String)' on a null object reference"

my SerialSend function :
` public void serialSend(String theString){

	if (mConnectionState == connectionStateEnum.isConnected) {

		try{

			mSCharacteristic.setValue(theString);
			mBluetoothLeService.writeCharacteristic(mSCharacteristic);

		}catch (Exception e){

			Log.d(TAG, "serialSend: "+e.getMessage());

		}

	}

}`

The characteristic i want to write in is null and the BroadcastReceiver is never used, in my opinion the characteristic is instanced in this receiver. the BroadcastReceiver is called after the broadcastUpdate but i enter well in the 'update' function and dont in the receiver.
private void broadcastUpdate(final String action) { final Intent intent = new Intent(action.toLowerCase()); sendBroadcast(intent); }

Is it because i dont used the scan to connect my bluno or there is a problem with version or there is an other problem?

Waiting for an answer, thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions