Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.0a0 #1

Merged
merged 46 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7c74056
add .gitignore
acmacunlay Oct 3, 2024
de14404
wip: add pyproject.toml
acmacunlay Oct 3, 2024
b43d280
update README.md
acmacunlay Oct 3, 2024
e4c01ba
wip: update pyproject.toml and setup.py
acmacunlay Oct 3, 2024
dab6846
wip: restructure project to src layout
acmacunlay Oct 3, 2024
5976f42
update LICENSE
acmacunlay Oct 5, 2024
ca40ed3
update .gitignore
acmacunlay Oct 5, 2024
323ab7a
wip: add CHANGELOG.md
acmacunlay Oct 5, 2024
39f129b
migrate setup.py to pyproject.toml
acmacunlay Oct 5, 2024
69f3f3c
update README.md
acmacunlay Oct 5, 2024
1146ed8
wip: restructuring
acmacunlay Oct 5, 2024
fa0bab4
remove setup.cfg
acmacunlay Oct 5, 2024
2ce9d2d
update .gitignore
acmacunlay Oct 5, 2024
9c29501
wip: restructuring p2
acmacunlay Oct 5, 2024
d9cdea5
update README.md
acmacunlay Oct 5, 2024
3d7d5ed
update README.md
acmacunlay Oct 5, 2024
85ae255
Merge branch 'revamp/packaging' into dev
acmacunlay Oct 5, 2024
41b5a0b
update dependencies and add dev dependencies
acmacunlay Oct 5, 2024
0dcb0de
fix mypy error
acmacunlay Oct 5, 2024
f806cc5
adjust supported python version
acmacunlay Oct 5, 2024
79f7677
add typedefs.py
acmacunlay Oct 5, 2024
45554d4
update pyproject.toml
acmacunlay Oct 5, 2024
110ce63
update CHANGELOG.md
acmacunlay Oct 5, 2024
1ab26a4
update .gitignore
acmacunlay Oct 5, 2024
d8f5c01
update .gitignore
acmacunlay Oct 6, 2024
1c78d12
update pyproject.toml
acmacunlay Oct 6, 2024
6adbdba
wip: pipeline
acmacunlay Oct 6, 2024
fbfda2e
wip: use multiple python versions
acmacunlay Oct 6, 2024
0d749a4
update pinned Python version
acmacunlay Oct 6, 2024
7d18910
update pyproject.toml
acmacunlay Oct 6, 2024
131e1c4
wip: pipeline
acmacunlay Oct 6, 2024
86f804d
update README.md
acmacunlay Oct 6, 2024
fdd4000
fix linter errors
acmacunlay Oct 6, 2024
2bafa8d
wip: pipeline
acmacunlay Oct 6, 2024
8706eba
improve pipeline linter check
acmacunlay Oct 6, 2024
9c8c19d
wip: pipeline
acmacunlay Oct 6, 2024
71dcc1d
update .gitignore
acmacunlay Oct 6, 2024
ddede33
wip: pipeline
acmacunlay Oct 6, 2024
0475c6c
wip: unit tests
acmacunlay Oct 6, 2024
15446ff
wip: pipeline
acmacunlay Oct 7, 2024
8add252
Merge branch 'feature/pipeline' into develop
acmacunlay Oct 7, 2024
f5c3c28
update pipeline
acmacunlay Oct 7, 2024
35cdab7
Merge branch 'feature/pipeline' into develop
acmacunlay Oct 7, 2024
c38e311
update pipeline
acmacunlay Oct 7, 2024
8249cf2
Merge branch 'feature/pipeline' into develop
acmacunlay Oct 7, 2024
8f7da65
update CHANGELOG.md
acmacunlay Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will install Python dependencies, run tests and lint with multiple versions of Python.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: pywaveshare

on:
push:
branches:
- "main"
- "develop"
- "feature/*"
- "bugfix/*"
- "hotfix/*"
- "release/*"
pull_request:
branches:
- "main"
- "develop"
- "feature/*"
- "bugfix/*"
- "hotfix/*"
- "release/*"

