{"id":19428818,"url":"https://github.com/love4yzp/loracap","last_synced_at":"2025-07-25T09:12:04.367Z","repository":{"id":221684694,"uuid":"755058901","full_name":"Love4yzp/LoRaCAP","owner":"Love4yzp","description":"LoRaCAP - LoRaE5_Python | Seeed LoRa E5 module Python Library on Raspberry Pi","archived":false,"fork":false,"pushed_at":"2024-02-19T06:29:48.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-19T12:03:21.559Z","etag":null,"topics":["lora","lora-e5","lorawan","lorawan-application","wio-e5"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Love4yzp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-09T11:00:53.000Z","updated_at":"2025-04-15T21:02:39.000Z","dependencies_parsed_at":"2024-02-19T07:40:36.358Z","dependency_job_id":null,"html_url":"https://github.com/Love4yzp/LoRaCAP","commit_stats":null,"previous_names":["love4yzp/lorae5_python","love4yzp/loracap"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Love4yzp/LoRaCAP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Love4yzp%2FLoRaCAP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Love4yzp%2FLoRaCAP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Love4yzp%2FLoRaCAP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Love4yzp%2FLoRaCAP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Love4yzp","download_url":"https://codeload.github.com/Love4yzp/LoRaCAP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Love4yzp%2FLoRaCAP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266983523,"owners_count":24016559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lora","lora-e5","lorawan","lorawan-application","wio-e5"],"created_at":"2024-11-10T14:16:47.078Z","updated_at":"2025-07-25T09:12:04.325Z","avatar_url":"https://github.com/Love4yzp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LoRaE5 Python Code for P2P Communication\n\nThis Python code is designed to facilitate P2P communication using a LoRaE5 module on a Raspberry Pi OS (Linux), leveraging the UART functionality for serial communication. The code provides a framework for sending and receiving data over LoRa, including setup, message formatting, and handling.\n\n## Prerequisites\n\n- A Raspberry Pi with Raspberry Pi OS installed.\n- A LoRaE5 module connected to the Raspberry Pi via UART.\n- Python 3.x installed on the Raspberry Pi.\n\n## Key Components of the Code\n\n- **Serial Communication Setup**: Establishes communication with the LoRaE5 module using the `serial` library.\n\u003c!-- - **LoRaE5 Macro Definitions**: Includes specific settings such as baud rate and timeout values for the LoRaE5 module, defined in `marcos.py`.\n- **Regular Expressions for Data Parsing**: Uses the `re` library to parse and extract hexadecimal values from received messages. --\u003e\n\n### Steps to Implement P2P Communication\n\n1. **Hardware Setup**:\n   - Connect the LoRaE5 module to the Raspberry Pi via the UART pins.\n   - Ensure the module is powered and correctly wired to the Pi's GPIO pins for serial communication.\n\n2. **Software Setup**:\n   - Install necessary Python libraries: `pySerial` for serial communication and `threading` for concurrent operations.\n   - Define the communication parameters, such as the baud rate and serial port, matching your hardware setup.\n\n3. **Send a Message**:\n   - Use the `fetch` or `command` method to send a message.\n\n## Example Use Case\n\n### Switch Mode\n```Python\nfrom loracap.LoRaMode import *\n\nclass Switch(LoRaMode):\n    def __init__(self):\n        super(LoRaMode, self).__init__()\n    def handle_line(self, line):\n        \"\"\"\n        We don't need any events for this example.\n        \"\"\"\n        self.responses.put(line)\n \nser = serial.serial_for_url('/dev/ttyS0', baudrate=9600, timeout=1)\nwith serial.threaded.ReaderThread(ser, Switch) as lorae5:\n   print(f\"Current Mode: {lorae5.mode}\")\n   \n   print(\"Change to LWOTAA Mode\")\n   lorae5.mode = 'LWOTAA'\n   \n   print(\"Change to LWABP Mode\")\n   lorae5.mode = 'LWABP'\n\n   print(\"Change to TEST Mode\")\n   lorae5.mode = 'TEST'\n   print(f\"Current Mode: {lorae5.mode}\")\n```\n```shell\nCurrent Mode: LWOTAA\nChange to LWOTAA Mode\nChange to LWABP Mode\nChange to TEST Mode\nCurrent Mode: TEST\n```\n### Update Credential of LoRa-E5\n```Python\nfrom loracap.LoRaMode import *\n\nser = serial.serial_for_url('/dev/ttyS0', baudrate=9600, timeout=1)\nread_thread = serial.threaded.ReaderThread(ser, LoRaTESTMode)\nread_thread.start()\n_thread, lorae5 = read_thread.connect()\n\nprint(\"Credentials: \\n{}\\n\".format(lorae5)) \n\nprint(\"Updating credentials...\")\n# lorae5.DevEui = '2CF7F12053700006'\nlorae5.DevEui = '2C:F7:F1:20:53:70:00:06'\n# lorae5.DevAddr = '3230C9A3'\nlorae5.DevAddr = '32:30:C9:A3'\n# lorae5.AppEui = '8000000000000009'\nlorae5.AppEui = '80:00:00:00:00:00:00:09'\n\nprint(\"Credentials updated!\\n{}\".format(lorae5))\n```\n```shell\nCredentials: \nDevEui: 2C:F7:F1:20:53:77:88:99, DevAddr: 42:33:55:A4, AppEui: 80:00:00:00:FF:00:00:10\n\nUpdating credentials...\nCredentials updated!\nDevEui: 2C:F7:F1:20:53:70:00:06, DevAddr: 32:30:C9:A3, AppEui: 80:00:00:00:00:00:00:09\n```\n\n## Virtual Environment Usage\n\nThis project is managed with Poetry, which supports both virtual environments for isolation and direct system-wide installation. You can choose the approach that best fits your workflow.\n\n### Without Using a Virtual Environment\n\nIf you prefer not to use a virtual environment, ensure your system has the required Python version and dependencies. This method may lead to conflicts with other Python projects or system packages.\n\n### Install Poetry\n\nTo install Poetry, execute:\n\n```shell\ncurl -sSL https://install.python-poetry.org | python3 -\n```\n\n### Setup the Project with a Virtual Environment\n\n1. **Install Dependencies**: In the project directory, run:\n\n   ```shell\n   poetry install\n   ```\n\n   This command installs dependencies and optionally sets up a virtual environment.\n\n2. **Activate the Virtual Environment**: To avoid conflicts with the system-wide Python interpreter and ensure project dependencies are managed separately, activate the virtual environment:\n\n   ```shell\n   poetry shell\n   ```\n\nUsing a virtual environment is recommended to isolate project dependencies, providing a controlled development environment and minimizing potential conflicts.\n\nFor more details, visit [Poetry's official documentation](https://python-poetry.org/docs/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flove4yzp%2Floracap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flove4yzp%2Floracap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flove4yzp%2Floracap/lists"}