简体   繁体   English

Android Beam 和 SNEP 转 pn532

[英]Android Beam and SNEP to pn532

we are trying to send a big file from an android phone to a mikroprocessor via nfc-p2p, android-beam and snep.我们正在尝试通过 nfc-p2p、android-beam 和 snep 将大文件从 android 手机发送到 mikroprocessor。

This is what we have so far.这就是我们迄今为止所拥有的。 I can connect the pn532(target) with the phone(initiator).我可以将 pn532(目标)与电话(发起方)连接起来。 My android app uses setNdefPushMessage to send a NdefMessage via nfc.我的 android 应用程序使用 setNdefPushMessage 通过 nfc 发​​送 NdefMessage。 As soon as i tap the phone(Beam-UI) it starts to connect with SAP 4 on my pn532 and after a readcommand(tgGetData) i receive the following:一旦我点击电话(Beam-UI),它就开始与我的 pn532 上的 SAP 4 连接,在读取命令(tgGetData)之后,我收到以下信息:

00 FF 86 7A D5 87 00 13 20 00 10 02 00 00 03 BD C1 01 00 00 03 B6 54 30 68 61 6C 6C 6F 20 64 61 73 20 69 73 74 20 65 69 6E 20 74 65 73 74 31 68 61 6C 6C 6F 20 64 61 73 20 69 73 74 20 65 69 6E 20 74 65 73 74 32 68 61 6C 6C 6F 20 64 61 73 20 69 73 74 20 65 69 6E 20 74 65 73 74 33 68 61 6C 6C 6F 20 64 61 73 20 69 73 74 20 65 69 6E 20 74 65 73 74 34 68 61 6C 6C 6F 20 64 61 73 20 69 73 74 20 65 69 6E 20 74 65 73 74

To clean it up: PN532 header: 00 FF 86 7A D5 87 00 no MI Bit set!清理:PN532 标头: 00 FF 86 7A D5 87 00未设置 MI 位!
LLCP header: 13 20 00 I-Package from SAP 32 to 4 LLCP 标头: 13 20 00 I-Package from SAP 32 to 4
SNEP header: 10 02 00 00 03 BD version 10 request PUT len 0x3bd SNEP 标头: 10 02 00 00 03 BD版本 10 请求 PUT len 0x3bd
NDEF header: C1 01 00 00 03 B6 54 c1: start+EndMessage NDEF 标头: C1 01 00 00 03 B6 54 c1:start+EndMessage
Message ... the rest留言……剩下的

I made the connect complete with MUI 128.我使用 MUI 128 完成了连接。

my problem: it says the SNEP packae is 0x3BD Bytes long but i only received this short part.我的问题:它说 SNEP 包的长度为 0x3BD 字节,但我只收到了这个短部分。 Nowhere in this message is any indication whether it is a split message.此消息中没有任何指示它是否是拆分消息。

where is the rest of my Data?我的其余数据在哪里? i tried to read more packages from pn532 but there were none.我试图从 pn532 读取更多包,但没有。

** edit: After a night of trying i finally got somewhere. ** 编辑:经过一夜的尝试,我终于到了某个地方。 What worked at least sometimes:(all from the PN532's point of view)什么至少有时有效:(所有从 PN532 的角度来看)
receive: Connect接收:连接
send: Connect complete[MUI=128]发送:连接完成[MUI=128]
receive: SYMM接收:SYMM
send: SYMM发送:SYMM
receive: I first Fragmented Data(as shown above)接收:我先分片数据(如上图)
send: RR发送:RR
receive: SYMM接收:SYMM
send: I SNEP:response CONTINUE发送:我 SNEP:响应 CONTINUE
receive: RR接收:RR
send: I SNEP:request CONTINUE发送:我 SNEP:请求继续
receive: I second Fragmented Data接收:我第二个碎片数据
send: RR发送:RR
receive: RR接收:RR
send: I SNEP:request CONTINUE发送:我 SNEP:请求继续
receive: I third Data Fragment接收:我第三个数据片段

Like I said this only works some times.就像我说的,这只适用于某些时候。 most of the Time my PN532 just responds with an error Code 0x29 -> Initiator droped the Connection.大多数情况下,我的 PN532 只是响应错误代码 0x29 -> 启动器丢弃了连接。 So te Question is can it be a timing problem or what else causes the Connection to be dropped before sending the Rest of the Data.所以问题是它可能是时间问题还是其他什么原因导致在发送其余数据之前断开连接。

SNEP is designed as a simple request/response protocol run on top of an LLCP data link connection (a pair of source and destination SAP established with CONNECT). SNEP 被设计为运行在 LLCP 数据链路连接(使用 CONNECT 建立的一对源和目标 SAP)之上的简单请求/响应协议。 The client requests an operation to be executed by the server and the server returns the response.客户端请求服务器执行一个操作,服务器返回响应。 With a PUT operation the client attaches data to the request.通过 PUT 操作,客户端将数据附加到请求中。 If the request then exceeds the maximum information unit size of an LLCP Information PDU, the client transmits the request in appropriate fragments.如果该请求超过了 LLCP 信息 PDU 的最大信息单元大小,则客户端以适当的片段传输该请求。 The first fragment informs the server of the number of octets it should be prepared to receive from the client.第一个片段通知服务器它应该准备从客户端接收的八位字节数。 If the server is able to receive the data it answers the first fragment with a Continue response, if the data size exceeds the server's capabilities it can stop the exchange with a Reject response.如果服务器能够接收到数据,它会用 Continue 响应回答第一个片段,如果数据大小超过服务器的能力,它可以用 Reject 响应停止交换。 After the client has received a Continue response it will send all remaining fragments without expecting intermediate responses.客户端收到 Continue 响应后,它将发送所有剩余的片段,而无需期待中间响应。 The server finally sends a Success response after having received all request data, as was indicated by the length value.服务器在收到所有请求数据后最终发送成功响应,如长度值所示。 The same principle applies to large SNEP responses, only that Continue or Reject are then request messages (because they are sent by the client).相同的原则适用于大型 SNEP 响应,只有 Continue 或 Reject 是请求消息(因为它们是由客户端发送的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM