RUI3 (RAK Unified Interface 3) - RAK4631
scheduler

Functions

bool create (char *name, RAK_TASK_HANDLER handler)
 
bool destroy (char *name)
 

Detailed Description

Function Documentation

◆ create()

bool create ( char *  name,
RAK_TASK_HANDLER  handler 
)
Description
Create a new task.
Syntax
api.system.scheduler.task.create(name, handler)
Parameters
nametask name
handlerthe handler function for this task
Returns
bool
Return values
TRUEfor creating task successfully
FALSEfor creating task failure
Example
     void handler(void *data)
     {
       Serial.printf("[%lu]This is the handler\r\n", millis());
       delay(60000);
     }
     void setup()
     {
       Serial.begin(115200);

       if (api.system.scheduler.task.create("task1", (RAK_TASK_HANDLER)handler) != true) {
         Serial.printf("Creating new task failed.\r\n");
       }
     }
     void loop()
     {
     }

◆ destroy()

bool destroy ( char *  name)
Description
Destroy an existing task.
Syntax
api.system.scheduler.task.destroy(name) api.system.scheduler.task.destroy()
Parameters
nametask name (if not specified, current thread is destroyed)
Returns
bool
Return values
TRUEfor destroying task successfully
FALSEfor destroying task failure
Example
     void handler(void *data)
     {
       Serial.printf("[%lu]This is the handler\r\n", millis());
       delay(60000);
     }
     void setup()
     {
       Serial.begin(115200);

       if (api.system.scheduler.task.create("task1", (RAK_TASK_HANDLER)handler) != true) {
         Serial.printf("Creating new task failed.\r\n");
       }
     }
     void loop()
     {
       if (millis() > 60000) {
         if (api.system.scheduler.task.destroy("task1") != true) {
           Serial.printf("Destroying existing task failed.\r\n");
         }
       }
     }