sim800L gprs post request - module

I've been working on a LoNet mini GSM module (SIM800L), interfacing it with Arduino.
I've inserted the SIM mobile card with Internet connection available.
Through serial monitor I'm communicating with it with no problems, but when it comes to make a GET or a POST request to a webserver page it returns Network Error (601).
Here it is:
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","http://:8080/folder/savedata.php"
OK
AT+HTTPACTION=0
OK
+HTTPACTION: 0,601,0 //601: Network Error
AT+HTTPREAD=1,100000
OK
And no response of the "echo" of the php page...
Do you have any suggestion?
Thanks in advance.
enter image description here
enter image description here

Did you set up your PDP context already? I think some main concepts are that you need to successfully attach and startup GPRS connection.
Some things that need to be active before this will work:
1) Network registration
AT+CREG? should return 0,1 if so, skip to 2)
if it doesn't then you can start by turning on and off the modem by inputting AT+CFUN=0 and then AT+CFUN=1
if you are still having problems registering make sure you have selected the correct network:
AT+COPS? should see your service providers name in the results
eg.
AT+COPS: 1,0,"T-Mobile USA"
If you don't, then make sure your band is set properly to your service provider. Look up your providers 2G band
e.g. t-mobile uses PCS_MODE for their 2G service. set this via:
AT+CBAND="PCS_MODE"
Also, obviously you should make sure you have signal:
AT+CSQ should return at at least a 5 or 6
2) Network Activation
AT+CIPSHUT
AT+CGATT=1 - this can take some time to get through. I have a 40 sec timeout
Its important for this step to work. If it doesn't perhaps restart your modem. But this is a key part.
3) setting PDP context and bringing up GPRS service
AT+SAPBR=3,1,"CONTYPE","GPRS"
set your APN: find out what your 2g APN is from your provider.
e.g. for t-mobile: epc.tmobile.com
define your APN:
T+SAPBR=3,1,"APN","epc.tmobile.com"
AT+SAPBR=1,1 This is the most important part to get through. Sometimes it takes a while to get through, I have a timeout on this part for 3 minutes to let it work.
if this doesn't give you an error proceed:
4) sending HTTP
Basically proceed with what you have...
an example of what I do:
AT+HTTPTERM
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","www.google.com"
AT+HTTPACTION = 0 This should return 200 if it is successful
5 shut down GPRS
AT+CIPSHUT this may give you an error buts its not important
AT+SAPBR=0,1 can take awhile
AT+CGATT=0 also can take a while
anyways I wrote some pretty neat lightweight code for arduino to send data via HTTP. I also wrote one for SMS. let me if you want to take a look. I use a SIM800L -- one of the cheap breakout boards.

If you want to use https add ssl in following order.
mySerial.println("AT+HTTPINIT");
mySerial.println("AT+HTTPSSL=1");
mySerial.println("AT+HTTPPARA=CID,1");
AT+HTTPSSL=1 this will let you to use url with https://
This really useful, if you want to use google cloud functions to add data to firebase.

Try using ipaddress in place of DNS as:
AT+HTTPPARA="URL","http://example.com:8080/folder/savedata.php" OK
Replace it to:
AT+HTTPPARA="URL","http://29.09.07.12:8080/folder/savedata.php" OK
It works in most of the cases.

Related

Can someone clarify IOS Safari Service Worker Support

Looking at the MDN documentation IOS/Safari fully supports ServiceWorkerGlobalScope.onfetch but when you look at the FetchEvent specification it says it is not supported at all by Safari.
In particular, I would like to store some state for each client and was hoping to use the fetchEvent.clientId property of the event to index it. Of course I presume I also have access to the fetchEvent.request object otherwise I can't see how a service worker can do anything useful and I could simulate clientID from a passed in parameter in the url. But the docs don't really tell me what IOS/Safari supports and doesn't so I don't know which way to go.
Can someone please tell me precisely what does IOS/Safari pass when it calls the defined onfetch function.
I found the answer to my question by using https://jakearchibald.github.io/isserviceworkerready/demos/fetchevent/
connecting my iPad to my Macbook and debugging my iPad. I was eventually able to open the web inspector for the Service worker for that page, and the console.log showed the event passed in.
FetchEvent.clientID is present but a zero length string. As it happens I did the same thing on my (linux) Desktop using Chrome and its also a zero length string, BUT it has another parameter resultingClientId with what looks like a UUID in it. That parameter is not there in Safari.
The FetchEvent.request is there, and in particular the URL. So I can generate my own client id in the client (I am using Date.now().toString() as that is good enough for my purposes) for use in the service worker. In fact my site without a service worker was using the in the URLs I need to intercept already, so I am happy that I have a solution.

