API for Development


#1

Hello,

Do you have any information on how the AJAX and Wiz550Web interact? I am using your demo pages and editing them but trial and error is a slow proccess. I was hoping that you had some documentation that explains the the interaction.

Thanks!


#2

Hi.

Sorry… We not have AJAX information documents…

Web have just simple documents.

refer to below URL. It is simple document. (web page)

wizwiki.net/wiki/doku.php?id=pro … 0webgsg_en

And refer to below URL. It is web page download URL.

github.com/Wiznet/WIZ550web

Thank you


#3

Hi,

Thanks for your reply. Since there is no information on how your application works, I was hoping that you could answer a few questions for me?

  1. I am having trouble doing things sequentially and I think it is due to timing. When I execute the code pasted below, not all of the I/O change as expected, and I get a debug error in my browser (Chrome) console that says:

(index):265 POST 192.168.11.100/dout.cgi net::ERR_CONNECTION_REFUSED
AJAX.doPost @ (index):265
(anonymous function) @ (index):390

I was also wondering how I can check the state of a pin, whether or not is is Hi or low?

Thanks!

function postdataPinState(pinNumber,pinState){
var p=pinNumber;
var v = pinState;
dout_timer=setTimeout(function(){
if(dout && dout.abort){dout.abort();}
dout=new AJAX(‘dout.cgi’,function(t){
try{eval(t);}catch(e){alert(e);}
});
dout.doPost(‘pin=’+p+’&val=’+v);
},300);
}

function postdataPinDir(pinNumber,pinDirection){
var p=pinNumber;
var v = pinDirection;
dout_timer=setTimeout(function(){
if(dout && dout.abort){dout.abort();}
dout=new AJAX(‘dir_change.cgi’,function(t){
try{eval(t);}catch(e){alert(e);console.log(t);}
});
dout.doPost(‘pin=’+p+’&dir=’+v);
},300);
}

function myDelay(myDelayTime){

for(var i=0; i<myDelayTime;){
i++;
}
}

function setAddrToVersion(){

postdataPinState(10,0);
postdataPinState(11,0);
postdataPinState(12,0);
postdataPinState(13,0);

}

function setDataBusToInput(){

postdataPinDir(0,1);
myDelay(1000);
    postdataPinDir(1,1);
myDelay(1000);
postdataPinDir(2,1);
myDelay(1000);
    postdataPinDir(3,1);
myDelay(1000);
postdataPinDir(4,1);
myDelay(1000);
postdataPinDir(5,1);
myDelay(1000);
postdataPinDir(6,1);
myDelay(1000);
postdataPinDir(7,1);

}
function setDataBusToOutput(){

postdataPinDir(0,2);
myDelay(1000);
    postdataPinDir(1,2);
myDelay(1000);
postdataPinDir(2,2);
myDelay(1000);
    postdataPinDir(3,2);
myDelay(1000);
postdataPinDir(4,2);
myDelay(1000);
postdataPinDir(5,2);
myDelay(1000);
postdataPinDir(6,2);
myDelay(1000);
postdataPinDir(7,2);

}

function getRevisionNum(){

setTimeout(setDataBusToInput(),1500*1);

setAddrToVersion();

//setDataBusToOutput();

}


#4

Hi,

I would also like to know how to read the status of an actual pin without having to check the html alias/name.

Thanks!


#5

Nevermind… as if you were actually working on it.

There are two ways to do what I wanted.

  1. use JQuery and the when() then() methods

  2. simply make ajax synchronus (this is what I used)

function AJAX(url, callback)
{
var req = AJAX_init();
req.onreadystatechange = AJAX_processRequest;

 function AJAX_init() { 
	 if (window.XMLHttpRequest) { 
	 	return new XMLHttpRequest(); 
	 } else if (window.ActiveXObject) { 
	 	return new ActiveXObject('Microsoft.XMLHTTP'); 
	 } 
 };
  
 function AJAX_processRequest() { 
	 if(req.readyState == 4) { 
	 	if(req.status == 200) { 
	 	if(callback) 
	 		callback(req.responseText); 
	 	} 
	 } 
 }; 
 
 this.doGet = function() { 
	 req.open('GET', url, false); // set this to false for synchronous behavior
	 req.send(null); 
 };
  
 this.doPost = function(body) { 
	 req.open('POST', url, false); // set this to false for synchronous behavior
	 req.setRequestHeader('Content-Type', 
	 'application/x-www-form-urlencoded'); 
	 req.setRequestHeader('ISAJAX','yes'); 
	 req.send(body); 
 }; 

};