|
1 | | -# SIM800L |
2 | | -A smart library based on Seeeduino that implements the AT HTTP commands to perform GET and POST requests to a JSON API. |
| 1 | + |
| 2 | +# HTTP client for SIM800L |
| 3 | +A smart HTTP client based on Seeeduino that implements the AT HTTP commands to perform GET and POST requests to a JSON API. |
| 4 | + |
| 5 | +## Support |
| 6 | +* Your board have to support the standard SoftwareSerial library. It doesn't work with HardwareSerial based boards for the moment. |
| 7 | +* The API response have to be a valid JSON. |
| 8 | + |
| 9 | +## Instalation |
| 10 | +Download the library and then import it. |
| 11 | + |
| 12 | +## Quick start! |
| 13 | + |
| 14 | +Here's some code to perform a GET request! :+1: |
| 15 | + |
| 16 | +``` c++ |
| 17 | +HTTP http; |
| 18 | +http.configureBearer("movistar.es"); |
| 19 | +http.connect(); |
| 20 | + |
| 21 | +char response[256]; |
| 22 | +Result result = http.get("your.api.com", response); |
| 23 | + |
| 24 | +Serial.println(response); |
| 25 | +// This prints the response body. Note that the response have to be a valid JSON |
| 26 | + |
| 27 | +http.disconnect(); |
| 28 | + |
| 29 | +``` |
| 30 | + |
| 31 | +Here's some code to perform a POST request! :+1: |
| 32 | + |
| 33 | +``` c++ |
| 34 | +HTTP http; |
| 35 | +http.configureBearer("movistar.es"); |
| 36 | +http.connect(); |
| 37 | + |
| 38 | +char response[256]; |
| 39 | +Result result = http.post("your.api.com", "{\"date\":\"12345678\"}", response); |
| 40 | + |
| 41 | +Serial.println(response); |
| 42 | +// This prints the response body. Note that the response have to be a valid JSON |
| 43 | + |
| 44 | +http.disconnect(); |
| 45 | +``` |
| 46 | + |
| 47 | +I suggest the [ArduinoJSON](https://github.com/bblanchon/ArduinoJson) library for parsing the JSON response, then you can play with the values easily. |
| 48 | + |
| 49 | + |
| 50 | +## How it works? |
3 | 51 | In order to perform a request, the library follows these steps: |
4 | 52 |
|
5 | 53 | ##### Configure Bearer: |
@@ -33,3 +81,7 @@ In order to perform a request, the library follows these steps: |
33 | 81 | - AT+HTTPTERM -> wait for OK |
34 | 82 | - AT+SAPBR=0,1 |
35 | 83 |
|
| 84 | +## Future improvements |
| 85 | + |
| 86 | +- Support of HardwareSerial. |
| 87 | +- Support of more content types, not only JSON (application/json). |
0 commit comments