webrtc used as a simile message app

I am trying to write a small application usingwebrtc that can be used as a messaging/Chat application between 2 computers.
I see this:
http://simpl.info/rtcdatachannel/
and it is not working. any suggestions?
I wrote the simpl.info/rtcdatachannel example. It's only designed to show off data channels working within one page.
For a complete peer-to-peer messaging application, I suggest adding RTCDataChannel functionality to something like apprtc.appspot.com. You could also consider a readymade abstraction library like PeerJS or EasyRTC.
You might also want to take a look at the RTCPeerConnection/RTCDataChannel/signaling codelab I built.
In above example, from the trace log, the ice-candidates are generated, but they are either not exchanged between each other because of there may be problem in sending 'offer' or responding the 'answer'. Also above example works only in chrome( because of only webkitRTCPeerConnection is used, with mozRTCPeerConnection this can work on firefox also.
If you want to develope chat application for only text and not for the video chat, then you can use node-js & socket.io or websockets for this.
You may like :) following two libraries:
DataChannel.js / for webrtc data/text/file sharing (among multi-users)
RTCMultiConnection.js / for data as well as media (screen/audio/video/etc) sharing
Firebase.com is a "suggested" starting point for newcomers; that can be used for signaling. You just need to override "openSignalingChannel" and done!
You should use peer.js (https://github.com/peers/peerjs) or use peer chat (https://github.com/Hironate/PeerChat) if you want to do with node js.

Arduino+WiFly shield failing to communicate to xively

I have a problem in delivering sensor data to the xively API via an Arduino Uno v3 and a Sparkfun WiFly shield. The problem is not in the hardware, or in the WiFly shield library since I can deliver the data to the Paraimpu server just fine.
The most fundamental problem is that the xively library will not work with the sparkfun WiFly library. The relevant declarations (suggested by xively in the documentation) are:
WiFlyClient client;
XivelyClient xivelyclient(client);
this will not work since the WiFlyClient declaration expects a server and port, hence I modified this to:
byte server[] = {173,203,98,29}; //api.xively.com IP address
WiFlyClient client(server,80);
XivelyClient xivelyclient(client);
This gives me an error on compilation of :
Xively_sketch2_aug20a:60: error: no matching function for call to 'XivelyClient::XivelyClient(WiFlyClient&)'
/Users/paultravers/Documents/Arduino/libraries/xively/XivelyClient.h:11: note: candidates are: XivelyClient::XivelyClient(Client&)
/Users/paultravers/Documents/Arduino/libraries/xively/XivelyClient.h:9: note: XivelyClient::XivelyClient(const XivelyClient&)
At this point I am stuck, and my attempts to modify the various libraries to try to reconcile this issue have come to no avail - mostly because it is above my skill level and I really don't know what I am doing.
To get round this, I have written the code to build the put request and send that to the API, using the template of the code that runs successfully to send data to Paraimpu.
I open a connection (either to api.xively.com or to 173.203.98.29; it makes no difference at this stage) and send the following :
PUT /v2/feeds/<feed ID redacted>.json
Host: api.xively.com
Content-Type: application/json
User-Agent : Xively-Arduino-Lib/1.0
X-ApiKey: < API key redacted >
Content-Length: 197
{"version":"1.0.0","datastreams" : [{"id":"TEMPERATURE_CHANNEL" , "current_value" : "29.00"},{"id":"LIGHT_SENSOR_CHANNEL","current_value":"541.00"},{"id":"ALARM_CHANNEL","current_value":"0.00"}]}
Terminating with a blank line.
Needless to say I have set up channels in xively with those names. But this does not work - I don't get the expected return, and the channels don't update. If I read the returning input on the connection it is just a long string of numbers. Can anyone see anything wrong in the format of this request?
i might take a look at WiFlyClient's documentation...maybe you need to set the port/etc in some other way...than extend WiFlyClient
class WiFlyClient2 : public WiFlyClient {
WiFlyClient2(int[] ip,int port) : WiFlyClient() {
//setup up your parent by calling it's functions here
}
}
then it should work like:
byte server[] = {173,203,98,29}; //api.xively.com IP address
WiFlyClient client(server,80);
XivelyClient xivelyclient(client);
note: i never use wifly/etc, i just use arduino...and i run into troubles like this too :)
I don't have a WiFly shield to test with. But as you said in your comment to Zoltan, I don't think that the WiFly client works in the same way that the Arduino Ethernet or Wifi do. This means that the Xively library likely does not work with the WiFly client.
This means that your approach of writing your own HTTP request is probably the way to go. I looked through your request and it looks exactly correct to me. Does anything show up in the Xively Workbench Request Log when you send the request?
One thing you could try is to use the CSV format instead. This can be better for testing since you avoid the possibility of a minor JSON error causing your entire request to not work. To do this change your .json to .csv and then simply make your body a comma separated list of datastream,value. Your body should look something like this:
TEMPERATURE_CHANNEL,29.00
LIGHT_SENSOR_CHANNEL,541.00
ALARM_CHANNEL,0.00
If this does not work it would be helpful if you could post what the return is, that would help us help you. Good luck!
One thing I noticed in your code is that you don't send the HTTP version in your request.
You should try sending:
PUT /v2/feeds/<feed ID redacted>.json HTTP/1.1
I was getting 405 errors when writing to Xively because I incorrectly had HTTP/1.0 as the version in my put requests.
There's also an example from SparkFun's WiFly library that shows writing to Thingspeak which is helpful to make sure you're using the WiFlyClient instance correctly.

