RSS
热门关键字:
当前位置 :| 主页>Mobile Development>

Develop module of communication of.NET CF blue tooth with C#

来源: 作者:Stand originally 时间:2008-12-21 Tag: 点击:


Because be the development that makes in the light of blue tooth, so we should examine these parameter should be what value. Say in the SDK of Windows CE 4.2, when blue tooth is developed, following members in Struct LPWSAQUERYSET ought to be these values:

The DwSize Member Must Be Sizeof(WSAQUERYSET) .

The LpBlob Member (itself A Pointer To A BLOB Structure) Is Optional, but If Used, the Device Inquire Parameters Valid For LUP_FLUSHCACHE Are The Following:

The CbSize Member Of The BLOB Structure Must Be Sizeof(BTH_QUERY_DEVICE) .

The PBlobData Member Is A Pointer To A BTH_QUERY_DEVICE Structure, for Which The LAP Member Is The Bluetooth Inquiry Access Code, and The Length Member Is The Length Of The Inquiry, in Seconds.

The DwNameSpace Member Must Be NS_BTH.

All Other WSAQUERYSET Members Are Ignored.

Everybody of specific what meaning is OK oneself go understand, it is good that I want to come out to want than my interpreter some, after all my English is very poor. According to above requirement, we assemble PQuerySet so:
Byte[] Buffer1 = New Byte[0x400];

BitConverter.GetBytes(60).CopyTo(buffer1, 0);

GCHandle Handle1 = GCHandle.Alloc(blob1.ToByteArray() , GCHandleType.Pinned);

IntPtr Ptr1 = Handle1.AddrOfPinnedObject();

BitConverter.GetBytes((int) (ptr1.ToInt32() 4)).CopyTo(buffer1, 0x38);

Two another API also are called according to similar method can.

After calling WSALookupServiceNext, the address information of long-range equipment was contained in Bytes array PQuerySet, we need to look for it below. The specification that adopts structure of the WSAQUERYSET in reading SDK and computation after the position of every member, we draw up as follows code:
Int Num5 = BitConverter.ToInt32(buffer1, 0x30);
Int Num6 = Marshal.ReadInt32((IntPtr) Num5, 8);
Int Num7 = Marshal.ReadInt32((IntPtr) Num5, 12);

SocketAddress Address1 = New SocketAddress(AddressFamily.Unspecified, num7);

Because of.net frame there is blue tooth inside address a group of things with common features, what use here so is AddressFamily.Unspecified.

The next ID that work even if gets long-range equipment from which:

We had been calculated in front piece, before 6 byte inside this Address are the equipment ID of Byte array form, the 7th to the 22nd Service Guid that byte is blue tooth, at the back 4 byte are port date, so we need to be extracted respectively only can.

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表
热点关注
相关文章