没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
154页
用于近场通信的 Python 模块 本文档涵盖 nfcpy的“1.0.4”版本。还有其他版本。 nfcpy模块实现NFC 论坛规范,用于与 NFC 设备和标签进行无线短距离数据交换。它是用Python编写的,旨在为集成 NFC 的应用程序提供易于使用但功能强大的框架。最新的发布版本可以从PyPI安装,带有.pip install -U nfcpy
资源推荐
资源详情
资源评论
nfcpy documentation
Release 1.0.4
Stephen Tiedemann
March 10, 2022
Contents
1 Overview 3
1.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Supported Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Implementation Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Getting started 7
2.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Open a local device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Read and write tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Emulate a card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5 Work with a peer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3 Logical Link Control Protocol 15
4 Simple NDEF Exchange Protocol 19
4.1 Default Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2 Using SNEP Put . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3 Private Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5 Example Programs 25
5.1 tagtool.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.2 beam.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.3 sense.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.4 listen.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.5 rfstate.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6 Interoperability Tests 47
6.1 Logical Link Control Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2 Simple NDEF Exchange Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
6.3 Connection Handover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6.4 Personal Health Device Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.5 Generate Test Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
7 Module Reference 75
7.1 nfc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
7.2 nfc.clf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
i
7.3 nfc.tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
7.4 nfc.llcp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
7.5 nfc.snep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.6 nfc.handover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Python Module Index 139
Index 141
ii
nfcpy documentation, Release 1.0.4
This documentation covers the ‘1.0.4’ version of nfcpy. There are also other versions.
The nfcpy module implements NFC Forum specifications for wireless short-range data exchange with NFC devices
and tags. It is written in Python and aims to provide an easy-to-use yet powerful framework for applications integrating
NFC. The source code is licensed under the EUPL and hosted at GitHub. The latest release version can be installed
from PyPI with pip install -U nfcpy.
To send a web link to a smartphone:
import nfc
import ndef
from threading import Thread
def beam(llc):
snep_client = nfc.snep.SnepClient(llc)
snep_client.put_records([ndef.UriRecord('http://nfcpy.org')])
def connected(llc):
Thread(target=beam, args=(llc,)).start()
return True
with nfc.ContactlessFrontend('usb') as clf:
clf.connect(llcp={'on-connect': connected})
There are also a number of Example Programs that can be used from the command line:
$ examples/beam.py send link http://nfcpy.org
Contents 1
剩余153页未读,继续阅读
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9157
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功