-
I rewritten things entirely from scratch.... also with use of promises.
However, the error still occurs...
My question is whether the SIM900 receives the response string as a whole?
In the JSON response I see a AT-Command-Response (+RECEIVE,0,940:) in middle of the string.
Can this be a problem? I do not see the end of the JSON-String, so my assumption is the missing characters were subtracted by the length of the AT-Response in middle.
Can I fix this myself?$http(sampleGetReq).then(function(data){
: // success
: console.log('success', data);
:});
={ }OK
0, CONN
ECT OK0, S
END OK+RECEIVE,0,
1380:
HTTP/1.1 200 OK
Date: Thu, 28 Jul 2016 22:25:00 GMT
Content-Type: application/vnd.carriots.v2+json; charset=utf-8
Connectio
n: close
Server: Carriots REST API
Cache-Control: no-cache
Allow: GET, POST
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: Date,Server,Allow,Connection,Content-Length,Content-Type,Cache-Control
{"total_documents"
:6,"result":[{"_id":"579842a25c5d7550425376e3","protocol":"v2","checksum":"","_t":"str","at":1469596322,"device":"Commander@afitterling.afitterling","data":{"time":1,"cycle":1},"id_developer":"185c0dde8b7c9df29d122b25d85fce1c26ad7645ed021f5c611fe4115132f4f8@afitterling.afitterling","created_at":1469596322,"owner":"afitterling"},{"_id":"579842ae5c5d752b45537679","protocol":"v2","checksum":"","_t":"str","at":1469596334,"device":"Commander@afitterling.afitterling","data":{"time":1,"cycle":1},"id_developer":"6c49c7f8cae5845cacd060ff93edb189517f691a47dbe4817a831869d3f
e8ca7@afitterling.afitterling","created_at":1469596334,"owner":"afitterling"},{"_id":"579842b85c5d75e1425376cc","protocol":"v2","checksum":"","_t":"str","at":1469596344,"device":"Commander@afitterling.afitterling","data":{"time":1,"cycle":1},"id_developer":"91df2481ae379b2c25fc485c6de961efea091aab3a4823853a17a22cd1feac52@afitterling.afitterling","created_at":1469596344,"owner":"afitterling"},{"_id":"579842d
+RECEIVE,0,940:
95c5d7599295379f1","protocol":"v2","checksum":"","_t":"str","at":1469596377,96387,"d
evice":"Commander@afitterling.afitterling","data":{"timex":1,"cylce":1},"id_developer":"20ed81b80c70b058cff3d1f339d8558cc00fc1dbf32fd193bde61b83c0185f72@afitterling.afitterling","created_at":1469596387,"owner":"afitterling"},{"_id":"579842f05c5d7550425376ea","protocol":"v2","checksum":"","_t":"str","at":1469596400,"device":"Commander@afitterling.afitterling","data":{"timex":1,"cylce":1},"iddeveloper":"a281efa90907e5e8ff7f6a4fe1afadcd23e746a717a8b7610ab459f8ab538258@afitterling.afitterling","created0, CLOS
EDthe next call then will get stuck then.
kind regards,
Alex -
-
-
All I do is run the below calls .... one after another it works as expected over 1.5 hour ... even chaining them via callback.
Then once I start resetting the SIM900 (my own reset) wich completely switches the SIM900 off and back on.
The first request (getJobs) will fail repeatedly.
// template for this device var device1 = { protocol: "v1", checksum: "", device: "defaultDevice@xyz", at: "now", data: {} }; function post(template, payload, fn, fne) { template.data = payload; content = JSON.stringify(template); var options = { host: 'api.carriots.com', path: '/status', port: '80', method:'POST', headers: { "carriots.apiKey": "aaaaaaaaaaaaaaaaa", "Content-Type": "application/json", "Content-Length": content.length } }; var req = require("http").request(options, function(res) { var d = ""; res.on('data', function(data) { d+= data; }); res.on('error', function(data) { console.log('error', data); if (fne){ return fne(); } }); res.on('close', function(data) { var obj = JSON.parse(d); if (fn){ return fn(obj); } }); }).end(content); }
the calls are done like:
function getJobs(fn, fne) { var options = { host: 'api.carriots.com', path: '/streams/?device=Commander@mydevice', port: '80', method:'GET', headers: { "carriots.apiKey": "key", "Content-Type": "application/json" } }; var req = require("http").request(options, function(res) { var d = ""; res.on('data', function(data) { d+= data; }); res.on('error', function(data) { console.log('error', data); if (fne){ return fne(); } }); res.on('close', function() { var obj = JSON.parse(d); if (fn){ return fn(obj); } console.log('req closed'); }); }).end(); }
-
-
@Gordon I reset the SIM900 with a relais. I really switch it off and back on. After that the uplink (refresh IP) works... but not the requests. they will fail with above errors. Should I initialize something I forgot about?
When is the gprs.reset() to be used? I could not bring my SIM900 online if I only use reset with callback. I really had to restart it by withdrawing power and put it back on. -
-
-
Excuse me this issue may not be SIM900 related, which performs quite good with the module... see my fix below:
Whenever I reset my SIM900 (switch it totally off) and would run a JSON-Request after reset it throws this kind of error, even I am online:
req start
Closed: undefined
Uncaught SyntaxError: Got ID:total_documents expected ':'
at line 3 col 3
{"total_documents":0,"result"l_documents":0,"result":""}:""}
^
in function called from systemHowever when I first doing a request with a non JSON result say the hello-request with a text result. The consecutive calls with JSON will NOT fail.
If someone has a hint, please tell me. kind regards, Alex
-
-
-
-
-
I really think each programmer should know this. We're dealing on a very low level on that hardware. Everyone has to be careful how he deals with it.... So I would say, not for sure the module needs to handle it.
I have to think about it.
In my case I was just receiving the IP-Adress from the SIM900 on timeinterval with a special AT-command (not with the SIM900 code). At the time this command did not resond properly, and I started the request, it got mixed up and the request failed with above error. Now as solution I do one operation at a time.
I prevent status requests on that hw, when I am aware I need to make a request. I personally gave the last one the higher priority.
-
I think it is not a problem with the SIM900 code. It is regarded, how AT commands get executed at the modem. I can reproduce this, when I run shortly after another two command, awaiting replies from the modem. e.g.: isOnline(); networkTasks() (my own code)
If avoiding this so called "concurrent" - in JS-Terms better say, overlapping operations - it might be fixed. However the hardware cannot not deal with the commands in a concurrent mode. So each has to be send at a time and pseudo-synchronously should receive its result, before proceeding to the next one.req start =undefined error request Uncaught Error: CIPSTART failed. at line 1 col 68 ...ew Error('CIPSTART failed.');at.registerLine(a+', CONNECT OK... ^ in function "a" called from line 1 col 31 c=undefined;var d;if(a&&(d=a(g))?(c=h,a=d):clearTimeout(j),c... ^ in function "c" called from line 1 col 331 ...e&&(d[e](i),j=!0);j||c&&c(i);}if(a=a.substr(f+h.length),a[0]...
-
I could successfully switch a HM-10 BLE Device with the 5LN01SP (using a IOPin for Gate). However only with VBAT to source (Espruino was hooked up with USB => 4,5V?). the 3.3V pin does not work, when switching with a IO-Pin at Gate. the current seems not high enough. Is there a way to use 3.3V, e.g. use two MOSFETS in parallel?
-
-
Everyone,
I am struggling with my Waveshare GSM-Module to establish M2M communication (http://www.waveshare.com/wiki/GSM/GPRS/GPSShield%28B%29).
There're two serial ports on this device. The GSM-Shield itself and some separate connections for the SIM808 to connect directly to it. However I could not get it to work. Even on Arduino.
Has anyone done this before? Does anyone use this module?
kind regards,
Alex -
-
yes, I will try that.