Click here to Skip to main content
15,918,808 members

Comments by xiaboyang (Top 3 by date)

xiaboyang 17-Apr-11 10:15am View    
I used "Windows Mobile 5.0 Pocket PC SDK\Samples\CPP\Win32\Bthchat" Sample Code,bluetooth spp service still does not start.

//SDP record generated by bthnscreate.exe
BYTE rgbSdpRecord[] = {
0x35, 0x4d, 0x09, 0x00, 0x01, 0x35, 0x11, 0x1c,
0x29, 0xf9, 0xc0, 0xfd, 0xbb, 0x6e, 0x47, 0x97,
0x9f, 0xa9, 0x3e, 0xc9, 0xa8, 0x54, 0x29, 0x0c,
0x09, 0x00, 0x04, 0x35, 0x0c, 0x35, 0x03, 0x19,
0x01, 0x00, 0x35, 0x05, 0x19, 0x00, 0x03, 0x08,
0x1a, 0x09, 0x00, 0x06, 0x35, 0x09, 0x09, 0x65,
0x6e, 0x09, 0x00, 0x6a, 0x09, 0x01, 0x00, 0x09,
0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11,
0x05, 0x09, 0x01, 0x00, 0x09, 0x01, 0x00, 0x25,
0x06, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c
};

//SDP record size constant returned by bthnscreate.exe
#define SDP_RECORD_SIZE 0x0000004f
#define SDP_CHANNEL_OFFSET 40

int BthUtils::RegisterService(BYTE *rgbSdpRecord, int cSdpRecord, int iChannelOffset, UCHAR channel)
{
ULONG recordHandle = 0;

struct bigBlob
{
BTHNS_SETBLOB b;

}*pBigBlob;

pBigBlob = (bigBlob *)malloc(sizeof(struct bigBlob)+cSdpRecord);
ULONG ulSdpVersion = BTH_SDP_VERSION;
pBigBlob->b.pRecordHandle = &recordHandle;
pBigBlob->b.pSdpVersion = &ulSdpVersion;
pBigBlob->b.fSecurity = 0;
pBigBlob->b.fOptions = 0;
pBigBlob->b.ulRecordLength = cSdpRecord;

memcpy (pBigBlob->b.pRecord, rgbSdpRecord, cSdpRecord);
pBigBlob->b.pRecord[iChannelOffset] = (unsigned char)channel;
BLOB blob;
blob.cbSize = sizeof(BTHNS_SETBLOB) + cSdpRecord - 1;
blob.pBlobData = (PBYTE) pBigBlob;

WSAQUERYSET Service;
memset (&Service, 0, sizeof(Service));
Service.dwSize = sizeof(Service);
Service.lpBlob = &blob;
Service.dwNameSpace = NS_BTH;
if (WSASetService(&Service,RNRSERVICE_REGISTER,0) == SOCKET_ERROR)
{
free(pBigBlob);
return WSAGetLastError();
}
else
{
free(pBigBlob);
return 0;
}
}
xiaboyang 17-Apr-11 10:09am View    
Thank you for your reply.
xiaboyang 17-Apr-11 5:52am View    
Forgive me, my English is very bad, so did not clear. It is in Chinese:这段代码不起作用,SPP服务没有能够正常开启.