iqrfpy


Nameiqrfpy JSON
Version 0.2.10 PyPI version JSON
download
home_pagehttps://gitlab.iqrf.org/open-source/iqrf-sdk/iqrfpy/iqrfpy
SummaryA python library for communication with IQRF Network
upload_time2024-09-15 09:47:15
maintainerNone
docs_urlNone
authorKarel Hanák
requires_python>=3.10
licenseApache-2.0
keywords iqrf dpa
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## What is iqrfpy?

iqrfpy is a library that provides a python API for interacting with the IQRF network
utilizing the [DPA framework](https://doc.iqrf.org/DpaTechGuide/) (DPA) or IQRF Gateway Daemon (Daemon) [JSON API](https://docs.iqrf.org/iqrf-gateway/user/daemon/api). Communication between a python runtime and the IQRF network is facilitated by transports.

For communication with Daemon, only the MQTT transport is implemented at this time.
However, this library provides an abstract transport class, allowing for custom communication implementations.

The library provides classes for serialization of requests and deserialization of responses to message class objects.

## Quick start

Before installing the library, it is recommended to first create a virtual environment.
Virtual environments help isolate python installations as well as pip packages independent of the operating system.

A virtual environment can be created and launched using the following commands:

```bash
python3 -m venv <dir>
source <dir>/bin/activate
```

iqrfpy can be installed using the pip utility:

```bash
python3 -m pip install -U iqrfpy
```

### Serialize requests to DPA:
```python
from iqrfpy.peripherals.coordinator.requests.addr_info import AddrInfoRequest

req = AddrInfoRequest()
req_packet = req.to_dpa()
print(req_packet)
```

### Serialize requests to JSON:
```python
from iqrfpy.peripherals.coordinator.requests.addr_info import AddrInfoRequest

req = AddrInfoRequest()
json_req = req.to_json()
print(json_req)
```

### Parse DPA responses:
```python
from iqrfpy.peripherals.coordinator.responses import AddrInfoResponse
from iqrfpy.response_factory import ResponseFactory

def handle_addr_info_response(response: AddrInfoResponse) -> None:
    print(f'peripheral: {response.pnum}')
    print(f'peripheral command: {response.pcmd}')
    status = response.rcode
    if status == 0:
        print(f'Addr info response dev_nr: {response.dev_nr}')
        print(f'Addr info response did: {response.did}')


dpa_rsp_packet = b'\x00\x00\x00\x80\x00\x00\x00\x40\x0a\x2a'
dpa_rsp = ResponseFactory.get_response_from_dpa(dpa=dpa_rsp_packet)
handle_addr_info_response(response=dpa_rsp)
```

### Parse JSON responses:
```python
from iqrfpy.peripherals.coordinator.responses import AddrInfoResponse
from iqrfpy.response_factory import ResponseFactory

def handle_addr_info_response(response: AddrInfoResponse) -> None:
    print(f'peripheral: {response.pnum}')
    print(f'peripheral command: {response.pcmd}')
    status = response.rcode
    if status == 0:
        print(f'Addr info response dev_nr: {response.dev_nr}')
        print(f'Addr info response did: {response.did}')


daemon_rsp_json = {
    "mType": "iqrfEmbedCoordinator_AddrInfo",
    "data": {
        "msgId": "testEmbedCoordinator",
        "rsp": {
            "nAdr": 0,
            "hwpId": 0,
            "rCode": 0,
            "dpaVal": 64,
            "result": {
                "devNr": 0,
                "did": 42
            }
        },
        "insId": "iqrfgd2-1",
        "status": 0
    }
}
json_rsp = ResponseFactory.get_response_from_json(json=daemon_rsp_json)
handle_addr_info_response(response=json_rsp)
```

## Documentation

For more information, check out our [API reference](https://apidocs.iqrf.org/iqrfpy/latest/iqrfpy.html).

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.iqrf.org/open-source/iqrf-sdk/iqrfpy/iqrfpy",
    "name": "iqrfpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "iqrf, dpa",
    "author": "Karel Han\u00e1k",
    "author_email": "karel.hanak@iqrf.org",
    "download_url": "https://files.pythonhosted.org/packages/3a/46/eb1690a405f61cf9852b1db4a2f721f2769c2962443370e3ee313f686526/iqrfpy-0.2.10.tar.gz",
    "platform": null,
    "description": "## What is iqrfpy?\n\niqrfpy is a library that provides a python API for interacting with the IQRF network\nutilizing the [DPA framework](https://doc.iqrf.org/DpaTechGuide/) (DPA) or IQRF Gateway Daemon (Daemon) [JSON API](https://docs.iqrf.org/iqrf-gateway/user/daemon/api). Communication between a python runtime and the IQRF network is facilitated by transports.\n\nFor communication with Daemon, only the MQTT transport is implemented at this time.\nHowever, this library provides an abstract transport class, allowing for custom communication implementations.\n\nThe library provides classes for serialization of requests and deserialization of responses to message class objects.\n\n## Quick start\n\nBefore installing the library, it is recommended to first create a virtual environment.\nVirtual environments help isolate python installations as well as pip packages independent of the operating system.\n\nA virtual environment can be created and launched using the following commands:\n\n```bash\npython3 -m venv <dir>\nsource <dir>/bin/activate\n```\n\niqrfpy can be installed using the pip utility:\n\n```bash\npython3 -m pip install -U iqrfpy\n```\n\n### Serialize requests to DPA:\n```python\nfrom iqrfpy.peripherals.coordinator.requests.addr_info import AddrInfoRequest\n\nreq = AddrInfoRequest()\nreq_packet = req.to_dpa()\nprint(req_packet)\n```\n\n### Serialize requests to JSON:\n```python\nfrom iqrfpy.peripherals.coordinator.requests.addr_info import AddrInfoRequest\n\nreq = AddrInfoRequest()\njson_req = req.to_json()\nprint(json_req)\n```\n\n### Parse DPA responses:\n```python\nfrom iqrfpy.peripherals.coordinator.responses import AddrInfoResponse\nfrom iqrfpy.response_factory import ResponseFactory\n\ndef handle_addr_info_response(response: AddrInfoResponse) -> None:\n    print(f'peripheral: {response.pnum}')\n    print(f'peripheral command: {response.pcmd}')\n    status = response.rcode\n    if status == 0:\n        print(f'Addr info response dev_nr: {response.dev_nr}')\n        print(f'Addr info response did: {response.did}')\n\n\ndpa_rsp_packet = b'\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x40\\x0a\\x2a'\ndpa_rsp = ResponseFactory.get_response_from_dpa(dpa=dpa_rsp_packet)\nhandle_addr_info_response(response=dpa_rsp)\n```\n\n### Parse JSON responses:\n```python\nfrom iqrfpy.peripherals.coordinator.responses import AddrInfoResponse\nfrom iqrfpy.response_factory import ResponseFactory\n\ndef handle_addr_info_response(response: AddrInfoResponse) -> None:\n    print(f'peripheral: {response.pnum}')\n    print(f'peripheral command: {response.pcmd}')\n    status = response.rcode\n    if status == 0:\n        print(f'Addr info response dev_nr: {response.dev_nr}')\n        print(f'Addr info response did: {response.did}')\n\n\ndaemon_rsp_json = {\n    \"mType\": \"iqrfEmbedCoordinator_AddrInfo\",\n    \"data\": {\n        \"msgId\": \"testEmbedCoordinator\",\n        \"rsp\": {\n            \"nAdr\": 0,\n            \"hwpId\": 0,\n            \"rCode\": 0,\n            \"dpaVal\": 64,\n            \"result\": {\n                \"devNr\": 0,\n                \"did\": 42\n            }\n        },\n        \"insId\": \"iqrfgd2-1\",\n        \"status\": 0\n    }\n}\njson_rsp = ResponseFactory.get_response_from_json(json=daemon_rsp_json)\nhandle_addr_info_response(response=json_rsp)\n```\n\n## Documentation\n\nFor more information, check out our [API reference](https://apidocs.iqrf.org/iqrfpy/latest/iqrfpy.html).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A python library for communication with IQRF Network",
    "version": "0.2.10",
    "project_urls": {
        "Changelog": "https://apidocs.iqrf.org/iqrfpy/latest/iqrfpy.html#changelog",
        "Documentation": "https://apidocs.iqrf.org/iqrfpy/latest/iqrfpy.html",
        "Homepage": "https://gitlab.iqrf.org/open-source/iqrf-sdk/iqrfpy/iqrfpy",
        "Issues tracker": "https://gitlab.iqrf.org/open-source/iqrf-sdk/libiqrf-python/-/issues",
        "Source code": "https://gitlab.iqrf.org/open-source/iqrf-sdk/libiqrf-python"
    },
    "split_keywords": [
        "iqrf",
        " dpa"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a0322151aeff27c450a77df4231bb23efa29b7d085e45f1899f1bbfed4fd422",
                "md5": "297bd2fb8a754e0946fca57052d48e43",
                "sha256": "1c2b7289b656d4e227e9b4b4fe0ac7273cceebe97dc61fbe0f4f3adf42643354"
            },
            "downloads": -1,
            "filename": "iqrfpy-0.2.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "297bd2fb8a754e0946fca57052d48e43",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 276049,
            "upload_time": "2024-09-15T09:47:12",
            "upload_time_iso_8601": "2024-09-15T09:47:12.805177Z",
            "url": "https://files.pythonhosted.org/packages/1a/03/22151aeff27c450a77df4231bb23efa29b7d085e45f1899f1bbfed4fd422/iqrfpy-0.2.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a46eb1690a405f61cf9852b1db4a2f721f2769c2962443370e3ee313f686526",
                "md5": "39acc800fefe30db76ddfed221d85f97",
                "sha256": "62a509622783a865f47ae0adf52f9baf8474fc6265f923e303fd966b0ad58297"
            },
            "downloads": -1,
            "filename": "iqrfpy-0.2.10.tar.gz",
            "has_sig": false,
            "md5_digest": "39acc800fefe30db76ddfed221d85f97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 109060,
            "upload_time": "2024-09-15T09:47:15",
            "upload_time_iso_8601": "2024-09-15T09:47:15.113665Z",
            "url": "https://files.pythonhosted.org/packages/3a/46/eb1690a405f61cf9852b1db4a2f721f2769c2962443370e3ee313f686526/iqrfpy-0.2.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-15 09:47:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "iqrfpy"
}
        
Elapsed time: 0.34951s