Name | libcoapy JSON |
Version |
2024.12.5
JSON |
| download |
home_page | None |
Summary | Python module to communicate over the CoAP protocol |
upload_time | 2024-12-05 18:41:37 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.0 |
license | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
coap
network
libcoap
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
libcoapy
========
libcoapy project enables communication over the CoAP protocol (RFC 7252). The
`llapi` module provides ctypes-based wrappers for the [libcoap](https://libcoap.net/)
C library. The `libcoapy` module uses `llapi` to provide a high-level class interface
to the libcoap functions.
Dependencies:
-------------
- [libcoap](https://libcoap.net/)
- [ifaddr](https://pypi.org/project/ifaddr/) (optional, to query all IPs of an interface)
- [netifaces](https://pypi.org/project/netifaces/) (optional alternative to ifaddr)
Status
------
This project is still in early development. Several functions of the libcoap
library are not yet available and existing high-level libcoapy APIs might change
in the future.
Portability
-----------
libcoapy is a pure python module and the underlying libcoap supports several platforms
like Linux, Windows, MacOS and Android. However, libcoap (and hence libcoapy) does not
support all features on all platforms and with all possible SSL/TLS libraries.
If you want to use libcoapy with asyncio on platforms without epoll, like Windows,
it might be necessary to choose an event loop that supports `add_reader()`. On
Windows you might need to add this to your code before initializing the loop:
```
if sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
```
Tools
-----
* coap-gui - a small Tkinter-based GUI to interact with a CoAP server
* coarl - a CLI tool that provides a similar interface as [curl](https://curl.se/)
Example: client
---------------
```python
from libcoapy import *
if len(sys.argv) < 2:
uri_str = "coap://localhost"
else:
uri_str = sys.argv[1]
ctx = CoapContext()
session = ctx.newSession(uri_str)
def rx_cb(session, tx_msg, rx_msg, mid):
print(rx_msg.payload)
session.ctx.stop_loop()
session.sendMessage(path=".well-known/core", response_callback=rx_cb)
ctx.loop()
```
Example: server
---------------
```python
from libcoapy import *
def echo_handler(resource, session, request, query, response):
response.payload = request.payload
def time_handler(resource, session, request, query, response):
import datetime
now = datetime.datetime.now()
response.payload = str(now)
ctx = CoapContext()
ctx.addEndpoint("coap://[::]")
time_rs = CoapResource(ctx, "time")
time_rs.addHandler(time_handler)
ctx.addResource(time_rs)
echo_rs = CoapResource(ctx, "echo")
echo_rs.addHandler(echo_handler)
ctx.addResource(echo_rs)
ctx.loop()
```
More examples can be found in the `examples` directory.
Raw data
{
"_id": null,
"home_page": null,
"name": "libcoapy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": null,
"keywords": "CoAP, network, libcoap",
"author": null,
"author_email": "Mario Kicherer <dev@kicherer.org>",
"download_url": "https://files.pythonhosted.org/packages/46/f7/107fb672015315f5ff0b9bcd03bb1b2ae320f8e164377783604121bfa334/libcoapy-2024.12.5.tar.gz",
"platform": null,
"description": "libcoapy\n========\n\nlibcoapy project enables communication over the CoAP protocol (RFC 7252). The\n`llapi` module provides ctypes-based wrappers for the [libcoap](https://libcoap.net/)\nC library. The `libcoapy` module uses `llapi` to provide a high-level class interface\nto the libcoap functions.\n\nDependencies:\n-------------\n\n - [libcoap](https://libcoap.net/)\n - [ifaddr](https://pypi.org/project/ifaddr/) (optional, to query all IPs of an interface)\n - [netifaces](https://pypi.org/project/netifaces/) (optional alternative to ifaddr)\n\nStatus\n------\n\nThis project is still in early development. Several functions of the libcoap\nlibrary are not yet available and existing high-level libcoapy APIs might change\nin the future.\n\nPortability\n-----------\n\nlibcoapy is a pure python module and the underlying libcoap supports several platforms\nlike Linux, Windows, MacOS and Android. However, libcoap (and hence libcoapy) does not\nsupport all features on all platforms and with all possible SSL/TLS libraries.\n\nIf you want to use libcoapy with asyncio on platforms without epoll, like Windows,\nit might be necessary to choose an event loop that supports `add_reader()`. On\nWindows you might need to add this to your code before initializing the loop:\n\n```\nif sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):\n\tasyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n```\n\nTools\n-----\n\n* coap-gui - a small Tkinter-based GUI to interact with a CoAP server\n* coarl - a CLI tool that provides a similar interface as [curl](https://curl.se/)\n\nExample: client\n---------------\n\n```python\nfrom libcoapy import *\n\nif len(sys.argv) < 2:\n\turi_str = \"coap://localhost\"\nelse:\n\turi_str = sys.argv[1]\n\nctx = CoapContext()\n\nsession = ctx.newSession(uri_str)\n\ndef rx_cb(session, tx_msg, rx_msg, mid):\n\tprint(rx_msg.payload)\n\tsession.ctx.stop_loop()\n\nsession.sendMessage(path=\".well-known/core\", response_callback=rx_cb)\n\nctx.loop()\n```\n\nExample: server\n---------------\n\n```python\nfrom libcoapy import *\n\ndef echo_handler(resource, session, request, query, response):\n\tresponse.payload = request.payload\n\ndef time_handler(resource, session, request, query, response):\n\timport datetime\n\tnow = datetime.datetime.now()\n\tresponse.payload = str(now)\n\nctx = CoapContext()\nctx.addEndpoint(\"coap://[::]\")\n\ntime_rs = CoapResource(ctx, \"time\")\ntime_rs.addHandler(time_handler)\nctx.addResource(time_rs)\n\necho_rs = CoapResource(ctx, \"echo\")\necho_rs.addHandler(echo_handler)\nctx.addResource(echo_rs)\n\nctx.loop()\n```\n\nMore examples can be found in the `examples` directory.\n",
"bugtrack_url": null,
"license": "Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Python module to communicate over the CoAP protocol",
"version": "2024.12.5",
"project_urls": {
"Homepage": "https://github.com/anyc/libcoapy/",
"Issues": "https://github.com/anyc/libcoapy/issues"
},
"split_keywords": [
"coap",
" network",
" libcoap"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4c4417349a8aef4eec0a1f7a35ebd10211b41d8ee709db4d1851fd4bbba71292",
"md5": "f5b15f2afae8897324525287a2fa8aa8",
"sha256": "3685cb03cf31d2c7d3243dd040cb52fdbd283cc9554208db97399e63c95af3d9"
},
"downloads": -1,
"filename": "libcoapy-2024.12.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f5b15f2afae8897324525287a2fa8aa8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.0",
"size": 25620,
"upload_time": "2024-12-05T18:41:35",
"upload_time_iso_8601": "2024-12-05T18:41:35.316146Z",
"url": "https://files.pythonhosted.org/packages/4c/44/17349a8aef4eec0a1f7a35ebd10211b41d8ee709db4d1851fd4bbba71292/libcoapy-2024.12.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "46f7107fb672015315f5ff0b9bcd03bb1b2ae320f8e164377783604121bfa334",
"md5": "c522dda8ec153b06b7a55dde2beae621",
"sha256": "181f33ab36cea5de3460052d979399157562d7f42b4da312e707629498551ffd"
},
"downloads": -1,
"filename": "libcoapy-2024.12.5.tar.gz",
"has_sig": false,
"md5_digest": "c522dda8ec153b06b7a55dde2beae621",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 25480,
"upload_time": "2024-12-05T18:41:37",
"upload_time_iso_8601": "2024-12-05T18:41:37.179139Z",
"url": "https://files.pythonhosted.org/packages/46/f7/107fb672015315f5ff0b9bcd03bb1b2ae320f8e164377783604121bfa334/libcoapy-2024.12.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-05 18:41:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "anyc",
"github_project": "libcoapy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "libcoapy"
}