Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question on WSASetService for Bluetooth Service

254 views
Skip to first unread message

KK Hung

unread,
Jul 13, 2003, 11:36:22 PM7/13/03
to
Dear all,
I am writing an bluetooth application and need to advertize some
services. I decide to build up my own SDP record and pass it to
WSASetService. However, I always get error code WSAEINVAL (10022) returned.
Does any one have called the WSASetService with own SDP record successfully?
If so, would you please send me some sample code on it?
Thanks a lot for your attention and kind help.
Yours,
KK


Doron Holan [MS]

unread,
Jul 14, 2003, 1:36:24 AM7/14/03
to
can you post the SDP record you are trying to add (preferrably in readable
form, not binary). also, email bt...@microsoft.com and ask for the
sdpverify.exe tool. You can input your record into this tool and see what
is wrong with it.

d

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"KK Hung" <kkh...@avantwave.com> wrote in message
news:Ov0r7kbS...@TK2MSFTNGP11.phx.gbl...

KK Hung

unread,
Jul 14, 2003, 2:23:30 AM7/14/03
to
Dear all,
Below is the SDP binary record (with explanion embedded). Would you
please help me to take a look on it? Thanks a lot for your kind help.
Yours,
KK
====== SDP Binary Data Attached ======

SDP Binary Data Meaning
=============================================
0x09 0x00 0x01 Service Class ID List
0x35 0x03 Data Sequence [3 bytes]
0x19 0x11 0x05 OBEXObjectPushServiceClassID_UUID16 [0x1105]

0x09 0x00 0x04 Protocol Descriptor List
0x35 0x11 Data Sequence [17 bytes]
0x35 0x03 Protocol ID #0 [3 bytes]
0x19 0x01 0x00 L2CAP_PROTOCOL_UUID16 [0x0100]
0x35 0x05 Protocol ID #1 [5 bytes]
0x19 0x00 0x03 RFCOMM_PROTOCOL_UUID16 [0x0003]
0x08 0x01 Channel 1
0x35 0x03 Protocol ID #2 [3 bytes]
0x19 0x00 0x08 OBEX_PROTOCOL_UUID16 [0x0008]

0x09 0x01 0x00 Service Name
0x25 0x11 Text String [17 bytes]
0x4F 0x42 0x45 0x58 0x20 "OBEX Push Service"
0x50 0x75 0x73 0x68 0x20
0x53 0x65 0x72 0x76 0x69
0x63 0x65

0x09 0x00 0x09 Bluetooth Profile Descriptor List
0x35 0x08 Data Sequence [8 bytes]
0x35 0x06 Data Sequence [6 bytes]
0x19 0x11 0x05 OBEXObjectPushServiceClassID_UUID16 [0x1105]
0x09 0x01 0x00 Version 0x0100

0x09 0x03 0x03 Supported Formats List
0x35 0x02 Data Sequence [2 bytes]
0x08 0x01 vCard 2.1 [0x01]

"Doron Holan [MS]" <dor...@online.microsoft.com> wrote in message
news:ur#MdncSD...@tk2msftngp13.phx.gbl...

Doron Holan [MS]

unread,
Jul 14, 2003, 11:27:19 AM7/14/03
to
your protocol descriptor list is missing a few sequences, it should look
like

SEQUENCE
SEQUENCE
UUID (l2cap)
SEQUENCE
UUID (RFCOMM)
UINT8 (channel number)
SEQUENCE
UUID (OBEX)

where each indented line is an element of the sequence that has one less
indent. basically, a protocol descriptor list has a SEQUENCE where each
element in it is a PROTOCOL DESCRIPTOR LIST. A PROTOCOL DESCRIPTOR LIST is
defined as a SEQUENCE whose first element must be a UUID (any size) follow
by any number (including zero) optional elements of an type.

d

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"KK Hung" <kkh...@avantwave.com> wrote in message

news:eHFAVCdS...@TK2MSFTNGP11.phx.gbl...

KK Hung

unread,
Jul 14, 2003, 9:53:43 PM7/14/03
to
Dear Doron and others,
May be my previous explanation quoted is misleading...
Actually, the protocol descriptor list is actually in the form you
mentioned below...
The part ot descriptor is shown below:

0x09 0x00 0x04 Protocol Descriptor List
0x35 0x11 Data Sequence [17 bytes]

0x35 0x03 Protocol ID #0 [3 bytes] <======== Data Sequence


