- Secure and insecure clients can usually be mixed when using multiple connections.
- The total number of connections possible varies by module
- Begin your serial communication and set all your pins as required to power your module and bring it to full functionality.
- Begin your serial communication and set all your pins as required to power your module and bring it to full functionality.
- Wait for the module to be ready (~300ms - 6s)
- Wait for the module to be ready (could be as much as 6s, depending on the module)
- Initialize the modem
- Initialize the modem
- ```modem.init()``` or ```modem.restart()```
- ```modem.init()``` or ```modem.restart()```
- restart generally takes longer than init but ensures the module doesn't have lingering connections
- Unlock your SIM, if necessary:
- Unlock your SIM, if necessary:
- ```modem.simUnlock(GSM_PIN)```
- ```modem.simUnlock(GSM_PIN)```
- If using **WiFi**, specify your SSID information:
- If using **WiFi**, specify your SSID information:
@ -199,7 +223,7 @@ The general flow of your code should be:
#### If you have any issues:
#### If you have any issues:
1. Read the whole README (you're looking at it!)
1. Read the whole README (you're looking at it!), particularly the troubleshooting section below.
2. Some boards require [**special configuration**](https://github.com/vshymanskyy/TinyGSM/wiki/Board-configuration).
2. Some boards require [**special configuration**](https://github.com/vshymanskyy/TinyGSM/wiki/Board-configuration).
3. Try running the Diagnostics sketch
3. Try running the Diagnostics sketch
4. Check for [**highlighted topics here**](https://github.com/vshymanskyy/TinyGSM/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22for+reference%22+)
4. Check for [**highlighted topics here**](https://github.com/vshymanskyy/TinyGSM/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22for+reference%22+)
@ -255,6 +279,34 @@ In custom code, you can add this snippit:
#endif
#endif
```
```
### Web request formatting problems - "but it works with PostMan"
This library opens a TCP (or SSL) connection to a server.
In the [OSI model](https://en.wikipedia.org/wiki/OSI_model), that's [layer 4](http://www.tcpipguide.com/free/t_TransportLayerLayer4.htm) (or 5 for SSL).
HTTP (GET/POST), MQTT, and most of the other functions you probably want to use live up at [layer 7](http://www.tcpipguide.com/free/t_ApplicationLayerLayer7.htm).
This means that you need to either manually code the top layer or use another library (like [HTTPClient](https://github.com/arduino-libraries/ArduinoHttpClient) or [PubSubClient](https://pubsubclient.knolleary.net/)) to do it for you.
Tools like PostMan also works at layer 7, not layer 4/5 like TinyGSM.
If you are successfully connecting to a server, but getting responses of "bad request" (or no response), the issue is probably your formatting.
Here are some tips for writing layer 7 (particularly HTTP request) manually:
- Look at the "WebClient" example
- Make sure you are including all required headers.
- If you use PostMan, make sure you un-hide and look at the "auto-generated" headers; you'll probably be surprised by how many of them there are.
- Use ```client.print("")```, or ```client.write(buf, #)```, or even ```client.write(String(""))```, not ```client.write("")``` to help prevent text being send out one character at a time (typewriter style)
- Enclose the entirety of each header or line within a single string or print statement