Hi,
I modified the basic Blink O Matic LED blinking sample code to have the imp.wakeup function call in-line. However, I get a syntax error. Also, I created a HTTP IN node and invoke the API from a HTML form I created in app engine. The form is created properly, however, the set function is not getting called in the imp.
I have been trying to figure out the issue for hours but unable to and looking for guidance from the community.
Below, I am pasting both my impee and HTML form code for guidance.
I think I am missing something simple as I get to learn how to program in impee.
impee code:
local ledState = 1;
local count = 0.1; // Blink every 100 ms
function toggle()
{
ledState = ledState?0:1;
hardware.pin1.write(ledState);
}
class BlinkInput extends InputPort
{
name = "BlinkPerSecond"
type = “float”
function set(httpValue) //ISSUE: Function set not called
{
server.show("blink variable set from webpage");
imp.wakeup(httpValue, blink() {toggle()}); //even with commenting off imp.wakeup line, function set() doesn't seem to be called
}
}
hardware.pin1.configure(DIGITAL_OUT_OD_PULLUP);
imp.configure(“BlinkBasic”, [BlinkInput()],[]);
imp.wakeup(count, blink() {toggle();});
HTTP Form Code (Form created in app engine):
Note: I have put some leading and trailing dots (…) in html tags so that the source code is retained and not processed as a html page
class InputBlinkValue(webapp2.RequestHandler):
def get(self):
self.response.out.write("""
<…html…>
<…body…>
<…form name=“form1” action=“https://api.electricimp.com/v1/4e47cd17027c48d3/3svb…” method=“post”>
<…div…>
<…h3…>IOT SETTINGS<…h3…> <…hr/…>
BLINKS PER SECOND: <..input type="text" name="value"/..><../br..>
<..input type="submit" value="Set Value"..>
<../div..>
<../form..>
<../body..>
<../html..>
..""")