0x19 0x01 0x00 L2CAP_PROTOCOL_UUID16 [0x0100]

0x35 0x05 Protocol ID #1 [5 bytes] <======== Data Sequence


0x19 0x00 0x03 RFCOMM_PROTOCOL_UUID16 [0x0003]
0x08 0x01 Channel 1

0x35 0x03 Protocol ID #2 [3 bytes] <======== Data Sequence


0x19 0x00 0x08 OBEX_PROTOCOL_UUID16 [0x0008]

Thanks a lot for your kind help.
Yours,
KK

"Doron Holan [MS]" <dor...@online.microsoft.com> wrote in message
news:eHu$pxhSDH...@tk2msftngp13.phx.gbl...

Doron Holan [MS]

unread,
Jul 15, 2003, 2:05:24 AM7/15/03
to
email bt...@microsoft.com, someone should be able to run your record through
sdpverify.exe or give you the tool.

d

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"KK Hung" <kkh...@avantwave.com> wrote in message

news:%23TAGQQn...@tk2msftngp13.phx.gbl...

KK Hung

unread,
Jul 15, 2003, 3:28:37 AM7/15/03
to
Dear Doron and others,
Thanks for your suggestion. I had already requested and got the
sdpverify.exe... But I encounter some problems in using it...
1. What is the file extension and format for "Profile Verification
Information Files" ?
2. In loading the binary file containing SDP record, an error message
"Could not open section [Version] and read the Service Key" always appear.
What records should I missed or what format should my file be?
I would also like to ask is there any tools available for us to use? Any
more suggestion?
Thanks for your attention and kind help.
Yours,
KK

"Doron Holan [MS]" <dor...@online.microsoft.com> wrote in message
news:#ao6UcpS...@tk2msftngp13.phx.gbl...

KK Hung

unread,
Jul 15, 2003, 3:44:50 AM7/15/03
to
Dear Doron and all,
Attached below is part of my source code and SDP record for advertising
the SDP service, would you please help me to find out what's wrong inside

it?
Thanks a lot for your attention and kind help.
Yours,
KK

====== Source Code Attached ======
BTCon::Result
BTCon::Listen( char* pSDPRecord,
int sdpRecordSize)
{
int wsaResult;
int sockAddrLen;
WSAQUERYSET wsaQuerySet;
PBTH_SET_SERVICE pBTHSetService;
ULONG sdpVersion = BTH_SDP_VERSION;
HANDLE sdpRecordHandle = NULL;
BLOB blob;
Result result;

m_btSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
if (m_btSocket == INVALID_SOCKET)
{
DEBUG_MSG( DEBUG_AREA_BTCON,
DEBUG_LEVEL_WARNING,
"Listen: socket failed(%d)\n",
WSAGetLastError());
result = FAIL;
goto SocketFailed;
}

ZeroMemory(&m_sockAddr, sizeof(SOCKADDR_BTH));
m_sockAddr.addressFamily = AF_BTH;
m_sockAddr.port = BT_PORT_ANY;
wsaResult = bind( m_btSocket,
(struct sockaddr*)&m_sockAddr,
sizeof(SOCKADDR_BTH));
if (wsaResult == SOCKET_ERROR)
{
DEBUG_MSG( DEBUG_AREA_BTCON,
DEBUG_LEVEL_WARNING,
"Listen: bind failed(%d)\n",
WSAGetLastError());
result = FAIL;
goto BindFailed;
}

sockAddrLen = sizeof(SOCKADDR_BTH);
wsaResult = getsockname(m_btSocket,
(struct sockaddr*)&m_sockAddr,
&sockAddrLen);
if (wsaResult == SOCKET_ERROR)
{
DEBUG_MSG( DEBUG_AREA_BTCON,
DEBUG_LEVEL_WARNING,
"Listen: getsockname failed(%d)\n",
WSAGetLastError());
result = FAIL;
goto GetSockNameFailed;
}
printf("BTCon: channel %d assigned\n", m_sockAddr.port);

wsaResult = listen(m_btSocket, SOMAXCONN);
if (wsaResult == SOCKET_ERROR)
{
DEBUG_MSG( DEBUG_AREA_BTCON,
DEBUG_LEVEL_WARNING,
"Listen: listen failed(%d)\n",
WSAGetLastError());
result = FAIL;
goto ListenFailed;
}

ZeroMemory(&wsaQuerySet, sizeof(WSAQUERYSET));
wsaQuerySet.dwSize = sizeof(WSAQUERYSET);
wsaQuerySet.dwNameSpace = NS_BTH;

pBTHSetService = (PBTH_SET_SERVICE)malloc(sizeof(BTH_SET_SERVICE) +
sdpRecordSize);
if (pBTHSetService != NULL)
{
ZeroMemory(pBTHSetService, sizeof(BTH_SET_SERVICE));
pBTHSetService->pSdpVersion = &sdpVersion;
pBTHSetService->pRecordHandle = &sdpRecordHandle;

#if 0
SET_COD_MAJOR( pBTHSetService->fCodService,
COD_MAJOR_COMPUTER);
SET_COD_MINOR( pBTHSetService->fCodService,
COD_COMPUTER_MINOR_DESKTOP);
SET_COD_SERVICE(pBTHSetService->fCodService,
COD_SERVICE_OBJECT_XFER);
#else
pBTHSetService->fCodService = COD_SERVICE_OBJECT_XFER;
#endif

pBTHSetService->ulRecordLength = sdpRecordSize;
memcpy(pBTHSetService->pRecord, pSDPRecord, sdpRecordSize);

blob.cbSize = sizeof(BTH_SET_SERVICE) + sdpRecordSize - 1;
blob.pBlobData = (BYTE*)pBTHSetService;

wsaQuerySet.lpBlob = &blob;
}

wsaResult = WSASetService(&wsaQuerySet, RNRSERVICE_REGISTER, 0);
if (wsaResult == SOCKET_ERROR)
{
DEBUG_MSG( DEBUG_AREA_BTCON,
DEBUG_LEVEL_WARNING,
"Listen: WSASetService failed(%d)\n",
WSAGetLastError());
result = FAIL;
goto WSASetServiceFailed;
}

return SUCCESS;

/****** Error Part ******/
WSASetServiceFailed:
ListenFailed:
GetSockNameFailed:
BindFailed:
ASSERT(m_btSocket != INVALID_SOCKET);
closesocket(m_btSocket);
m_btSocket = INVALID_SOCKET;

SocketFailed:
AlreadyConnected:
return result;
}

