如何使用Windows Phone 10从NFC获取Mac ID。 [英] How to get the Mac id from NFC using windows phone 10.

查看:118
本文介绍了如何使用Windows Phone 10从NFC获取Mac ID。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在开发一个程序,它提取NFC标签的所有细节,尤其是"Mac ID",


我可以从我的Windows Phone 10上的设备上读取NFC标签,我可以获取设备名称,但我无法获取设备ID,请找到下面的代码。


无效NFCConnect()

        {

            device = ProximityDevice.GetDefault();

            device.DeviceArrived + = Device_DeviceArrived;

            device.SubscribeForMessage(" WindowsMime",messageReceived);


}




private void messageReceived(ProximityDevice sender,ProximityMessage message)

        {

            var buffer = message.Data.ToArray();

            int mimesize = 0;

            //首先搜索'\0'charactere

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(mimesize = 0; mimesize< 256&& buffer [mimesize]!= 0; ++ mimesize)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }; b

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //提取mimetype

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; var messageType = Encoding.UTF8.GetString(buffer,0,mimesize);



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //将数据转换为字符串。这取决于mimetype值。

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; var scans_message = Encoding.UTF8.GetString(buffer,256,buffer.Length - 256);  &NBSP; &NBSP; &NBSP;   



  &NBSP; &NBSP; &NBSP; }


OutPut:


application / vnd.bluetooth。 ep.oob\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\ \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\ \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\ \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\ \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\\0 ????\\\%\0\\\
\tDX30-1693\\\\r\0\\\\0\\\\\\\\\\\\"


谢谢,


Praveen.N

解决方案

根据API参考,您可以获得  DeviceId


  ProximityDevice   class
具有以下属性: 















< td style ="padding:10px 8px;颜色:#2a2a2a;垂直对齐:顶部;最小宽度:80px; border:1px solid rgb(187,187,187)">

MinDistanceInMillimeters






DeviceId



只读

获取设备标识符。

MaxDistanceInMillimeters



只读

接近传感器可以检测到对象的最大距离。


可以找到Proximity的详细API参考
here  
可以找到UWP SDK示例 
这里


Hi All,

I am developing a program which extracts all the details of the NFC tag, especially the "Mac ID",

I am able to read the NFC tag from a Device on my windows phone 10, i am able to get the device name but i am not able to get the device id, please find the code below.

void NFCConnect()
        {
            device = ProximityDevice.GetDefault();
            device.DeviceArrived += Device_DeviceArrived;
            device.SubscribeForMessage("WindowsMime", messageReceived);

}

private void messageReceived(ProximityDevice sender, ProximityMessage message)
        {
            var buffer = message.Data.ToArray();
            int mimesize = 0;
            //search first '\0' charactere
            for (mimesize = 0; mimesize < 256 && buffer[mimesize] != 0; ++mimesize)
            {
            };

            //extract mimetype
            var messageType = Encoding.UTF8.GetString(buffer, 0, mimesize);

            //convert data to string. This depends on mimetype value.
            var scanned_message = Encoding.UTF8.GetString(buffer, 256, buffer.Length - 256);          

        }

OutPut:

application/vnd.bluetooth.ep.oob\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\u001c\0?\u0016?%?\0\n\tDX30-1693\u0004\r\0\u001f\0\u0003\u0002\u0001\u0011"

Thanks,

Praveen.N

解决方案

As per the API reference, you can get the DeviceId

The ProximityDevice class has these properties: 

DeviceId

Read-only Gets the device identifier.

MaxDistanceInMillimeters

Read-only The largest distance where the proximity sensor can detect an object.

MinDistanceInMillimeters

You can find detailed API reference for Proximity here and UWP SDK Samples can be found here.


这篇关于如何使用Windows Phone 10从NFC获取Mac ID。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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