how to get errors from tileupdatemanager

In my winrt app, I am trying to update the live tile based on polled URIs. There is currently no update happening and I can't figure out how to troubleshoot. There are numerous scenarios that could be breaking things but i can't seem to find anyway to get insight into potential errors.
The TileUpdateManager seems to be a bit of a black hole that absorbs information but never lets it out.
Does anyone know of how to view errors from the TileUpdateManager?
If it interests anyone, here is my update code:
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
PeriodicUpdateRecurrence recurrence = PeriodicUpdateRecurrence.HalfHour;
List<Uri> urisToPoll = new List<Uri>();
urisToPoll.Add(new Uri(#"http://livetileservice2012.azurewebsites.net/api/liveupdate/1"));
urisToPoll.Add(new Uri(#"http://livetileservice2012.azurewebsites.net/api/liveupdate/2"));
TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdateBatch(urisToPoll, recurrence);
To expand on Nathan's comment, here are two steps you can take to troubleshoot:
Enter your URI straight into a browser to see the results that are returned, and inspect them for being proper XML. As Nathan points out, your URIs are returning JSON which will be ignored by the tile update manager. As a working example (that I use in Chapter 13 of my HTML/JS book), try http://programmingwin8-js-ch13-hellotiles.azurewebsites.net/Default.cshtml.
If you feel that your URI is returning proper XML, try it in the Push and Periodic Notifications Sample (Scenarios 4 and 5 for tiles and badges). If this works, then the error would be in your app code and not in the service.
Do note that StartPeriodicUpdate[Batch] will send a request to the service right away, rather than waiting for the first interval to pass.
Also, if you think that you might have a problem with the service, it's possible to step through its code using Visual Studio Express for Web running on the localhost, when the app is also running inside Visual Studio Express for Win8 (where localhost is enabled).
.Kraig

Setting USB configuration fails

I'm trying to talk to a USB device using libusb, but I feel like I'm tripping up on the first leg of the race. I know precisely what endpoints I need to talk to, etc., but I can't even get that far. I have, in essence:
usb_device *dev = ...; // opened from get_busses()
usb_set_configuration(dev, dev->config[0].bConfigurationValue); // bConfigVal = 1
Now, I can look at the device information in debug mode and I know that the current configuration is 0 (uninitialized / just after restart), and there's exactly 1 valid configuration, which has a configuration number of 1. But when I set the config to 1, I get a return value of -22, which (passed through the stringifier) translates to "windows api error: bad parameter.
I haven't been able to find other people having a similar problem, and it seems like such a simple thing to do -- I can't even claim the interface, or set the alt-interface, or anything like that, because I have to set the configuration first. What am I missing? (if it matters: this is on WinXP)
Looking at libusb-win32\src\driver\set_configuration.c, there seem to be a bunch of different reasons for returning STATUS_INVALID_PARAMETER.
Use libusb_set_debug (from your user mode application) to set verbose debug level, then run Sysinternals DebugView to see the driver's error messages. Hopefully you'd see a clue as to why your set_configuration call fails.