Skip to content

Commit cb2c254

Browse files
committed
Internet functionality added
1 parent 29d4f54 commit cb2c254

File tree

3 files changed

+387
-117
lines changed

3 files changed

+387
-117
lines changed

README.md

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# gsmHat - Waveshare GSM/GPRS/GNSS HAT for Raspberry Pi with Python
22

3-
With gsmHat, you can easily use the functionality of the Waveshare GSM/GPRS/GNSS HAT for Raspberry Pi ([Link to HAT](https://www.waveshare.com/gsm-gprs-gnss-hat.htm)). On this module a SIM868 Controller is doing the job too connect your Raspberry Pi with the world just by using a sim card.
3+
With gsmHat, you can easily use the functionality of the Waveshare GSM/GPRS/GNSS HAT for Raspberry Pi ([Link to HAT](https://www.waveshare.com/gsm-gprs-gnss-hat.htm)). On this module a SIM868 Controller is doing the job to connect your Raspberry Pi with the world just by using a sim card.
4+
5+
## Update on Wed Oct 21st, 2020
6+
:point_right: Internet functionality added!
47

58
## Overview
69
gsmHat was written for Python 3. It provides the following features
710

811
- Non-blocking receiving and sending SMS in background
912
- Non-blocking calling
1013
- Non-blocking refreshing of actual gps position
14+
- Non-blocking URL Call and receiving of response
1115

1216
## Usage
1317

@@ -88,7 +92,7 @@ gsm.HangUp() # Or you can HangUp by yourself earlier
8892
gsm.Call(Number, 60) # Or lets change the timeout to 60 seconds. This call hangs up automatically after 60 seconds
8993
```
9094

91-
7. Lets see, where your Raspberry Pi (in a car or in a motocycle or on a cat?) is positioned on earth
95+
7. Lets see, where your Raspberry Pi (in a car or on a motocycle or on a cat?) is positioned on earth
9296

9397
```Python
9498
# Get actual GPS position
@@ -114,16 +118,49 @@ print('Signal: %s' % str(GPSObj.Signal))
114118
8. Calculate the distance between two Points on earth
115119

116120
```Python
117-
GPSObj1 = GPS() # You can also use gsm.GetActualGPS() to get an GPS object
118-
GPSObj1.Latitude = 52.266949 # Location of Braunschweig, Germany
119-
GPSObj1.Longitude = 10.524822
121+
GPSObj1 = GPS() # You can also use gsm.GetActualGPS() to get an GPS object
122+
GPSObj1.Latitude = 52.266949 # Location of Braunschweig, Germany
123+
GPSObj1.Longitude = 10.524822
124+
125+
GPSObj2 = GPS()
126+
GPSObj2.Latitude = 36.720005 # Location of Manavgat, Turkey
127+
GPSObj2.Longitude = 31.546094
120128

121-
GPSObj2 = GPS()
122-
GPSObj2.Latitude = 36.720005 # Location of Manavgat, Turkey
123-
GPSObj2.Longitude = 31.546094
129+
print('Distance from Braunschweig to Manavgat in metres:')
130+
print(GPS.CalculateDeltaP(GPSObj1, GPSObj2)) # this will print 2384660.7 metres
131+
```
124132

125-
print('Distance from Braunschweig to Manavgat is [m]:')
126-
print(GPS.CalculateDeltaP(GPSObj1, GPSObj2)) # this will print 2384660.7 metres
133+
9. Call URL to send some data
134+
135+
```Python
136+
# Init gsmHat
137+
gsm = GSMHat('/dev/ttyS0', 115200)
138+
139+
# Set the APN Connection data. You will get this from your provider
140+
# e.g. German Provider 'Congstar'
141+
gsm.SetGPRSconnection('internet.telekom', 'congstar', 'cs')
142+
143+
# Get actual GPS position
144+
GPSObj = gsm.GetActualGPS()
145+
146+
# Build url string with data
147+
url = 'www.someserver.de/myscript.php'
148+
url += '?time='+str(int(GPSObj.UTC.timestamp()))
149+
url += '&lat='+str(GPSObj.Latitude)
150+
url += '&lon='+str(GPSObj.Longitude)
151+
url += '&alt='+str(GPSObj.Altitude)
152+
153+
gsm.CallUrl(url) # Send actual position to a webserver
154+
```
155+
156+
10. Get the Response from a previous URL call
157+
158+
```Python
159+
# Check, if new Response Data is available
160+
if gsm.UrlResponse_available() > 0:
161+
# Read the Response
162+
newResponse = gsm.UrlResponse_read()
163+
# Do something with it
127164
```
128165

129166
## What will come in the future?
@@ -168,4 +205,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
168205
SOFTWARE.
169206

170207

171-
contact me: <software@tounsi.de>
208+
contact me: <software@tounsi.de>

0 commit comments

Comments
 (0)