I would make the electric imp as a web server and activate the outputs like:
http: // myelectricimp / io / out1 / on
like response in xml
<Code = " 200 " />
is it possible ?
I would make the electric imp as a web server and activate the outputs like:
http: // myelectricimp / io / out1 / on
like response in xml
<Code = " 200 " />
is it possible ?
Your imp agent has its own URL. You can POST to it from another website, or use GET to pass values in the URL. You may not always want to use GET because anyone who views your browser history will see the URL along with values you are passing to your imp.
What project are you working on … what is it supposed to do?
I want to activate the outputs of the electric imp using http request
http requests will be launched an application
thanks
Here’s an article on our Community Blog about serving web pages from an agent.
you noted that you wish to have the response in xml. You can set up all your response headers using httpresponse.header method.
hello
here is the code I used:
agent code:
`// HTTP Request handlers expect two parameters:
// request: the incoming request
// response: the response we send back to whoever made the request
function requestHandler(request, response) {
// Check if the variable led was passed into the query
if (“pin” in request.query) {
// if it was, send the value of it to the device
device.send(“pin”, request.query[“pin”]);
response.send(200, “OK”);
}
else
{
response.send(500, “Internal Server Error”);
}
}
// your agent code should only ever have ONE http.onrequest call.
http.onrequest(requestHandler);`
device code:
led <- hardware.pin1; led.configure(DIGITAL_OUT);agent.on(“pin”, function (value) {
if (value == “0”) {
led.write(0);
server.log(“pin=0”);
}else if (value == "1") { led.write(1); server.log("pin=1"); } else server.log("wrong value");
});