#include <Arduino.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
// Define your task parameters structure
struct TaskParameters {
const char* param1;
const char* param2;
};
// Define your task function
void TaskFunction(void* parameters) {
// Cast the parameters back to the correct type
TaskParameters* params = (TaskParameters*)parameters;
// Access the parameters
const char* param1 = params->param1;
const char* param2 = params->param2;
// Your task code here
Serial.print("Parameter 1: ");
Serial.println(param1);
Serial.print("Parameter 2: ");
Serial.println(param2);
// Delete the task if needed
vTaskDelete(NULL);
}
void setup() {
// Your setup code here
Serial.begin(115200);
// Create the task parameters structure
TaskParameters* taskParams = new TaskParameters(); // Allocate memory for the parameters
taskParams->param1 = "Sample 1";
taskParams->param2 = "Example 2";
// Create the task and pass the parameters
xTaskCreate(
TaskFunction,
"TaskName",
10000, // Stack size in bytes
(void*)taskParams,
1, // Priority of the task
NULL // Task handle (optional)
);
}
void loop() {
// Your loop code here
}