Hi Sheikh
Based on my understanding, you would like to call the "TimerFcn" callback function periodically. Inside this callback function you would like to get data from database and send a "response" to the system based on the provided conditions.
For achieving the above requirement, please follow the below steps:
- Create a function, say, "TimerFun".
- Inside this function, write the code for reading the data from database and the code for sending the "response" of "ON" or "OFF" to the system.
- Inside the "timer" object, create a function handle for the function "TimerFun" and pass it as argument to 'TimerFcn' option.
Let us assume the "TimerFun" callback function is defined as below,
function TimerFun(url, opts, api, sensorlist)
...
end
The function handle for this function will look something like this:
{@TimerFun, url, opts, api, sensorlist}
Please refer to the following documentation for more information on:
- Function handle: https://www.mathworks.com/help/matlab/matlab_prog/creating-a-function-handle.html
- Timer Callback Functions: https://www.mathworks.com/help/matlab/matlab_prog/timer-callback-functions.html
- timer: https://www.mathworks.com/help/matlab/ref/timer.html
I hope this helps.
Regards
Binaya