function receiveHandler(line) {
  var colon = line.indexOf(":\r\n");
  if (colon<0) return line; // not enough data here at the moment
  var parms = line.substring(9,colon).split(",");
  parms[1] = 0|parms[1];
  var len = line.length-(colon+3);
  if (len>=parms[1]) {
   // we have everything
   sockData[parms[0]] += line.substr(colon+3,parms[1]);
   return line.substr(colon+parms[1]+3); // return anything else
  } else { 
   // still some to get
   sockData[parms[0]] += line.substr(colon+3,len);
   return "+D,"+parms[0]+","+(parms[1]-len)+":"; // return +D so receiveHandler2 gets called next time    
  }
}
//Handle +RECEIVE input data from SIM900A
Handle +RECEIVE input data from SIM900A
Handle + RECEIVE input data from SIM900A
function receiveHandler(line) {
  var colon = line.indexOf(":\r\n");
  if (colon<0) return line; 
  var parms = line.substring(9,colon).split(",");
  parms[1] = 0|parms[1];
  var len = line.length-(colon+3);
  if (len>=parms[1]) {
   sockData[parms[0]] += line.substr(colon+3,parms[1]);
   return line.substr(colon+parms[1]+3); 
  } else { 
   sockData[parms[0]] += line.substr(colon+3,len);
   return "+D,"+parms[0]+","+(parms[1]-len)+":"; 
  }
}
function receiveHandler ( line ) { var colon = line . indexOf ( ":\r\n" ) ; if ( colon < 0 ) return line ; var parms = line . substring ( 9 , colon ) . split ( "," ) ; parms [ 1 ] = 0 | parms [ 1 ] ; var len = line . length - ( colon + 3 ) ; if ( len >= parms [ 1 ] ) { sockData [ parms [ 0 ] ] += line . substr ( colon + 3 , parms [ 1 ] ) ; return line . substr ( colon + parms [ 1 ] + 3 ) ; } else { sockData [ parms [ 0 ] ] += line . substr ( colon + 3 , len ) ; return "+D," + parms [ 0 ] + "," + ( parms [ 1 ] - len ) + ":" ; } }
Handle +RECEIVE input data from SIM900A
Handle + RECEIVE input data from SIM900A
// not enough data here at the moment // we have everything // return anything else // still some to get // return +D so receiveHandler2 gets called next time    