用于NFC的接近API - 使用“NDEF”无法发布二进制消息。作为论点 [英] Proximity API for NFC - Fail to PublishBinaryMessage using "NDEF" as the argument

查看:96
本文介绍了用于NFC的接近API - 使用“NDEF”无法发布二进制消息。作为论点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试发布"NDEF:Uri"时遇到了一个问题。通过"PublishBinaryMessage"格式化数据。(我可以通过PublishUriMessage成功发布URI但在这里我想使用NDEF使其他NFC设备兼容)我的代码如下:

Hi, I met a problem when trying to publish an "NDEF:Uri" format data through "PublishBinaryMessage".(I can successfully publish a URI by PublishUriMessage but here I want to use NDEF to make other NFC device compatible) My code is as below:

byte [ ] buff = Encoding.UTF8.GetBytes(MessageTextBox.Text); //从MessageTextBox获取URL字符串

byte[] buff = Encoding.UTF8.GetBytes(MessageTextBox.Text); //get the URL string from MessageTextBox

int count = Encoding.UTF8.GetByteCount(MessageTextBox.Text);

int count = Encoding.UTF8.GetByteCount(MessageTextBox.Text);

IBuffer ibuff = WindowsRuntimeBuffer.Create (buff,0,count,count);

IBuffer ibuff = WindowsRuntimeBuffer.Create(buff, 0, count, count);

publishedMessageId = proximityDevice.PublishBinaryMessage(" NDEF",ibuff);

publishedMessageId = proximityDevice.PublishBinaryMessage("NDEF", ibuff);

会有一个例外:"价值不在预期的范围内" (System.Argument Exception)

There will be an exception: "Value does not fall within the expected rage" (System.Argument Exception)

我是否正确使用此API?有人对这个问题有什么想法/建议吗?谢谢〜

Am I using this API rightly? Anyone has an idea/suggestion on this problem? Thanks~

推荐答案

请注意PublishUriMessage应发布兼容NFC设备的NDEF URI记录。没有必要明确地构造和发布NDEF。您是否尝试过使用PublishUriMessage?

Note that PublishUriMessage should publish an NFC device compatible NDEF URI record. It should not be necessary to construct and publish the NDEF explicitly. Have you tried just using PublishUriMessage?

您使用的是哪些硬件以及驱动程序版本是什么?它看起来也不像你的代码片段会使用格式正确的NDEF记录。司机可能会拒绝不合适NDEF的内容。

What hardware are you using and what driver version? It also doesn't look like your code snippet would be using properly formatted NDEF records. The driver would likely reject content that is not proper NDEF.

-Mike [MSFT]

-Mike [MSFT]


这篇关于用于NFC的接近API - 使用“NDEF”无法发布二进制消息。作为论点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