I am developing a graphic user interface on AppDesigner with the purpose of displaying the result of a classification algorithm using data coming via MQTT protocol. The “subscribe” function (related to the “mqtt” function) requires the use of a callback to perform tasks whenever data are received. This procedure works fine when applied outside AppDesigner, while within AppDesigner it seems like the callback function is never executed. An attempt to address this issue was using global variable (see code below) but it did not work.
function StartButtonPushed(app, event)
% Connection to MQTT
mqttAddress = 'tcp://10………';
mObj = mqtt(mqttAddress,'Port',1883);
mySub = subscribe(mObj,'sensors','callback',@appCallback);
app.GoodLamp.Color = 'Green';
How can this issue be addressed?