1 minute agent update?

If I send a value from http request to imp via agent, it only updates once a minute.

Agent code:

responses <- []

http.onrequest(function(req, res) {
local val = -1
if(“led” in req.query) {
val = req.query.led
device.send(“ping”, val)

Device code:

// DMX Controller

dmxoutput <- hardware.uart57;
dmxoutput.configure(250000, 8, PARITY_NONE, 2, NO_CTSRTS);

// build up a static 512-device DMX frame
local outBlob = blob(12);

// populate the blob with null data
for (local i = 0; i < 12; i++) {
outBlob.writen(0x00, ‘b’);

function refresh() {
hardware.pin2.write(0); // manually send out the break and mark-after-break
imp.wakeup(0.001, refresh);

agent.on(“ping”, function(data) {
outBlob.writen(data, ‘b’);
server.log(“led on”);

imp.configure(“DMX Controller”,[],[]);


When I open a browser and make the http change at the end with the desired led level ( /?led=0 thru 255), it will only update once a minute; ie. the IDE server log shows the “led on” response once a minute, no matter how fast I update the http query.

Any ideas?
Thanks in advance!

you’re not sending a http response back, so the browser keeps waiting for that, until it times out (after a minute). if you’re not interested in a response, but just accepting commmands from a browser (or phone app), you don’t need to stack the response objects, just reply with a 200 status immediately. like so:
http.onrequest(function(req, res) { res.send(200, "OK") if("led" in req.query) { device.send("ping", req.query.led) } })
you don’t need the responses array, and you also don’t need to ping your device if there is no valid data.