Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lufa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
587f3203
Commit
587f3203
authored
14 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Add Service Attribute request processing to the SDP server code.
parent
e15838d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
+100
-1
100 additions, 1 deletion
...t/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
with
100 additions
and
1 deletion
Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c
+
100
−
1
View file @
587f3203
...
@@ -314,7 +314,106 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Blu
...
@@ -314,7 +314,106 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Blu
*/
*/
static
void
SDP_ProcessServiceAttribute
(
const
SDP_PDUHeader_t
*
const
SDPHeader
,
Bluetooth_Channel_t
*
const
Channel
)
static
void
SDP_ProcessServiceAttribute
(
const
SDP_PDUHeader_t
*
const
SDPHeader
,
Bluetooth_Channel_t
*
const
Channel
)
{
{
const
void
*
CurrentParameter
=
((
void
*
)
SDPHeader
+
sizeof
(
SDP_PDUHeader_t
));
BT_SDP_DEBUG
(
1
,
"<< Service Attribute"
);
BT_SDP_DEBUG
(
1
,
"<< Service Attribute"
);
/* Retrieve the service handle whose attributes are to be examined */
uint32_t
ServiceHandle
=
SwapEndian_32
(
*
((
uint16_t
*
)
CurrentParameter
));
CurrentParameter
+=
sizeof
(
uint32_t
);
BT_SDP_DEBUG
(
2
,
"-- Service Handle: 0x%08lX"
,
ServiceHandle
);
/* Retrieve the maximum Attribute reponse size from the request */
uint16_t
MaxAttributeSize
=
SwapEndian_16
(
*
((
uint16_t
*
)
CurrentParameter
));
CurrentParameter
+=
sizeof
(
uint16_t
);
BT_SDP_DEBUG
(
2
,
"-- Max Return Attribute Bytes: 0x%04X"
,
MaxAttributeSize
);
/* Retrieve the list of Attributes from the request */
uint16_t
AttributeList
[
15
][
2
];
uint8_t
TotalAttributes
=
SDP_GetAttributeList
(
AttributeList
,
&
CurrentParameter
);
BT_SDP_DEBUG
(
2
,
"-- Total Attributes: %d"
,
TotalAttributes
);
struct
{
SDP_PDUHeader_t
SDPHeader
;
uint16_t
AttributeListByteCount
;
uint8_t
ResponseData
[
100
];
}
ResponsePacket
;
/* Create a pointer to the buffer to indicate the current location for response data to be added */
void
*
CurrResponsePos
=
ResponsePacket
.
ResponseData
;
/* Clamp the maximum attribute size to the size of the allocated buffer */
if
(
MaxAttributeSize
>
sizeof
(
ResponsePacket
.
ResponseData
))
MaxAttributeSize
=
sizeof
(
ResponsePacket
.
ResponseData
);
/* Add the outer Data Element Sequence header for all of the retrieved Attributes */
uint16_t
*
TotalResponseSize
=
SDP_AddDataElementHeader16
(
&
CurrResponsePos
,
SDP_DATATYPE_Sequence
);
/* Search through the global UUID list an item at a time */
for
(
uint8_t
CurrTableItem
=
0
;
CurrTableItem
<
(
sizeof
(
SDP_Services_Table
)
/
sizeof
(
ServiceTable_t
));
CurrTableItem
++
)
{
/* Read in a pointer to the current UUID table entry's Attribute table */
ServiceAttributeTable_t
*
CurrAttributeTable
=
(
ServiceAttributeTable_t
*
)
pgm_read_word
(
&
SDP_Services_Table
[
CurrTableItem
].
AttributeTable
);
/* Retrieve a PROGMEM pointer to the value of the Service Record Handle */
const
void
*
ServiceRecord
=
SDP_GetAttributeValue
(
CurrAttributeTable
,
SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE
);
/* Check if the current service in the service table has the requested service handle */
if
(
memcmp_P
(
ServiceRecord
,
&
ServiceHandle
,
sizeof
(
uint32_t
))
==
0
)
{
/* Search through the list of Attributes one at a time looking for values in the current UUID's Attribute table */
for
(
uint8_t
CurrAttribute
=
0
;
CurrAttribute
<
TotalAttributes
;
CurrAttribute
++
)
{
uint16_t
*
AttributeIDRange
=
AttributeList
[
CurrAttribute
];
/* Look in the current Attribute Range for a matching Attribute ID in the service's Attribute table */
for
(
uint32_t
CurrAttributeID
=
AttributeIDRange
[
0
];
CurrAttributeID
<=
AttributeIDRange
[
1
];
CurrAttributeID
++
)
{
/* Retrieve a PROGMEM pointer to the value of the current Attribute ID, if it exists in the service's Attribute table */
const
void
*
AttributeValue
=
SDP_GetAttributeValue
(
CurrAttributeTable
,
CurrAttributeID
);
/* If the Attribute does not exist in the current service's Attribute table, continue to the next Attribute ID */
if
(
AttributeValue
==
NULL
)
continue
;
BT_SDP_DEBUG
(
2
,
" -- Add Attribute 0x%04X"
,
CurrAttributeID
);
/* Increment the service's returned Attribute container size by the number of added bytes */
*
TotalResponseSize
+=
SDP_AddAttributeToResponse
(
CurrAttributeID
,
AttributeValue
,
&
CurrResponsePos
);
}
}
/* Requested service found, abort the search through the service table */
break
;
}
}
/* Continuation state - always zero */
*
((
uint8_t
*
)
CurrResponsePos
)
=
0
;
/* Set the total response list size to the size of the outer container plus its header size and continuation state */
ResponsePacket
.
AttributeListByteCount
=
SwapEndian_16
(
3
+
*
TotalResponseSize
);
/* Calculate the total parameter length that is to be sent, including the fixed return parameters, the created attribute
value list and the SDP continuation state */
uint16_t
ParamLength
=
(
sizeof
(
ResponsePacket
.
AttributeListByteCount
)
+
(
3
+
*
TotalResponseSize
)
+
sizeof
(
uint8_t
));
/* Fill in the response packet's header */
ResponsePacket
.
SDPHeader
.
PDU
=
SDP_PDU_SERVICEATTRIBUTERESPONSE
;
ResponsePacket
.
SDPHeader
.
TransactionID
=
SDPHeader
->
TransactionID
;
ResponsePacket
.
SDPHeader
.
ParameterLength
=
SwapEndian_16
(
ParamLength
);
/* Flip the endianness of the container's size */
*
TotalResponseSize
=
SwapEndian_16
(
*
TotalResponseSize
);
BT_SDP_DEBUG
(
1
,
">> Service Attribute Response"
);
BT_SDP_DEBUG
(
2
,
"-- Param Len 0x%04X"
,
ParamLength
);
/* Send the completed response packet to the sender */
Bluetooth_SendPacket
(
&
ResponsePacket
,
(
sizeof
(
ResponsePacket
.
SDPHeader
)
+
ParamLength
),
Channel
);
}
}
/** Internal processing routine for SDP Service Search Attribute Requests.
/** Internal processing routine for SDP Service Search Attribute Requests.
...
@@ -608,7 +707,7 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], const void**
...
@@ -608,7 +707,7 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], const void**
memcpy
(
&
CurrentUUID
[
0
],
*
CurrentParameter
,
UUIDLength
);
memcpy
(
&
CurrentUUID
[
0
],
*
CurrentParameter
,
UUIDLength
);
}
}
BT_SDP_DEBUG
(
2
,
"-- UUID (%d):
0x
%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X"
,
BT_SDP_DEBUG
(
2
,
"-- UUID (%d): %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X"
,
UUIDLength
,
UUIDLength
,
CurrentUUID
[
15
],
CurrentUUID
[
14
],
CurrentUUID
[
13
],
CurrentUUID
[
12
],
CurrentUUID
[
15
],
CurrentUUID
[
14
],
CurrentUUID
[
13
],
CurrentUUID
[
12
],
CurrentUUID
[
11
],
CurrentUUID
[
10
],
CurrentUUID
[
9
],
CurrentUUID
[
8
],
CurrentUUID
[
11
],
CurrentUUID
[
10
],
CurrentUUID
[
9
],
CurrentUUID
[
8
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment