Platforms to show: All Mac Windows Linux Cross-Platform

IOBluetoothSDPDataElementMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Bluetooth MBS Bluetooth Plugin 18.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
An instance of this class represents a single SDP data element as defined by the Bluetooth SDP spec.

The data types described by the spec have been mapped onto the base Xojo classes and data types double, Array, Memoryblock as well as IOBluetoothSDPUUID. The number and boolean types (type descriptor 1, 2 and 5) are represented as booleans with the exception of 128-bit numbers which are represented as memoryblock objects in their raw format. The UUID type (type descriptor 3) is represented by IOBluetoothSDPUUID. The string and URL types (type descriptor 4 and 8) are represented by string. The sequence types (type descriptor 6 and 7) are represented by array.

Typically, you will not need to create an IOBluetoothSDPDataElement directly, the system will do that automatically for both client and server operations. However, the current API for adding SDP services to the system does allow the use of an Dictionary based format for creating new services. The purpose for that is to allow a service to be built up completely in a text file (a plist for example) and then easily imported into an app and added to the system without a lot of tedious code to build up the entire SDP service record.

The basis for that dictionary comes from the IOBluetoothSDPDataElement. At its simplest, a data element is made up of three parts: the type descriptor, the size (from which the size descriptor is generated) and the actual value. To provide a complete representation of a data element, an dictionary with three entries can be used. Each of the three entries has a key/value pair representing one of the three attributes of a data element. The first key/value pair has a key 'DataElementType' that contains a number value with the actual type descriptor for the data element. The second pair has a key 'DataElementSize' that contains the actual size of the element in bytes. The size descriptor will be calculated based on the size and type of the element. The third pair is the value itself whose key is 'DataElementValue' and whose type corresponds to the type mapping above.
In addition to this complete description of a data element, their are some shortcuts that can be used for some of the common types and sizes.
If the 'DataElementType' value is one of the numeric types (1, 2), the 'DataElementValue' can be an memoryblock instead of an number. In that case, the numeric data is taken in network byte order (MSB first). Additionally, the 'DataElementSize' parameter may be omitted and the size will be taken from the length of the data object.
If the 'DataElementType' value is the nil type (0), no 'DataElementSize' or 'DataElementValue' entries are needed.
If the 'DataElementType' value is any of the other types, the 'DataElementSize' entry is not needed since the size will be taken directly from the value (data, array, string).
In the case where the element is an unsigned, 32-bit integer (type descriptor 1, size descriptor 4), the value itself may simply be a number (instead of a dictionary as in the previous examples). In the case where the element is a UUID (type descriptor 3), the value itself may be a data object. The UUID type will be inferred and the size taken from the length of the data object.

In the case where the element is a text string (type descriptor 4), the value may be a string object. The text string type will be inferred and the size taken from the length of the string.
In the case where the element is a data element sequence, the value may be an array object. The type will be inferred and the size taken from the length of the array. Additionally, the array must contain sub-elements that will be parsed out individually.

Types

Constant Value Description
kTypeBoolean 5 Boolean
kTypeNil 0 Nil
kTypeReservedEnd 31 End of reserved numbers
kTypeReservedStart 9 Begin of reserved numbers.
kTypeSignedInt 2 Signed integer
kTypeString 4 String
kTypeUnsignedInt 1 Unsigned integer
kTypeURL 8 URL
kTypeUUID 3 UUID

DataElement Types

Constant Value Description
kTypeDataElementAlternative 7 Alternative
kTypeDataElementSequence 6 Sequence

This class has no sub classes.

Some methods using this class:

Some properties using for this class:

Blog Entries

Release notes


The items on this page are in the following plugins: MBS Bluetooth Plugin.


IOBluetoothRFCOMMChannelMBS   -   IOBluetoothSDPServiceAttributeMBS


The biggest plugin in space...