I have written an ‘app’ for my android phone which success fully turns an LED on and off using HTTP-IN, but how can I return a value. The value could be an acknowledge. My ‘app’ having sent the on/off string waits for a response.
Thanks.
I have written an ‘app’ for my android phone which success fully turns an LED on and off using HTTP-IN, but how can I return a value. The value could be an acknowledge. My ‘app’ having sent the on/off string waits for a response.
Thanks.
List your imp code here.
And a screenshot of your planner might be nice too.
The imp code is as follows and I have attached a copy of the planner screen.
// input class for Power control channel (from HTML IN)
class power_input extends InputPort
{
name = “Power On”
type = “number”
function set(value)
{
// update the display
server.show("Power On!");
// set the power pin to whatever was passed in above, on or off, we don't care at this point
hardware.pin9.write(1);
}
}
// input class for Brew control channel (from other HTML IN)
class power_off extends InputPort
{
name = “Power Off”
type = “number”
function set(value)
{
// update display
server.show("Power Off");
hardware.pin9.write(0);
}
}
// Configure pin 9 as an open drain output with internal pull up (Power)
hardware.pin9.configure(DIGITAL_OUT_OD_PULLUP);
// Register with the server , passing our two inputs as an array
imp.configure(“Coffee Web”, [power_input(), power_off()], []);
your acknowledge comes in the android part.
you need to do something like:
DefaultHttpClient httpClient; .... HttpResponse response = httpClient.execute(.....); then you check: int ret = response.getStatusLine().getStatusCode(); if (ret == HttpStatus.SC_OK) { .. }
Thanks
I already have the response routine in my android software, what I need to know is how to send the imp code. In other words, when I receive the response into HTTP IN, and light my LED, how can I send back a value, from the imp code to gthe android app.
You want to export variables or data from imp/squirrel outside.
that can be done with agents, a new feature coming soon
When will agents be available?
The plan is by the end of this month for all users.