Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IN PROGRESS] Features - 2g data GET request #13

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

facultymatt
Copy link
Contributor

Don't merge yet because there is a bug documented below

There is a bug that occurs when you end a script and then try running it again. You get the following stack trace.

{ message: 'Chain broke on AT+SAPBR=1,1', type: 'Error', name: 'Error', stack: 'stack traceback:
    /app/node_modules/gprs-sim900/index.js:208: in function 'f'
    /app/node_modules/gprs-sim900/index.js:194: in function 'temp'
    /app/node_modules/gprs-sim900/postmaster.js:152: in function 'reply'
    /app/node_modules/gprs-sim900/postmaster.js:166: in function 'f'
    /app/node_modules/gprs-sim900/postmaster.js:86: in function '?'
    /app/node_modules/gprs-sim900/packetizer.js:152: in function '?'
    builtin/tessel.js:738: in function 'func'
    [T]: src/colony/lua/colony-node.lua:54: in function <[T]: src/colony/lua/colony-node.lua:53>' }

To re-create do the following:

  1. Create a simple script that makes a GET request, see example below.
  2. Stop the script using control + c
  3. Then run the script again

I think this is happening because we are doing something wrong with the init or termination commands. @johnnyman727, could a state or command remain lingering on the chip between power cycles? Otherwise this is likely do the network not being discovered in time.


requestGET(webAddress, callback)

This PR introduces data support to the GRPS module. It adds a method, #requestGET(webAddress, callback), that will perform a simple GET request to a given web address. The callback will return with any errors if the GET request fails.

For example:

gprs.requestGET('http://myapi.com?id=12345&location=xyz', function requestGETCallback(err, data) {
    if(err) {
        console.log('location was not saved');
        return;
    }
    console.log('location was saved to API');
});

new CommandChain()

This PR also introduces a helper method for generating command chains. Previously you needed to create three separate arrays, for example:

var commands = ['AT+INIT', 'AT+CMD'];
var patiences = [2000, 5000];
var replies = [ ['AT+INIT' , 'OK'], ['AT+CMD' , 'OK'] ];

This was cumbersome in that it required updating three arrays to add or remove commands. Now you can keep the command, patience, and reply together in one object. For example:

var commands = new CommandChain([{
    message: 'AT+INIT, 
    patience: 2000,
    expected: ['AT+INIT' , 'OK']
}, {
    message: 'AT+CMD',
    patience: 5000,
    expected: ['AT+CMD' , 'OK']
}]);

You can then get arrays from the command chain using the following methods:

commands.getMessages() // array of all messages
commands.getPatiences() // array of all patiences
commands.getExpected() // array of all expectations

@facultymatt facultymatt changed the title [DONT MERGE YET] Features - 2g data GET request [IN PROGRESS] Features - 2g data GET request Jun 22, 2014
@davidhq
Copy link

davidhq commented Mar 21, 2015

Is this abandoned? Would be great to have data support for gprs module.....
thank you for clarification

@facultymatt
Copy link
Contributor Author

It's not abandoned per say... but hasn't been updated in a while and I'm not sure of its current working status.

I suggest you look at this project: https://github.com/heikki/tessel-tracker-demo. The author has done great work creating an abstract set of commands for chaining data. See https://github.com/heikki/tessel-tracker-demo/blob/master/index.js#L17-L26 and https://github.com/heikki/tessel-tracker-demo/blob/master/lib/commands.js

@davidhq
Copy link

davidhq commented Mar 21, 2015

Thank you for the answer! Actually I have tried tessel-tracker-demo code today already but it didn't work for me, not sure why.. I opened an issue there heikki/tessel-tracker-demo#1 .. maybe it's some obvious mistake from my side but still I think I tried everything, always Chain broke on AT+HTTPDATA=16,5000 .. so I wanted to ask for status here as well...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants