From d11854c39ceb36118b3888c03dddd3a6c6d5f324 Mon Sep 17 00:00:00 2001 From: geeksville Date: Mon, 27 Apr 2020 11:36:55 -0700 Subject: [PATCH] and standard pypi boilerplate --- TODO.md | 18 ++++++++++++++---- setup.py | 35 +++++++++++++++++++++++++++++++++++ test-release.sh | 11 +++++++++++ upload-release.sh | 4 ++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 setup.py create mode 100755 test-release.sh create mode 100755 upload-release.sh diff --git a/TODO.md b/TODO.md index e862105..4486c6a 100644 --- a/TODO.md +++ b/TODO.md @@ -27,15 +27,25 @@ Use a pubsub model to communicate events [https://pypubsub.readthedocs.io/en/v4. - meshtastic.receive.position(MeshPacket) - meshtastic.receive.user(MeshPacket) - meshtastic.receive.data(MeshPacket) -- meshtastic.debugMessage(string) +- meshtastic.debug(string) ## Wire encoding -When sending protobuf packets over serial or TCP each packet is preceded by uint32_t sent in network byte order (big endian). -The upper 16 bits must be 0x4403. The lower 16 bits are packet length (this encoding gives room to eventually allow quite large packets). +When sending protobuf packets over serial or TCP each packet is preceded by uint32 sent in network byte order (big endian). +The upper 16 bits must be 0x94C3. The lower 16 bits are packet length (this encoding gives room to eventually allow quite large packets). Implementations validate length against the maximum possible size of a BLE packet (our lowest common denominator) of 512 bytes. If the length provided is larger than that we assume the packet is corrupted and begin again looking for 0x4403 framing. The packets flowing towards the device are ToRadio protobufs, the packets flowing from the device are FromRadio protobufs. -The 0x4403 marker can be used as framing to (eventually) resync if packets are corrupted over the wire. +The 0x94C3 marker can be used as framing to (eventually) resync if packets are corrupted over the wire. + +Note: the 0x94C3 framing was chosen to prevent confusion with the 7 bit ascii character set. It also doesn't collide with any valid utf8 encoding. This makes it a bit easier to start a device outputting regular debug output on its serial port and then only after it has received a valid packet from the PC, turn off unencoded debug printing and switch to this +packet encoding. + +## MeshtasticShell + +A tool to talk to radios (also serves as an example of the API). + +tips to output to multiple windows: +https://stackoverflow.com/questions/12351786/how-to-redirect-print-statements-to-tkinter-text-widget diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..85f3778 --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +import pathlib +from setuptools import setup + +# The directory containing this file +HERE = pathlib.Path(__file__).parent + +# The text of the README file +README = (HERE / "README.md").read_text() + +# This call to setup() does all the work +setup( + name="ezdevice", + version="0.0.7", + description="Python API & client shell for talking to Meshtastic devices", + long_description=README, + long_description_content_type="text/markdown", + url="https://github.com/meshtastic/Meshtastic-python", + author="Kevin Hester", + author_email="kevinh@geeksville.com", + license="MIT", + classifiers=[ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + ], + packages=["meshtastic"], + include_package_data=True, + install_requires=["FIXME"], + python_requires='>=3', + entry_points={ + "console_scripts": [ + "meshtastic=meshtastic.__main__:main", + ] + }, +) diff --git a/test-release.sh b/test-release.sh new file mode 100755 index 0000000..2a21eaf --- /dev/null +++ b/test-release.sh @@ -0,0 +1,11 @@ +rm dist/* +set -e + +pydoc3 -w meshtastic +mv *.html doc + +python3 setup.py sdist bdist_wheel +python3 -m twine check dist/* +# test the upload +python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* +echo "view the upload at https://test.pypi.org/ it it looks good upload for real" \ No newline at end of file diff --git a/upload-release.sh b/upload-release.sh new file mode 100755 index 0000000..f892a39 --- /dev/null +++ b/upload-release.sh @@ -0,0 +1,4 @@ +rm dist/* +set -e +python3 setup.py sdist bdist_wheel +python3 -m twine upload dist/* \ No newline at end of file