GPRS or Edge Howto?

Posted on
Page
of 4
First Prev
/ 4
  • maybe by extending the features of the AT lib?

  • I'm not sure the issue is quite as simple as that. If you look at the AT module code responsible it would appear to be doing the right thing...

    It looks to me like it copes with the cases where the line starts with \r or \n. But I'll do some tests and will let you know

  • Yes this is as well part of the problem. My close handlers are not getting called if the line starts with \r\n or \r or \n. See here:

    var handler = function(d) {
            var s;
            if(d === 'OK') {
              s = sckt;
              at.registerLine(s + ', CONNECT OK', function() {
                at.unregister(s + ', CONNECT OK');
                socks[s] = true;
              });
              at.registerLine(s + ', CLOSED', function() {
                at.unregisterLine(s + ', CLOSED');
                socks[s] = undefined;
              });
            }
          }; 
          at.cmd('AT+CIPSTART='+sckt+',"TCP",'+JSO­N.stringify(host)+','+port+'\r\n', 10000, handler);
    

    This unfortunately happens sometimes, for example a few seconds ago I had the situation:

    ] "\r\n1, CLOSED\r\n" <--- "\r\n1, CLOSED\r\n"
    

    The close handler has not been called here :(

  • 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);
    
  • The new AT lib did it! Thank you so much Gordon! It works much more stable now. I'll test it tomorrow intensively.

  • It is working well without any changes being necessary in the driver I uploaded here a few days ago. So you can use it as module. As well if someone else needs help regarding the SIM900 hardware I will of course help to get it running.

  • That's great, thanks! I plan to come up with a page on the Espruino website for it soon!

  • @Gordon : I have to say thank you for the great support!

  • No problem - glad you got it working - and thanks for getting stuck in and actually making the module in the first place!

    It's something I should have done myself, but I now have 2 GSM modules, neither of which seem to be able to get a signal!

  • Hey Guys - I'm new to IoT but am working on a project that needs to connect to cellular data as it will be a mobile type device. Did this thread end up with the ability to use GPRS data using the SIM900 hardware?

    Thanks for helping a n00b get his feet wet!

  • Yes, absolutely! There's a page with some information on how to do it here: http://www.espruino.com/SIM900

    It's pretty easy - you just need to ensure the GSM module has a good power supply, and that you know your mobile carrier's access point details (it's easy enough to google).

    If you've got other questions it might be better to post up in a new thread though - this one's getting a bit long!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

GPRS or Edge Howto?

Posted by Avatar for fobus @fobus

Actions