$dev=array(
array('name'=>'Gdoor', 'esp_ip'=>'192.168.1.133', 'pin'=>3 ),
array('name'=>'ACunit', 'esp_ip'=>'192.168.1.133', 'pin'=>1 ),
array('name'=>'Light1', 'esp_ip'=>'192.168.1.134', 'pin'=>1 )
);
foreach ($dev as $k=>$v) {
for each device as key variable
$cmd=$_REQUEST[$dev[$k]['name']];
command request device key name
if ($cmd!='') {
if command equals
$url="http://" . $dev[$k]['esp_ip'] . "/msg?";
the attributes of http://, device, espip, /msg?
if ($cmd!='r') $url .= "pin=" . $dev[$k]['pin'] . "&";
if cmd equals r url = pin device key pin &
$url .= "stat=" . $cmd;
url equals stat command
$curl = curl_init($url);
curl equals curl initialize the url generated
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl set options curl and curl options return transfer true
$output = curl_exec($curl);
output equals curl execution of curl
curl_close($curl);
curl close curl link given
print $output;
print output of curl
}
}
Keep trying to understand the code it does not make since to me the way that I see it...
I have tried to walk myself through understanding the code and it does not look as if it would even function correctly while I am quite likely dead wrong it just don't seem right the way I read it.
I wish to store every full command in an array and then access it according to the in in coming url.
http://WANIP/ACON would be array('name'=>'ACON', 'espreq'=>'192.168.1.133/msg?pin=D5stat=1')
http://WANIP/ACOFF would be array('name'=>'ACOFF', 'espreq'=>'192.168.1.133/msg?pin=D5stat=0')
http://WANIP/READAC would be array('name'=>'ACREAD', 'espreq'=>'192.168.1.133/msg?stat=r')
I would like each thing to be allowed to execute data locally and then return the response page to the browser so it can be seen remotely!
I don't know how else to put it.
So if I request ACON remotely using the servers IP http://WANIP/ACON
what happens next:
Look for ACON as a key
if it is a key then:
Send espreq
Return the Response page from local device to the remote requester.
I believe this should likely be a little more less complex than your code possibly to me it seems as if your code is doing way too much maybe I just am having trouble with php possibly?
Thanks in advance livetv!
By the way is there any easy way to serve up php on windows to do some testing I would bet there are some local web dev programs that you could forward to port 80 or some open source project that makes this type of testing easy on windows somewhere...
Anyways hope I can grab some insight on this one before I waste too much time on it maybe it is not possible in this manner IDK I guess I lack the understanding but to me it just does not seem as if this is what the code is doing.
Where I buy my ESP8266 boards from... (Banggood)