On the positive side I got the mute working. Only problem is, that the script is in the activity and the mute on/off went beserk - that was expected though. Now I have this page script:
getCurrent()
function getCurrent(){
if (socket.connected == true){
socket.write("MU?\r");
}else{
scheduleAfter(1000,getCurrent)
}
}
and this activity script:
ConnectionSetup()
function ConnectionSetup(){
socket = new TCPSocket(false);
socket.connect(CF.widget("IP", "Settings").label,23,3000);
socket.onConnect=onConnect;
socket.onData=onData;
socket.onIOError=onIOError;
socket.onClose=onClose;
}
function onConnect()
{
CF.activity().label = CF.page().label ;
};
function onData()
{
myString = socket.read()
if(CF.page().label == "test page"){
ViewInputs(myString)
}
}
function onClose()
{
CF.activity().label = "Connection Closed";
scheduleAfter(5000,ConnectionSetup);
};
function onIOError()
{
CF.activity().label = "Connection Failed";
scheduleAfter(5000,ConnectionSetup);
};
function ViewInputs(sString){
var tmpString;
var aResults = sString.split(String.fromCharCode(13));
var i;
for (i=0; i<aResults.length; i++){
tmpString = aResults[i]
//CF.widget("AmpStatus").label = CF.widget("AmpStatus").label + "\n" + "->" +"{ "+aResults[i].substr(0,2)+" } " +aResults[i].substr(2) + "\n" + isNaN(aResults[i].substr(2))
if(tmpString == "MUON"){
socket.write("MUOFF\r");
}else if(tmpString == "MUOFF"){
socket.write("MUON\r");
}
}
}
how do I turn the last part of the activity into a button script?