Prepair for release

This commit is contained in:
Dionysus 2024-11-29 22:56:16 -05:00
parent 897b443034
commit 5c1e5ee60d
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
6 changed files with 117 additions and 21 deletions

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Build artifacts
__pycache__/
*.py[cod]
build/
dist/
*.egg-info/
.eggs/
# Virtual environments
venv/
env/
# Testing
.pytest_cache/
.coverage
coverage.xml
# IDE
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db

View File

@ -6,7 +6,6 @@ A lightweight Python library for parsing Meshtastic MQTT messages into JSON form
This library connects to a Meshtastic MQTT broker and decodes various message types into JSON format, making it simple to process Meshtastic mesh network data in your Python applications.
## Features
- Connects to any Meshtastic MQTT broker
@ -16,16 +15,25 @@ This library connects to a Meshtastic MQTT broker and decodes various message ty
- Message type filtering support
- Simple command-line interface
## Installation
## Installation
Install from PyPI:
```bash
pip install cryptography protobuf meshtastic paho-mqtt
pip install pip install meshtastic-mqtt
```
## usage
```bash
python meshtastic_mqtt.py [options]
python meshtastic_mqtt [options]
```
```python
from meshtastic_mqtt import MeshtasticMQTT
client = MeshtasticMQTT()
client.connect(broker='mqtt.meshtastic.org', port=1883, root='msh/US/2/e/', channel='LongFast', username='meshdev', password='large4cats', key='AQ==')
```
### Command Line Options
| Option | Description | Default |

6
pyproject.toml Normal file
View File

@ -0,0 +1,6 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "src/meshtastic_mqtt/_version.py"

43
setup.py Normal file
View File

@ -0,0 +1,43 @@
from setuptools import setup, find_packages
setup(
name="meshtastic_mqtt",
version='0.1.0',
author='acidvegas',
author_email='acid.vegas@acid.vegas',
description='A lightweight Python library for parsing Meshtastic MQTT messages',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url='https://github.com/acidvegas/meshtastic_mqtt',
project_urls={
'Bug Tracker' : 'https://github.com/acidvegas/meshtastic_mqtt/issues',
'Documentation' : 'https://github.com/acidvegas/meshtastic_mqtt#readme',
'Source Code' : 'https://github.com/acidvegas/meshtastic_mqtt',
},
packages=find_packages(where='src'),
package_dir={'': 'src'},
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: ISC License (ISCL)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Communications',
],
python_requires='>=3.6',
install_requires=[
'cryptography',
'protobuf',
'meshtastic',
'paho-mqtt',
],
entry_points={
'console_scripts': [
'meshtastic-mqtt=meshtastic_mqtt.client:main',
],
},
)

View File

@ -0,0 +1,9 @@
"""
Meshtastic MQTT Interface - A lightweight Python library for parsing Meshtastic MQTT messages
"""
from .client import MeshtasticMQTT
__version__ = "0.1.0"
__author__ = "acidvegas"
__license__ = "ISC"

View File

@ -26,6 +26,7 @@ try:
except ImportError:
raise ImportError('missing the paho-mqtt module (pip install paho-mqtt)')
class MeshtasticMQTT(object):
def __init__(self):
'''Initialize the Meshtastic MQTT client'''
@ -301,21 +302,26 @@ class MeshtasticMQTT(object):
print(mp)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Meshtastic MQTT Interface')
parser.add_argument('--broker', default='mqtt.meshtastic.org', help='MQTT broker address')
parser.add_argument('--port', default=1883, type=int, help='MQTT broker port')
parser.add_argument('--root', default='msh/US/2/e/', help='Root topic')
parser.add_argument('--channel', default='LongFast', help='Channel name')
parser.add_argument('--username', default='meshdev', help='MQTT username')
parser.add_argument('--password', default='large4cats', help='MQTT password')
parser.add_argument('--key', default='AQ==', help='Encryption key')
parser.add_argument('--filter', help='Filter message types (comma-separated). Example: NODEINFO,POSITION,TEXT_MESSAGE')
args = parser.parse_args()
def main():
parser = argparse.ArgumentParser(description='Meshtastic MQTT Interface')
parser.add_argument('--broker', default='mqtt.meshtastic.org', help='MQTT broker address')
parser.add_argument('--port', default=1883, type=int, help='MQTT broker port')
parser.add_argument('--root', default='msh/US/2/e/', help='Root topic')
parser.add_argument('--channel', default='LongFast', help='Channel name')
parser.add_argument('--username', default='meshdev', help='MQTT username')
parser.add_argument('--password', default='large4cats', help='MQTT password')
parser.add_argument('--key', default='AQ==', help='Encryption key')
parser.add_argument('--filter', help='Filter message types (comma-separated). Example: NODEINFO,POSITION,TEXT_MESSAGE')
args = parser.parse_args()
client = MeshtasticMQTT()
if args.filter:
client.filters = [f'{f.strip()}_APP' for f in args.filter.upper().split(',')]
else:
client.filters = None
client.connect(args.broker, args.port, args.root, args.channel, args.username, args.password, args.key)
client = MeshtasticMQTT()
if args.filter:
client.filters = [f'{f.strip()}_APP' for f in args.filter.upper().split(',')]
else:
client.filters = None
client.connect(args.broker, args.port, args.root, args.channel, args.username, args.password, args.key)
if __name__ == '__main__':
main()