Agent.send/device.on issue

I have taken the sample code that is provided by Xively with the electric imp and for some reason I believe either the agent.send is having issues or the device.on is. It was working fine a few hours ago but I don’t know what I did to get this problem.

I have already tried to use the same code as the example and it still does not work. I have also tried to just use only the agent.send and the device.on but it still doesn’t work. I want to believe it is a hardware problem now.

Something else that happened before this problem was that I used up all the mem in the imp which crashed and reset the imp. Not sure if this matters or not but maybe it does.

Here is the agent code:

function get_xively() {
imp.wakeup(30.0, get_xively); //schedule when to wakeup again

local xively_url = "" + FEED_ID + ".json";      //format xively url
local getreq = http.get(xively_url, {"X-ApiKey":API_KEY, "User-Agent":"xively-Imp-Lib/1.0"});       //add headers
local res = getreq.sendsync();      //actuallty send request
if(res.statuscode != 200) {
    server.log("error sending message: " + res.body);
server.log(res.statuscode + " OK");     //status
server.log(res.body);                   //body

device.send("json", res.body);     //send json

get_xively(); //initialize first get request. will continue to call itself.
function send_xively(body) { //take in csv value
local xively_url = “” + FEED_ID + “.csv”; //setup url for csv
server.log(body); //pring body for testing
local req = http.put(xively_url, {“X-ApiKey”:API_KEY, “Content-Type”:“text/csv”, “User-Agent”:“xively-Imp-Lib/1.0”}, body); //add headers
local res = req.sendsync(); //send request
if(res.statuscode != 200) {
server.log("error sending message: “+res.body);
}else device.send(“status”, (res.statuscode + " OK”)); //sends status to uart. this can be removed if not desired

device.on(“data”, function(feedCSV) { //take csv body in from device
server.log(“device on”);

//send preformatted multi-ds csv
send_xively(feedCSV);         //send to function to call xively


Here is the device code:
local index = 0;
local masterUART = array(100); //serial buffer
//these should be changed to non character values
local startbit = 124; //which is |
local endbit = 126; //which is ~
//uart initialization
function startUART()
hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS); //baud:19200, dataBits:8, parity, stopbit
function checkUART()
imp.wakeup(0.001, checkUART.bindenv(this));

local byte =;    //read uart 

while (byte != -1)  
    if(byte == endbit){     //check if endbit
        local startint = masterUART.find(startbit);     //find startbit
        if(startint != null){   
            local fullTrans = masterUART.slice((startint + 1),index);   //slice transmission from checkbits
            local transString = "";
            for(local a=0;a<fullTrans.len();a++){   //convert char array to string
                transString = transString + format("%c",fullTrans[a]); 
            agent.send("data", transString);    //send string to agent
            index = 0;
        }else server.log("UART ERROR");
    }else{  //if not endbit, add byte to array
        index ++;
    byte =;         

agent.on(“json”, function(value) { //receive data from agent
server.log(“agent is on”);
//server.log(value); //uncomment to print the data first


" + value); //write data to UART
agent.on(“status”, function(code) { //this functions send the xively put status code to serial port.
server.log(“agent is on”);
" + code);
imp.configure(“Xively UART”, [], []); //standard imp configure statement
startUART(); //setup uart
checkUART(); //begin uart polling

There seems to be an issue with device to agent coms. Myself and others are having issues

Thanks for letting me know. I was about to buy another imp for my project that I have to demo tomorrow. I hope everything is fine in a few hours.

This issue affected one server but nobody had been paged when the issue occurred; we have since closed the hole in our automatic monitoring so this should not happen again. The production servers (for commercial devices) were not affected.

Sorry for the inconvenience!