You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Ok, well you can test in a controlled manner using the Loopback like this:

    var at = require("AT").connect(LoopbackA);
    at.registerLine('1, CLOSED', function() {
      console.log("I got called");
    });
    at.debug();
    
    LoopbackB.write("\r\n1, CLOSED\r\n");
    

    Now that actually works, so I think you have some other problem there.

    However the following doesn't:

    var at = require("AT").connect(LoopbackA);
    at.register("> ", function(x) {
      console.log("HANDLER: "+JSON.stringify(x));
      return "";
    });
    at.debug();
    
    LoopbackB.write("\r");
    setTimeout(function() {
      LoopbackB.write("\n> ");
    },100);
    

    That was an issue with the AT module, which I've just updated and fixed.

    But your other issue ("\r\n>" then " ") was actually the same as the one that was stopping ">" from working a week ago. It should be fixed if you're using an up to date build from GitHub (I fixed it last week), but I guess yours might be older?

    If you want to fix it on the existing firmware, you just need to register a handler for ">" without the space. Then you handle the check for the space yourself:

    var at = require("AT").connect(LoopbackA);
    at.register(">", function(x) {
      if (x.substr(0,2)=="> ") {
        console.log("HANDLER: "+JSON.stringify(x));
        return "";
      } else return x;
    });
    at.debug();
    
    LoopbackB.write("\r\n>");
    setTimeout(function() {
      LoopbackB.write(" ");
    },100);
    
About

Avatar for Gordon @Gordon started