X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/2eff731ecfbcfec4f3152992e5ae5602a3694424..a8871c7fba73307226bd13e2cad4c840c850e6f1:/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c b/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c index c5c490ed3..19d42e264 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c @@ -52,18 +52,12 @@ const ServiceAttributeTable_t* SDP_Services_Table[] PROGMEM = /** Base UUID value common to all standardized Bluetooth services */ const UUID_t BaseUUID PROGMEM = {0x00000000, BASE_80BIT_UUID}; -/** Initializes the SDP service, ready for new connections from a SDP client. */ -void SDP_Initialize(void) -{ - /* Not currently used */ -} - -/** Main Service Discovery Protocol packet processing routine. This function processes incomming SDP packets from +/** Main Service Discovery Protocol packet processing routine. This function processes incoming SDP packets from * a connected Bluetooth device, and sends back appropriate responses to allow other devices to determine the * services the local device exposes. * - * \param[in] Data Incomming packet data containing the SDP request - * \param[in] Channel Channel the request was issued to by the remote device + * \param[in] Data Incoming packet data containing the SDP request + * \param[in] Channel ACL channel the request was issued to by the remote device */ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel) { @@ -94,9 +88,10 @@ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel) * \param[in] SDPHeader Pointer to the start of the issued SDP request * \param[in] Channel Pointer to the Bluetooth channel structure the request was issued to */ -static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel) +static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, + Bluetooth_Channel_t* const Channel) { - const void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t)); + const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t)); BT_SDP_DEBUG(1, "<< Service Search"); @@ -105,7 +100,7 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Blu uint8_t TotalUUIDs = SDP_GetUUIDList(UUIDList, &CurrentParameter); BT_SDP_DEBUG(2, "-- Total UUIDs: %d", TotalUUIDs); - /* Retrieve the maximum service record reponse count from the request */ + /* Retrieve the maximum service record response count from the request */ uint16_t MaxServiceRecordCount = SDP_ReadData16(&CurrentParameter); BT_SDP_DEBUG(2, "-- Max Return Service Count: 0x%04X", MaxServiceRecordCount); @@ -175,9 +170,10 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Blu * \param[in] SDPHeader Pointer to the start of the issued SDP request * \param[in] Channel Pointer to the Bluetooth channel structure the request was issued to */ -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)); + const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t)); BT_SDP_DEBUG(1, "<< Service Attribute"); @@ -185,7 +181,7 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, uint32_t ServiceHandle = SDP_ReadData32(&CurrentParameter); BT_SDP_DEBUG(2, "-- Service Handle: 0x%08lX", ServiceHandle); - /* Retrieve the maximum Attribute reponse size from the request */ + /* Retrieve the maximum Attribute response size from the request */ uint16_t MaxAttributeSize = SDP_ReadData16(&CurrentParameter); BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize); @@ -265,9 +261,10 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, * \param[in] SDPHeader Pointer to the start of the issued SDP request * \param[in] Channel Pointer to the Bluetooth channel structure the request was issued to */ -static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel) +static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHeader, + Bluetooth_Channel_t* const Channel) { - const void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t)); + const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t)); BT_SDP_DEBUG(1, "<< Service Search Attribute"); @@ -276,7 +273,7 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe uint8_t TotalUUIDs = SDP_GetUUIDList(UUIDList, &CurrentParameter); BT_SDP_DEBUG(2, "-- Total UUIDs: %d", TotalUUIDs); - /* Retrieve the maximum Attribute reponse size from the request */ + /* Retrieve the maximum Attribute response size from the request */ uint16_t MaxAttributeSize = SDP_ReadData16(&CurrentParameter); BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize); @@ -354,8 +351,10 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe * * \return Number of bytes added to the output buffer */ -static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t* AttributeTable, uint16_t AttributeList[][2], - const uint8_t TotalAttributes, void** const BufferPos) +static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t* AttributeTable, + uint16_t AttributeList[][2], + const uint8_t TotalAttributes, + void** const BufferPos) { uint16_t TotalResponseSize; @@ -394,7 +393,7 @@ static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t* return TotalResponseSize; } -/** Adds the given attribute ID and value to the reponse buffer, and advances the response buffer pointer past the added data. +/** Adds the given attribute ID and value to the response buffer, and advances the response buffer pointer past the added data. * * \param[in] AttributeID Attribute ID to add to the response buffer * \param[in] AttributeValue Pointer to the start of the Attribute's value, located in PROGMEM @@ -402,7 +401,9 @@ static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t* * * \return Number of bytes added to the response buffer */ -static uint16_t SDP_AddAttributeToResponse(const uint16_t AttributeID, const void* AttributeValue, void** ResponseBuffer) +static uint16_t SDP_AddAttributeToResponse(const uint16_t AttributeID, + const void* AttributeValue, + void** ResponseBuffer) { /* Retrieve the size of the attribute value from its container header */ uint8_t AttributeHeaderLength; @@ -430,7 +431,8 @@ static uint16_t SDP_AddAttributeToResponse(const uint16_t AttributeID, const voi * * \return Pointer to the start of the Attribute's value if found within the table, NULL otherwise */ -static void* SDP_GetAttributeValue(const ServiceAttributeTable_t* AttributeTable, const uint16_t AttributeID) +static void* SDP_GetAttributeValue(const ServiceAttributeTable_t* AttributeTable, + const uint16_t AttributeID) { void* CurrTableItemData; @@ -455,7 +457,8 @@ static void* SDP_GetAttributeValue(const ServiceAttributeTable_t* AttributeTable * * \return True if all the UUIDs given in the UUID list appear in the given attribute table, false otherwise */ -static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES], const uint8_t TotalUUIDs, +static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES], + const uint8_t TotalUUIDs, const ServiceAttributeTable_t* CurrAttributeTable) { const void* CurrAttribute; @@ -477,18 +480,20 @@ static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES], const ui return (UUIDMatches == TotalUUIDs); } -/** Recursively upwraps the given locally stored attribute (in PROGMEM space), searching for UUIDs to match against +/** Recursively unwraps the given locally stored attribute (in PROGMEM space), searching for UUIDs to match against * the given UUID list. As matches are found, they are indicated in the UUIDMatch flag list. * - * \param[in] UUIDList List of UUIDs which must be matched within the service attribute table - * \param[in] TotalUUIDs Total number of UUIDs stored in the UUID list - * \param[in, out] UUIDMatch Array of flags indicating which UUIDs in the list have already been matched - * \param[in] CurrAttribute Pointer to the current attribute to search through + * \param[in] UUIDList List of UUIDs which must be matched within the service attribute table + * \param[in] TotalUUIDs Total number of UUIDs stored in the UUID list + * \param[in, out] UUIDMatchFlags Array of flags indicating which UUIDs in the list have already been matched + * \param[in] CurrAttribute Pointer to the current attribute to search through * * \return True if all the UUIDs given in the UUID list appear in the given attribute table, false otherwise */ -static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], const uint8_t TotalUUIDs, - uint16_t* const UUIDMatchFlags, const void* CurrAttribute) +static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], + const uint8_t TotalUUIDs, + uint16_t* const UUIDMatchFlags, + const void* CurrAttribute) { uint8_t CurrAttributeType = (pgm_read_byte(CurrAttribute) & ~0x07); @@ -542,7 +547,8 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], const uint8_ * * \return Total number of Attribute ranges stored in the Data Element Sequence */ -static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2], const void** const CurrentParameter) +static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2], + const void** const CurrentParameter) { uint8_t ElementHeaderSize; uint8_t TotalAttributes = 0; @@ -584,7 +590,8 @@ static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2], const void** co * * \return Total number of UUIDs stored in the Data Element Sequence */ -static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], const void** const CurrentParameter) +static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], + const void** const CurrentParameter) { uint8_t ElementHeaderSize; uint8_t TotalUUIDs = 0; @@ -635,7 +642,8 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], const void** * * \return Size in bytes of the entire attribute container, including the header */ -static uint32_t SDP_GetLocalAttributeContainerSize(const void* const AttributeData, uint8_t* const HeaderSize) +static uint32_t SDP_GetLocalAttributeContainerSize(const void* const AttributeData, + uint8_t* const HeaderSize) { /* Fetch the size of the Data Element structure from the header */ uint8_t SizeIndex = (pgm_read_byte(AttributeData) & 0x07); @@ -674,7 +682,8 @@ static uint32_t SDP_GetLocalAttributeContainerSize(const void* const AttributeDa * * \return Size in bytes of the Data Element container's contents, minus the header */ -static uint32_t SDP_GetDataElementSize(const void** const DataElementHeader, uint8_t* const ElementHeaderSize) +static uint32_t SDP_GetDataElementSize(const void** const DataElementHeader, + uint8_t* const ElementHeaderSize) { /* Fetch the size of the Data Element structure from the header, increment the current buffer pos */ uint8_t SizeIndex = (SDP_ReadData8(DataElementHeader) & 0x07);