py dtn7
1.0.0
DTN7 REST和DTN7-RS的Websocket API的Python包装库。该库包含完全规格的捆绑Bundle类型(但没有片段和CRC支持),该捆绑包允许完整的捆绑包创建和(DE-)序列化。
bundle.py , dtn_rest_client.py , utils.py模块/文件兼容。但是,这需要一些手动库管理。请参阅下面的Micropython安装指南。
要在您的项目中使用py-dtn7 ,只需将其从PYPI中以诗歌的形式安装:
$ poetry install --no-dev py_dtn7这是一个正在进行的工作,迄今为止还不完整。捆绑包的实现非常基本,并且不支持主和有效载荷以外的任何块。
为了生成API文档,请使用pdoc :
$ pdoc ./py_dtn7 --output-directory ./docs...或查看py-dtn7.readthedocs.org
>>> from py_dtn7 import DTNRESTClient
>>> client = DTNRESTClient( host = " http://localhost " , port = 3000 )
>>> d.peers
{'box1': {'eid': [1, '//box1/'], 'addr': {'Ip': '10.0.0.42'}, 'con_type': 'Dynamic', 'period': None, 'cla_list': [['MtcpConvergenceLayer', 16162]], 'services': {}, 'last_contact': 1653316457}}
>>> d.info
{'incoming': 0, 'dups': 0, 'outgoing': 0, 'delivered': 3, 'broken': 0}将捆绑包发送到已知的对等方面时,我们可以简单地提供对等名称和端点,否则我们使用完整的URI:
>>> d.send( payload = { " body " : " This will be transferred as json " }, peer_name = " box1 " , endpoint = " info " )
<Response [200]>
>>> r = d.send( payload = " Is there anybody out there? " , destination = " dtn://greatunkown/incoming " )
>>> r.content.decode( " utf-8 " )
'Sent payload with 27 bytes'要扩展:
虚拟库__future__.py , abc.py , typing.py ,micropython-cbor库(特别是cbor.py模块/文件)和urequests以及datetime :
$ mpremote mip install urequests
$ mpremote mip install datetime