Skip to content

WriteRequest Split : cancelCurrent don't stop sending packets #594

Description

@rlebranchu

Hello,

I'm having a problem cancelling a executing split WriteRequest.
The sending of the packets is not stopped.

I think this is because WriteRequest.hasMore() (in BleManagerHandler.onCharacteristicWrite) will always return the next packet.
If we add this following function to the WriteRequest class :

/**
 * Cancel split WriteRequest during sending packets (called by BleManagerHandler.cancelCurrent function)
 * This will block hasMore function called by BleManagerHandler.onCharacteristicWrite function
 */
void cancel() {
	complete = true;
}

And call it it BleManagerHandler.cancelCurrent function (after notifyFail of TimeoutableRequest)

if (request instanceof final TimeoutableRequest r) {
	r.notifyFail(device, FailCallback.REASON_CANCELLED);
} else if(request instanceof final WriteRequest r) {
	r.cancel();
}

So when WriteRequest.hasMore() is called, the ‘complete’ variable will be set to true and so will not return the next packet (and will not send the next packet).

(I tried to test locally with a fork but Execution failed for task ':ble:signReleasePublication'. error fail publication)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions