%% Callback function to send Acknowledgement
% This callback function sends an acknowledgement string back to the udpport instance on the first MATLAB instance, when it received the data.

function sendAcknowledgement(u, ~)
% Read the data received from the other udpport instance. readline removes
% the terminator from the data read.
data = readline(u);

% Prepare the acknowledgement string.
data = "COMMAND RECEIVED - """ + data +  """. SENDING ACKNOWLEDGEMENT.";

% Send the acknowledgement string, followed by the Terminator "CR/LF", to the
% udpport instance bound to port 3030 in the first MATLAB instance.
writeline(u, data, "127.0.0.1", 3030);
end