Can someone verify my understanding of the AT module is correct. It looks like it will continue to call your callback that you pass to the at.cmd for each line of data it encounters until the timeout occurs which then it calls your callback with no params. Is that a correct view? If so, does this pseudo code work for dealing with a multi-line response from an at cmd where you are looking for a certain response.
var somInitFunc = function(callback){
//This will get called for each line of data. If we return a func it will continue to be called
//for each line. On timeout, it will get called with no params.
var myLineCallback = function(d){
if(!d){
return callback("Error in SOMECOMMAND");
}
if(d === 'ANSWER I WANT'){
//got a success keep going
} else {
//just return self b/c we can get multiple lines of extraneous responses from this cmd
return myLineCallback;
}
};
//This command returns multiple lines of data that we need to handle.
at.cmd('AT+SOMECOMMAND\r\n', 1000, myLineCallback);
};
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Can someone verify my understanding of the AT module is correct. It looks like it will continue to call your callback that you pass to the at.cmd for each line of data it encounters until the timeout occurs which then it calls your callback with no params. Is that a correct view? If so, does this pseudo code work for dealing with a multi-line response from an at cmd where you are looking for a certain response.