permissions:
contents: read

jobs:
integration:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -e .[dev]

- name: Run linter
run: |
ruff check . --select I
ruff check .

- name: Run static type checker
run: |
mypy .

- name: Run unit tests
run: |
pytest .
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__
*.egg-info
.mypy_cache
.pytest_cache
.ruff_cache
.pypirc
.venv
dist
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!--
## [Unreleased] - yyyy-mm-dd

### Added

- TODO

### Changed

- TODO

### Deprecated

- TODO

### Fixed

- TODO

### Removed

- TODO

### Security

- TODO
-->

## [0.5.0a0] - 2024-10-07

### Added

- `CHANGELOG.md`
- `.gitignore`
- [WIP] refactor SIM868 controller
- [WIP] unit tests
- implemented GitHub Action for automated CI workflow
- implemented linting using `ruff`
- implemented static type checking using `mypy`
- implemented unit testing using `pytest`

### Changed

- added copyright notice in `LICENSE` for the scope of this fork
- converted `setup.py` to `pyproject.toml` for PEP-517/518 compliance
- converted project structure to `src` layout
- moved forked implementation of the controller to `pywaveshare.boards.sim868`
- made minor changes in `README.md`

### Removed

- `setup.cfg`
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2020 Tarek Tounsi
Copyright (c) 2024 Achilles Macunlay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
113 changes: 44 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
# gsmHat - Waveshare GSM/GPRS/GNSS HAT for Raspberry Pi with Python
# pywaveshare - Waveshare GSM/GPRS/GNSS HAT Controller for Raspberry Pi

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.
With pywaveshare, you can easily use the functionality of the [Waveshare GSM/GPRS/GNSS HAT for Raspberry Pi](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.

## Update on Wed Oct 21st, 2020
:point_right: Internet functionality added!
## Changelog
[See this document.](https://github.com/acmacunlay/pywaveshare/blob/master/CHANGELOG.md)

## Overview
gsmHat was written for Python 3. It provides the following features
pywaveshare was written for Python 3. It provides the following features

- Non-blocking receiving and sending SMS in background
- Non-blocking calling
- Non-blocking refreshing of actual gps position
- Non-blocking URL Call and receiving of response
- Non-blocking receiving and sending SMS in background
- Non-blocking calling
- Non-blocking refreshing of actual GPS position
- Non-blocking URL Call and receiving of response

## Usage
## Quickstart

In the following paragraphs, I am going to describe how you can get and use gsmHat for your own projects.
In the following paragraphs, I am going to describe how you can get and use pywaveshare for your own projects.

### Getting it
### Download

To download pywaveshare, either fork this github repo or simply use pypi via pip.

To download gsmHat, either fork this github repo or simply use Pypi via pip.
```sh
$ python3 -m pip install -U gsmHat
$ python3 -m pip install -U pywaveshare
```

### Prepare
### Setup

* Install your sim card in your module, connect the GSM and the GPS antennas and mount the module on the pin headers of your Raspberry Pi. Make sure, that you **do not** need to enter Pin Code to use your card. Pin Codes are not supported yet.

* Enable the Uart Interface in your Raspberry Pi
* Enable the UART Interface in your Raspberry Pi

1. Start raspi-config: `sudo raspi-config`.
2. Select option 5 - interfacing options.
3. Select option P6 - serial.
4. At the prompt `Would you like a login shell to be accessible over serial?` answer 'No'
5. At the prompt `Would you like the serial port hardware to be enabled?` answer 'Yes'
6. Exit raspi-config and reboot the Pi for changes to take effect.
- Start raspi-config: `sudo raspi-config`.
- Select option 5 - interfacing options.
- Select option P6 - serial.
- At the prompt `Would you like a login shell to be accessible over serial?` answer 'No'
- At the prompt `Would you like the serial port hardware to be enabled?` answer 'Yes'
- Exit raspi-config and reboot the Pi for changes to take effect.

### Using it
### Usage

1. Import gsmHat to your project

```Python
from gsmHat import GSMHat, SMS, GPS
```python
from pywaveshare.boards.sim868 import GSMHat, SMS, GPS
```

2. Init gsmHat
2. Create an instance

```Python
```python
gsm = GSMHat('/dev/ttyS0', 115200)
```

3. Check, if new SMS are available in your main loop

```Python
```python
# Check, if new SMS is available
if gsm.SMS_available() > 0:
# Get new SMS
Expand All @@ -63,7 +64,7 @@ if gsm.SMS_available() > 0:

4. Do something with your newly received SMS

```Python
```python
# Get new SMS
newSMS = gsm.SMS_read()

Expand All @@ -74,7 +75,7 @@ print('The message is: %s' % newSMS.Message)

5. You can also write SMS

```Python
```python
Number = '+491601234567'
Message = 'Hello mobile world'

Expand All @@ -84,7 +85,7 @@ gsm.SMS_write(Number, Message)

6. Or you can call a number

```Python
```python
Number = '+491601234567'
gsm.Call(Number) # This call hangs up automatically after 15 seconds
time.sleep(10) # Wait 10 seconds ...
Expand All @@ -94,7 +95,7 @@ gsm.Call(Number, 60) # Or lets change the timeout to 60 seconds. This call ha

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

```Python
```python
# Get actual GPS position
GPSObj = gsm.GetActualGPS()

Expand All @@ -115,9 +116,9 @@ print('GNSS_satellites: %s' % str(GPSObj.GNSS_satellites))
print('Signal: %s' % str(GPSObj.Signal))
```

8. Calculate the distance between two Points on earth
8. Calculate the distance between two Points on Earth

```Python
```python
GPSObj1 = GPS() # You can also use gsm.GetActualGPS() to get an GPS object
GPSObj1.Latitude = 52.266949 # Location of Braunschweig, Germany
GPSObj1.Longitude = 10.524822
Expand All @@ -132,7 +133,7 @@ print(GPS.CalculateDeltaP(GPSObj1, GPSObj2)) # this will print 2384660.7

9. Call URL to send some data

```Python
```python
# Init gsmHat
gsm = GSMHat('/dev/ttyS0', 115200)

Expand All @@ -155,7 +156,7 @@ gsm.CallUrl(url) # Send actual position to a webserver

10. Get the Response from a previous URL call

```Python
```python
# Check, if new Response Data is available
if gsm.UrlResponse_available() > 0:
# Read the Response
Expand All @@ -164,45 +165,19 @@ if gsm.UrlResponse_available() > 0:
```

## What will come in the future?
- More options to configure the module (e.g. using sim cards with pin code)

* More options to configure the module (e.g. using sim cards with pin code)

## On which platform was gsmHat developed and tested?
## On which platform was pywaveshare developed and tested?

### Hardware:
* [Raspberry Pi 4, Model B](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/)
* [GSM/GPRS/GNSS/Bluetooth HAT for Raspberry Pi](https://www.waveshare.com/gsm-gprs-gnss-hat.htm), **later version that allows to power on/off the module by controlling GPIO 4**
- [Raspberry Pi 4, Model B](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/)
- [GSM/GPRS/GNSS/Bluetooth HAT for Raspberry Pi](https://www.waveshare.com/gsm-gprs-gnss-hat.htm), **later version that allows to power on/off the module by controlling GPIO 4**

### Software:
* Raspbian (Codename: buster, Release: 10)
* Kernel: Linux 5.4.51-v7l+
* Python: 3.7.3


License
----

MIT License

Copyright (c) 2020 Tarek Tounsi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* Python: 3.12


contact me: <software@tounsi.de>
## License
[See this document.](https://github.com/acmacunlay/pywaveshare/blob/master/LICENSE)
1 change: 0 additions & 1 deletion gsmHat/__init__.py

This file was deleted.

Loading