-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved documentation, Changed default AUX to 250ms, Bump to v0.8 (#4)
- Loading branch information
1 parent
1dcb0e4
commit 721d6e7
Showing
23 changed files
with
328 additions
and
41 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Error Handling ⚠️ Must-read ⚠️ | ||
------------------------------ | ||
These examples will show you how to recover from errors returned by the ``E32Device`` class. | ||
|
||
Config Changes | ||
^^^^^^^^^^^^^^ | ||
If you get an ``E32GenericError`` exception when changing the module's config, you will need to follow this procedure. | ||
|
||
**Expected error:** | ||
|
||
``E32GenericError: The module didn't return the new config !`` | ||
|
||
**Resolution procedure:** | ||
|
||
* Catch error in a ``try except`` block. | ||
|
||
* Reset the module via ``E32Device.reset()``. | ||
|
||
* Wait some time for it to restart. | ||
|
||
* Re-apply the config with ``E32Device.update_config()``. | ||
|
||
* Go back into the original mode. | ||
|
||
* Retry the code that raised the error | ||
|
||
**Warning:** | ||
|
||
Failure to follow the procedure WILL result in a module that no longer applies new operating parameters | ||
given to it ! | ||
|
||
.. literalinclude:: ../examples/error_handling.py | ||
:caption: examples/error_handling.py | ||
:emphasize-lines: 24-45 | ||
:linenos: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,77 @@ | ||
LoRa (TODO) | ||
----------- | ||
TODO | ||
.. role:: raw-html(raw) | ||
:format: html | ||
|
||
Spreading Factor | ||
^^^^^^^^^^^^^^^^ | ||
TODO | ||
LoRa | ||
---- | ||
LoRa is a RF modulation technology engineered to be quite resilient to allow long-distance communications with a | ||
relatively low power-consumption. | ||
|
||
It is also referred to as `LoRa PHY`. | ||
|
||
Max Message Length | ||
^^^^^^^^^^^^^^^^^^ | ||
⚠️ **Do not confuse with LoRaWAN limits** ⚠️ | ||
|
||
Due to some legal limitations regarding the maximum RF air-time that can be used by LoRa, there is a limit to how | ||
long each packet can be. | ||
|
||
If given more data than what should be transmitted in a single packet, the E32 modules will segment that data | ||
and transfer it as individual packets. | ||
|
||
This automatic segmentation can be a problem in fixed transmissions since it completely erase the target address and | ||
channel from any subsequent packet. | ||
|
||
This limit can be **somewhat** ignored when using transparent communications since the message doesn't | ||
contain the target address and channel, but steps should be taken to not rely on this behaviour. | ||
|
||
Official limits | ||
""""""""""""""" | ||
I couldn't find any concrete limits for packet size on LoRa PHY. | ||
|
||
All I know is that is depends on a maximum air-time limit enforced by local RF laws which is defined by the | ||
air data rate and some other parameters. | ||
|
||
As of now, you should try different sizes at your desired operating settings in fixed mode to find that limit. | ||
|
||
Here is an excerpt from the `"LoraWAN Regional Parameters RP002-1.0.4"` document: | ||
|
||
.. image:: _static/lora-phy-size-limit-mention.png | ||
:width: 80% | ||
:alt: Mention of PHY restrictions influencing LoRaWAN max packet size. | ||
:align: center | ||
|
||
:raw-html:`<span class="image-caption">Mention of PHY restrictions finfluencing LoRaWAN max packet size.</span>` | ||
|
||
Observed limits | ||
""""""""""""""" | ||
TODO: Check if it depends on the spread factor or just operating parameters and region. | ||
|
||
If you can, please contribute to these tables by raising an issue. | ||
|
||
Documentation | ||
""""""""""""" | ||
|
||
* `LoRaWAN Packet Size Considerations (By The Things Network) <https://lora-developers.semtech.com/documentation/tech-papers-and-guides/the-book/packet-size-considerations>`_ | ||
|
||
Spreading Factor (SF) | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
The spreading factor is a mechanism that influence the air data rate, time-on-air and the receiver's sensitivity. | ||
:raw-html:`<br>` | ||
It can be one of 6 values between ``SF7`` and ``SF12``. | ||
|
||
I can't for the life of me give you a clear and concise explanation or table of these values and their effect | ||
as well as the operating parameters that would be appropriate for them. | ||
:raw-html:`<br>` | ||
**Absolutely nobody who should be able to** can make a document that is concise, complete and | ||
doesn't expect the reader to glue bits and pieces from 20+ different documents to get a complete view that | ||
doesn't only cover part of these SF values because of some arcane reasons. | ||
|
||
Here are some links to documentation I'd recommend on the subject: | ||
|
||
* `Spreading Factors (By The Things Network) <https://www.thethingsnetwork.org/docs/lorawan/spreading-factors/>`_ | ||
|
||
* `Spreading Factor (By iotjourney.orange.com) <https://iotjourney.orange.com/en/support/faq/spreading-factor-(sf)>`_ | ||
|
||
* `LoRa SF explained (By blog.ttulka.com) <https://blog.ttulka.com/lora-spreading-factor-explained/>`_ | ||
|
||
Good luck. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
""" | ||
|
||
MAJOR = 0 | ||
MINOR = 7 | ||
MINOR = 8 | ||
PATCH = 0 | ||
VERSION = f"{MAJOR}.{MINOR}.{PATCH}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# SPDX-FileCopyrightText: 2023 Herwin Bozet | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
import board | ||
import time | ||
|
||
import ebyte_e32 | ||
import ebyte_e32.exceptions | ||
|
||
PIN_M0 = board.B3 | ||
PIN_M1 = board.B4 | ||
PIN_RXD = board.A2 # Pin marked as RX on the module | ||
PIN_TXD = board.A3 # Pin marked as TX on the module | ||
PIN_AUX = board.B7 | ||
|
||
e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD, address=0x1337, channel=0) | ||
|
||
# We'll be iterating over each channel | ||
channel = 0 | ||
while True: | ||
print(f"Moving to channel {channel}") | ||
|
||
try: | ||
# Can cause errors if the module fails to respond to config request when validating it. | ||
e32.channel = channel | ||
e32.wait_aux() | ||
except ebyte_e32.exceptions.E32GenericError: | ||
print("Failed to change !") | ||
|
||
# We reset it and wait more than what AUX indicates. | ||
e32.reset(True) | ||
time.sleep(2) | ||
|
||
# We re-apply the `E32Device` class' config | ||
e32.update_config() | ||
e32.wait_aux() | ||
|
||
# Going back to the appropriate mode | ||
e32.mode = ebyte_e32.Modes.MODE_NORMAL | ||
e32.wait_aux() | ||
|
||
# Retrying to change channels and send the message. | ||
time.sleep(1) | ||
continue | ||
|
||
e32.send(b'Hello World !') | ||
e32.wait_aux() | ||
|
||
time.sleep(2.5) | ||
|
||
channel = channel + 1 | ||
if channel > ebyte_e32.CHANNEL_MAX: | ||
channel = ebyte_e32.CHANNEL_MIN | ||
|
||
time.sleep(2.5) |
Oops, something went wrong.