This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to terminate "Scheduled Task" on receiving "BLE Disconnection Event"

Dear All,

I am using "Scheduler" module as mentioned in this tutorial Scheduler Tutorial.

I have one question.  My scheduler tasks are using some SD functions which require to have "Valid BLE connection". These tasks are put in the queue as soon as the connection is made and the tasks start executing. Some of the tasks are pretty time consuming involving sending kBs of data to the connected client through notification.

A single task may contain several long sub-tasks all of which may require valid BLE connection.

Now, my problem is "How to terminate the ongoing task as soon as the connection is broken". Is there a way to terminate the queued tasks on receiving "Disconnection event".

One possible solution can be to check Error Code of "Each and every" sub-task to see if it returns "Invalid Connection handle" and terminate the task. But this may make my code messy.

Can you please tell me an elegant way to do it?

Parents Reply Children
No Data
Related