====== Binary SDP Record ======


SDP Binary Data Meaning
=============================================
0x09 0x00 0x01 Service Class ID List
0x35 0x03 Data Sequence [3 bytes]
0x19 0x11 0x05 OBEXObjectPushServiceClassID_UUID16 [0x1105]

0x09 0x00 0x04 Protocol Descriptor List
0x35 0x11 Data Sequence [17 bytes]
0x35 0x03 Data Sequence [3 bytes]

0x19 0x01 0x00 L2CAP_PROTOCOL_UUID16 [0x0100]

0x35 0x05 Data Sequence [5 bytes]


0x19 0x00 0x03 RFCOMM_PROTOCOL_UUID16 [0x0003]
0x08 0x01 Channel 1

0x35 0x03 Data Sequence [3 bytes]

0x19 0x00 0x08 OBEX_PROTOCOL_UUID16 [0x0008]

0x09 0x01 0x00 Service Name
0x25 0x11 Text String [17 bytes]
0x4F 0x42 0x45 0x58 0x20 "OBEX Push Service"
0x50 0x75 0x73 0x68 0x20
0x53 0x65 0x72 0x76 0x69
0x63 0x65

0x09 0x00 0x09 Bluetooth Profile Descriptor List
0x35 0x08 Data Sequence [8 bytes]
0x35 0x06 Data Sequence [6 bytes]
0x19 0x11 0x05 OBEXObjectPushServiceClassID_UUID16 [0x1105]
0x09 0x01 0x00 Version 0x0100

0x09 0x03 0x03 Supported Formats List
0x35 0x02 Data Sequence [2 bytes]
0x08 0x01 vCard 2.1 [0x01]

"KK Hung" <kkh...@avantwave.com> wrote in message
news:O2CRZLqS...@TK2MSFTNGP12.phx.gbl...

Doron Holan [MS]

unread,
Jul 16, 2003, 2:25:09 AM7/16/03
to
send your errors and code to bthfb. the profile verification information
files are a variant of INI files; you don't really need to write your own
since the attribute that is failing is a universal attribute (PVIs verify
profile specific custom attributes >= 0x200)

d

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"KK Hung" <kkh...@avantwave.com> wrote in message

news:O2CRZLqS...@TK2MSFTNGP12.phx.gbl...

0 new messages