lora-modem


Namelora-modem JSON
Version 1.4.1 PyPI version JSON
download
home_pageNone
SummaryPython library for the Murata TypeABZ LoRaWAN modem
upload_time2024-05-18 14:55:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseCopyright (c) 2022 Jan Janak <jan@janakj.org> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords iot lora lorawan lpwan lorawan-device firmware stm32
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python library for the Murata TypeABZ LoRa modem

This project provides a Python support library for working with the Murata TypeABZ LoRaWAN modem. The modem communicates with the host over an AT command interface. The Python library abstracts away the AT command interface and provides an easier-to-use high-level API. The library provides a Python module that can be embedded into a larger Python application and a command line tool called `lora` that can be used to manage the modem from the terminal. The Python module supports the original Murata Modem firmware shipped with some TypeABZ modules and the open LoRaWAN firmware from the [lora-modem](https://github.com/hardwario/lora-modem) GitHub repository. The command line tool only works with the open firmware.

## Installation
You can install the library with pip from PyPI as follows:
```sh
pip install --upgrade lora-modem
```
Alternatively, you can also install the library from the GitHub repository as follows:
```
git clone https://github.com/hardwario/lora-modem
cd lora-modem/python
pip install --editable .
```

## Usage from Python
The basic usage from a Python program looks as follows:
```python
from lora import TypeABZ, OpenLoRaModem, MurataModem

# Create an instance of the TypeABZ device
device = TypeABZ('/dev/ttyUSB0')

# Try to detect the serial port baud rate used by the device
baudrate = device.detect_baud_rate()
if baudrate is None:
    raise SystemExit('Could not detect modem baud rate')

# Open the serial port and connect to the TypeABZ device
device.open(baudrate)
try:
    # Create an API instance depending on the firmware
    # Use MurataModem instead if your module has the original firmware
    modem = OpenLoRaModem(device)

    # Show fimware version
    print(modem.version)

    # Send an unconfirmed uplink to the default port
    # The message must be a bytes value, not str
    modem.utx(b'ping')
finally:
    # Close the serial port
    device.close()
```
The class `TypeABZ` represents the physical modem device. The classes `OpenLoRaModem` and `MurataModem` then implement a particular version of the modem API. The class `OpenLoRaModem` has been designed for the open firmware from the [lora-modem](https://github.com/hardwario/lora-modem) Github. The class `MurataModem` has been designed for the original Murata Modem firmware preinstalled on some TypeABZ modules. Please refer to the documentation in `lora.py` for more information.

## Command Line Tool

*Note: The command line tool only works with the open modem firmware.*

The library provides a command line tool installed under the name `lora`. The tool can interact with TypeABZ LoRaWAN modems from shell scripts and the terminal. To invoke the tool, pass the pathname to the modem's serial port via the environment variable PORT or the command line option `-p`. Without any arguments, the tool displays information about the selected modem:
```
$ lora -p /dev/serial0
Device information for modem /dev/serial0:
+---------------------+-------------------------------------------------------------------+
| Port configuration  | 19200 8N1                                                         |
| Device model        | ABZ                                                               |
| Firmware version    | 1.1.1-43-gf86592d2 (modified) [LoRaMac-node 4.6.0-23-g50155c55]   |
| Data encoding       | binary                                                            |
| LoRaWAN version     | 1.1.1 / 1.0.4 (1.0.4 for ABP)                                     |
| Regional parameters | RP002-1.0.3                                                       |
| Supported regions   | AS923 AU915 CN470 CN779 EU433 EU868 IN865 KR920 RU864 US915       |
| Device EUI          | 323838377B308503                                                  |
+---------------------+-------------------------------------------------------------------+
Network activation information for modem /dev/serial0:
+------------------+------------------+
| Network type     | public           |
| Activation       | OTAA             |
| Network ID       | 00000013         |
| Join EUI         | 0101010101010101 |
| Protocol version | LoRaWAN 1.1.1    |
| Device address   | 260C56AC         |
+------------------+------------------+
Current state of modem /dev/serial0:
+---------------------------+-----------------------------------------------------------+
| Current region            | US915                                                     |
| LoRaWAN class             | A                                                         |
| Channel mask              | 00FF00000000000000000000                                  |
| Data rate                 | SF10_125                                                  |
| Maximum message size      | 11 B                                                      |
| RF power index            | 0                                                         |
| ADR enabled               | True                                                      |
| Duty cycling enabled      | False                                                     |
| Join duty cycling enabled | True                                                      |
| Maximum EIRP              | 32 dBm                                                    |
| Uplink frame counter      | 2                                                         |
| Downlink frame counter    | 0                                                         |
| Last downlink RSSI        | -105 dBm                                                  |
| Last downlink SNR         | -4 dB                                                     |
| RX1 window                | Delay: 5000 ms                                            |
| RX2 window                | Delay: 6000 ms, Frequency: 923.3 MHz, Data rate: SF12_500 |
| Join response windows     | RX1: 5000 ms, RX2: 6000 ms                                |
+---------------------------+-----------------------------------------------------------+
```
To see the full list of supported commands, run `lora --help`:
```
...
Commands:
  device   Show basic modem information.
  get      Retrieve modem setting(s).
  join     Perform a LoRaWAN OTAA Join.
  keygen   Generate new random LoRaWAN security keys.
  keys     Show current LoRaWAN security keys.
  link     Check the radio link.
  network  Show current network activation parameters.
  reboot   Restart the modem.
  reset    Reset the modem to factory defaults.
  set      Update modem setting.
  state    Show the current modem state.
  trx      Transmit and receive LoRaWAN messages.
```
Run `lora <command> --help` to see the built-in documentation for each command.

## License

The library is licensed under the terms of the Revised BSD License. See [LICENSE](https://github.com/hardwario/lora-modem/blob/main/python/LICENSE) for full details.

Copyright (c) 2022-2023 Jan Janak \<jan@janakj.org\>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "lora-modem",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "iot, lora, lorawan, lpwan, lorawan-device, firmware, stm32",
    "author": null,
    "author_email": "Jan Janak <jan@janakj.org>",
    "download_url": "https://files.pythonhosted.org/packages/e3/82/c1d81efb4d8631489039dea5cd011fc552af083bae0b10b94e90a5b8a53a/lora_modem-1.4.1.tar.gz",
    "platform": null,
    "description": "# Python library for the Murata TypeABZ LoRa modem\n\nThis project provides a Python support library for working with the Murata TypeABZ LoRaWAN modem. The modem communicates with the host over an AT command interface. The Python library abstracts away the AT command interface and provides an easier-to-use high-level API. The library provides a Python module that can be embedded into a larger Python application and a command line tool called `lora` that can be used to manage the modem from the terminal. The Python module supports the original Murata Modem firmware shipped with some TypeABZ modules and the open LoRaWAN firmware from the [lora-modem](https://github.com/hardwario/lora-modem) GitHub repository. The command line tool only works with the open firmware.\n\n## Installation\nYou can install the library with pip from PyPI as follows:\n```sh\npip install --upgrade lora-modem\n```\nAlternatively, you can also install the library from the GitHub repository as follows:\n```\ngit clone https://github.com/hardwario/lora-modem\ncd lora-modem/python\npip install --editable .\n```\n\n## Usage from Python\nThe basic usage from a Python program looks as follows:\n```python\nfrom lora import TypeABZ, OpenLoRaModem, MurataModem\n\n# Create an instance of the TypeABZ device\ndevice = TypeABZ('/dev/ttyUSB0')\n\n# Try to detect the serial port baud rate used by the device\nbaudrate = device.detect_baud_rate()\nif baudrate is None:\n    raise SystemExit('Could not detect modem baud rate')\n\n# Open the serial port and connect to the TypeABZ device\ndevice.open(baudrate)\ntry:\n    # Create an API instance depending on the firmware\n    # Use MurataModem instead if your module has the original firmware\n    modem = OpenLoRaModem(device)\n\n    # Show fimware version\n    print(modem.version)\n\n    # Send an unconfirmed uplink to the default port\n    # The message must be a bytes value, not str\n    modem.utx(b'ping')\nfinally:\n    # Close the serial port\n    device.close()\n```\nThe class `TypeABZ` represents the physical modem device. The classes `OpenLoRaModem` and `MurataModem` then implement a particular version of the modem API. The class `OpenLoRaModem` has been designed for the open firmware from the [lora-modem](https://github.com/hardwario/lora-modem) Github. The class `MurataModem` has been designed for the original Murata Modem firmware preinstalled on some TypeABZ modules. Please refer to the documentation in `lora.py` for more information.\n\n## Command Line Tool\n\n*Note: The command line tool only works with the open modem firmware.*\n\nThe library provides a command line tool installed under the name `lora`. The tool can interact with TypeABZ LoRaWAN modems from shell scripts and the terminal. To invoke the tool, pass the pathname to the modem's serial port via the environment variable PORT or the command line option `-p`. Without any arguments, the tool displays information about the selected modem:\n```\n$ lora -p /dev/serial0\nDevice information for modem /dev/serial0:\n+---------------------+-------------------------------------------------------------------+\n| Port configuration  | 19200 8N1                                                         |\n| Device model        | ABZ                                                               |\n| Firmware version    | 1.1.1-43-gf86592d2 (modified) [LoRaMac-node 4.6.0-23-g50155c55]   |\n| Data encoding       | binary                                                            |\n| LoRaWAN version     | 1.1.1 / 1.0.4 (1.0.4 for ABP)                                     |\n| Regional parameters | RP002-1.0.3                                                       |\n| Supported regions   | AS923 AU915 CN470 CN779 EU433 EU868 IN865 KR920 RU864 US915       |\n| Device EUI          | 323838377B308503                                                  |\n+---------------------+-------------------------------------------------------------------+\nNetwork activation information for modem /dev/serial0:\n+------------------+------------------+\n| Network type     | public           |\n| Activation       | OTAA             |\n| Network ID       | 00000013         |\n| Join EUI         | 0101010101010101 |\n| Protocol version | LoRaWAN 1.1.1    |\n| Device address   | 260C56AC         |\n+------------------+------------------+\nCurrent state of modem /dev/serial0:\n+---------------------------+-----------------------------------------------------------+\n| Current region            | US915                                                     |\n| LoRaWAN class             | A                                                         |\n| Channel mask              | 00FF00000000000000000000                                  |\n| Data rate                 | SF10_125                                                  |\n| Maximum message size      | 11 B                                                      |\n| RF power index            | 0                                                         |\n| ADR enabled               | True                                                      |\n| Duty cycling enabled      | False                                                     |\n| Join duty cycling enabled | True                                                      |\n| Maximum EIRP              | 32 dBm                                                    |\n| Uplink frame counter      | 2                                                         |\n| Downlink frame counter    | 0                                                         |\n| Last downlink RSSI        | -105 dBm                                                  |\n| Last downlink SNR         | -4 dB                                                     |\n| RX1 window                | Delay: 5000 ms                                            |\n| RX2 window                | Delay: 6000 ms, Frequency: 923.3 MHz, Data rate: SF12_500 |\n| Join response windows     | RX1: 5000 ms, RX2: 6000 ms                                |\n+---------------------------+-----------------------------------------------------------+\n```\nTo see the full list of supported commands, run `lora --help`:\n```\n...\nCommands:\n  device   Show basic modem information.\n  get      Retrieve modem setting(s).\n  join     Perform a LoRaWAN OTAA Join.\n  keygen   Generate new random LoRaWAN security keys.\n  keys     Show current LoRaWAN security keys.\n  link     Check the radio link.\n  network  Show current network activation parameters.\n  reboot   Restart the modem.\n  reset    Reset the modem to factory defaults.\n  set      Update modem setting.\n  state    Show the current modem state.\n  trx      Transmit and receive LoRaWAN messages.\n```\nRun `lora <command> --help` to see the built-in documentation for each command.\n\n## License\n\nThe library is licensed under the terms of the Revised BSD License. See [LICENSE](https://github.com/hardwario/lora-modem/blob/main/python/LICENSE) for full details.\n\nCopyright (c) 2022-2023 Jan Janak \\<jan@janakj.org\\>\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2022 Jan Janak <jan@janakj.org>  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "Python library for the Murata TypeABZ LoRaWAN modem",
    "version": "1.4.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/hardwario/lora-modem/issues",
        "Documentation": "https://github.com/hardwario/lora-modem/wiki",
        "Homepage": "https://github.com/hardwario/lora-modem"
    },
    "split_keywords": [
        "iot",
        " lora",
        " lorawan",
        " lpwan",
        " lorawan-device",
        " firmware",
        " stm32"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "36772c00d7dc0ac81ff6c8bb764570d72af69f41d389dd423deb6f1b294dfe70",
                "md5": "51c30811def917442e030edc29bcb38e",
                "sha256": "c3743cafbe6efbb244f42ad2bf1eb3a8079aeaae753e54fc2506d28c66c3fb5f"
            },
            "downloads": -1,
            "filename": "lora_modem-1.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "51c30811def917442e030edc29bcb38e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 53129,
            "upload_time": "2024-05-18T14:55:03",
            "upload_time_iso_8601": "2024-05-18T14:55:03.310959Z",
            "url": "https://files.pythonhosted.org/packages/36/77/2c00d7dc0ac81ff6c8bb764570d72af69f41d389dd423deb6f1b294dfe70/lora_modem-1.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e382c1d81efb4d8631489039dea5cd011fc552af083bae0b10b94e90a5b8a53a",
                "md5": "1d041eba4b014d6ce3e84d651cb9dc52",
                "sha256": "4c64cd32b5dd980b40c4f65d13bacdf1106e6c7a203f26e2e6aff8448f5f0e5d"
            },
            "downloads": -1,
            "filename": "lora_modem-1.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1d041eba4b014d6ce3e84d651cb9dc52",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 54501,
            "upload_time": "2024-05-18T14:55:05",
            "upload_time_iso_8601": "2024-05-18T14:55:05.197836Z",
            "url": "https://files.pythonhosted.org/packages/e3/82/c1d81efb4d8631489039dea5cd011fc552af083bae0b10b94e90a5b8a53a/lora_modem-1.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-18 14:55:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hardwario",
    "github_project": "lora-modem",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "lora-modem"
}
        
Elapsed time: 0.31954s