Yes, you're right there. When you do at.cmd, it'll call the function once, and if that function returns a function then it'll call that for the next line. Finally if it was still waiting for info and it hits the timeout, it'll call the function with undefined.
Only thing I'd say in your example is while it works you probably don't want to do if (!d) return callback("Error in SOMECOMMAND"); - just call the callback and don't return anything.
The reason for that one is later you might do if (d!="what_i_want") return callback("Error in SOMECOMMAND");, but then callback could return something and the AT module might still end up waiting for a response - it just could be a source of bugs.
I'd be interested to know what you have to change for SIM800 - I'd hope that we could maybe make the same module handle both devices, as I'm pretty sure people have had SIM800 working.
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.
Hi Jake,
Yes, you're right there. When you do
at.cmd
, it'll call the function once, and if that function returns a function then it'll call that for the next line. Finally if it was still waiting for info and it hits the timeout, it'll call the function withundefined
.Only thing I'd say in your example is while it works you probably don't want to do
if (!d) return callback("Error in SOMECOMMAND");
- just call the callback and don't return anything.The reason for that one is later you might do
if (d!="what_i_want") return callback("Error in SOMECOMMAND");
, but thencallback
could return something and theAT
module might still end up waiting for a response - it just could be a source of bugs.I'd be interested to know what you have to change for SIM800 - I'd hope that we could maybe make the same module handle both devices, as I'm pretty sure people have had SIM800 working.