-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[lora-sx126x,lora-sx127x]: Add dependencies for sync/async modems. #1047
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
base: master
Are you sure you want to change the base?
[lora-sx126x,lora-sx127x]: Add dependencies for sync/async modems. #1047
Conversation
The lora-sx126x and lora-sx127x packages create SyncModem and AsyncModem classes by importing from lora.sync_modem and lora.async_modem modules, which are provided by the lora-sync and lora-async extension packages respectively. However, the manifest.py files for these hardware driver packages did not require lora-sync or lora-async as dependencies. This meant that when users installed lora-sx126x or lora-sx127x, they would get the hardware driver but not the modem wrapper classes needed to actually use it. This commit adds the missing dependencies and increments the patch versions (0.1.5→0.1.6 for sx126x, 0.1.2→0.1.3 for sx127x), so users will receive the fixed packages. Also fixed error handling in lora/__init__.py where ImportError would be raised incorrectly when the second hardware driver import failed, even if the first one had succeeded. Signed-off-by: Breno RdV <[email protected]>
…cond hardware driver import failed, because the error message would contain "lib.lora" instead of just "lora.". Signed-off-by: Breno RdV <[email protected]>
…sync modems. micropython/lora/lora-sx127x/manifest.py: Add dependencies for sync/async modems. The lora-sx126x and lora-sx127x packages create SyncModem and AsyncModem classes by importing from lora.sync_modem and lora.async_modem modules, which are provided by the lora-sync and lora-async extension packages respectively. However, the manifest.py files for these hardware driver packages did not require lora-sync or lora-async as dependencies. This meant that when users installed lora-sx126x or lora-sx127x, they would get the hardware driver but not the modem wrapper classes needed to actually use it. This commit adds the missing dependencies and increments the patch versions (0.1.5→0.1.6 for sx126x, 0.1.2→0.1.3 for sx127x), so users will receive the fixed packages. Also fixed error handling in lora/__init__.py where ImportError would be raised incorrectly when the second hardware driver import failed, even if the first one had succeeded. Signed-off-by: Breno RdV <[email protected]>
…ncorrectly when the second hardware driver import failed, because the error message would contain "lib.lora" instead of just "lora.". Signed-off-by: Breno RdV <[email protected]> Signed-off-by: Breno RdV <[email protected]>
…brenordv/micropython-lib into improving-importing-for-sx-1262
Hi @brenordv, Thanks for digging into this and submitting this PR. Not depending on either We tried to smooth over the usability of this in the installation instructions and by producing a helpful error message if neither package was installed. It seems like your PR also fixes a case where that message wasn't being generated, thanks! |
del ok | ||
|
||
|
||
__version__ = '0.2.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is automatically added by mip
when the package is installed.
Problem
When installing
lora-sx126x
orlora-sx127x
packages via mip, users only get the hardware drivers but not the SyncModem/AsyncModem wrapper classes, making the packages unusable.Also found a problem in the import handling in
lora/__init__.py
whereImportError
would be raised incorrectly when the error message containedlib.lora
instead of justlora
.I noticed both problems after installing the
lora-sx1262
package viaThonny
package manager.Solution
Added
require("lora-sync")
andrequire("lora-async")
to the manifest files so these dependencies are automatically installed.To fix the import problem, I added an extra check to prevent this from happening by checking if the error message contains both "no module named", and "lora". Since the check was the same for all imports, I centralized the check in a function.
Testing
Install the package and verify the modem classes are available: