iocp (v2.0b1)

::iocp::bt::sdrTop, Main, Index

The iocp::bt::sdr namespace contains commands for parsing Bluetooth Service Discovery Records (SDR) as returned by the ::iocp::bt::device services and ::iocp::bt::device service_references commands. These return a list of binary records which must be first parsed with the decode command. Individual service attributes can then be retrieved from the decoded records using the other commands in the namespace.

set dev  [iocp::bt::device address "APN Phone"]
set recs [iocp::bt::device services $dev]
set sdr  [iocp::bt::sdr::decode [lindex $recs 0]]
set service_classes [iocp::bt::sdr::attribute get $sdr ServiceClassIDList]

CommandsTop, Main, Index

attribute [::iocp::bt::sdr]Top, Main, Index

A command ensemble.

attribute subcommand ...
Description

The ensemble supports the following subcommands:

existsChecks if an attribute exists in a service discovery record.
getGet the value of an universal attribute from a service discovery record.
rawGet an attribute value from an service discovery record.
textGet the value of an text attribute in the specified language from a service discovery record.

Refer to the documentation of each subcommand for details.

attribute exists [::iocp::bt::sdr]Top, Main, Index

Checks if an attribute exists in a service discovery record

attribute exists sdr attr_id ?varname?
Parameters
sdrA decoded service discovery record in the form returned by decode.
attr_idAttribute integer id or Bluetooth universal attribute name.
varnameIf not the empty string, the attribute value is stored in a variable of this name in the caller's context. Optional, default "".
Description

The value returned in $varname is the attribute type-independent data value. To get the value formatted for the attribute type, use the attribute get command.

Return value

Returns 1 if the attribute exists, and 0 otherwise.

attribute get [::iocp::bt::sdr]Top, Main, Index

Get the value of an universal attribute from a service discovery record.

attribute get sdr attr_id ?varname?
Parameters
sdrDecoded service discovery record.
attr_idUniversal attribute name or numeric identifier.
varnameOptional name of variable in caller's context. Optional, default "".
Description

If $varname is not the empty string, it should be the name of a variable in the caller's context.

If $varname is an empty string,

The attribute value is decoded into a attribute type-dependent format.

The $attr_id argument must be one of those defined in the Universal Attributes section in the Bluetooth Assigned Numbers specification. Otherwise an error is raised. The recognized attributes are listed below. Refer to the Bluetooth specification for their exact semantics.

AdditionalProtocolDescriptorListList of protocol stacks. This supplements the ProtocolDescriptorList attribute.
BluetoothProfileDescriptorListList of Bluetooth profile descriptors to which the service conforms. Each element is a dictionary with keys Uuid, Name, MajorVersion and MinorVersion corresponding to the referenced profile.
BrowseGroupListList of browse group descriptors representing the browse groups to which the service record belongs. Each descriptor is dictionary with keys Uuid and Name identifying the a browse group.
ClientExecutableURLURL pointing to the client application that may be used to utilize the service.
DocumentationURLURL for the service documentation.
IconURLURL for icon that may be used to represent the service.
LanguageBaseAttributeIDListNested dictionary of language-specific attribute offsets (see below).
ProtocolDescriptorListList of protocol stacks (see below) that may be used to access the service described by the service record.
ProviderNameName of entity providing the service in the primary language of the service record.
ServiceAvailabilityA value in the range 0-255 that indicates relative availability of the service in terms of the number of clients it can accept. Note this is a scaled estimate.
ServiceClassIDListList with each element being a dictionary corresponding to a service class that the record conforms to. The keys of the dictionary are Name and Uuid.
ServiceDescriptionA description of the service in the primary language of the record.
ServiceIDUUID that uniquely identifies a service instance.
ServiceInfoTimeToLiveThe number of seconds from the time it was generated that the service record information is expected to be valid.
ServiceNameThe human-readable name of the service in the primary language of the record.
ServiceRecordHandleA numeric value that uniquely identifies a service record within a SDP server.
ServiceRecordStateNumeric value that is changed any time the service record is modified by the SDP server.

In the case of ProtocolDescriptorList and AdditionalProtocolDescriptorList, the attribute value is in the form of a list each element of which describes a protocol stack that may be used to access the service. Each such element is itself a list whose elements correspond to layers in that protocol stack starting with the lowest layer first. Each layer is described as a dictionary with the following keys:

UuidThe UUID of the protocol for the layer.
NameThe name of the protocol.
ParamsThe protocol parameters. This is a list of raw data elements of the form {type value} the interpretation of which is protocol dependent.

In the case of LanguageBaseAttributeIDList, the attribute value is a dictionary indexed by language identifiers as defined in ISO639, e.g. en, fr etc. The corresponding value is itself a dictionary with keys BaseOffset and Encoding. See the Bluetooth specification for the former. The latter is either a Tcl encoding name or in case the encoding is not supported by Tcl, an integer value that identifies an encoding as per the Bluetooth specification.

Return value

Returns a boolean or the decoded attribute value.

attribute raw [::iocp::bt::sdr]Top, Main, Index

Get an attribute value from an service discovery record.

attribute raw sdr attr_id
Parameters
sdrA decoded service discovery record in the form returned by sdr_decode.
attr_idAttribute integer id.
Description

The command will raise an error if the attribute does not exist in the sdr.

Return value

Returns the attribute value as a pair consisting of the type and the raw data element value.

attribute text [::iocp::bt::sdr]Top, Main, Index

Get the value of an text attribute in the specified language from a service discovery record.

attribute text sdr attr_id lang ?varname?
Parameters
sdrDecoded service discovery record.
attr_idUniversal attribute name or numeric identifier.
langLanguage identifier as specified in iso639, e.g. en for english, fr for french etc. or the keyword primary.
varnameName of variable in caller's context. Optional, default "".
Description

If $varname is not the empty string, it should be the name of a variable in the caller's context.

If $varname is an empty string,

If the record does not contain a value for the specified language, the value for the primary language will be retrieved.

Return value

Returns a boolean or the attribute text value.

attributes [::iocp::bt::sdr]Top, Main, Index

Get the list of attributes in a service discovery record

attributes sdr
Parameters
sdrA decoded service discovery record in the form returned by decode.
Return value

Returns a list of numeric attribute ids.

decode [::iocp::bt::sdr]Top, Main, Index

Decodes a binary service discovery record

decode binsdr
Parameters
binsdrA raw Bluetooth service discovery record in binary form.
Description

The returned value should be treated as opaque. The attributes stored in the record should be accessed with the commands in the sdr namespace.

Return value

Returns a container of attributes stored in the record.

print [::iocp::bt::sdr]Top, Main, Index

Prints a SDP record to a more human readable form.

print rec ?attrfilter?
Parameters
recA binary SDP record in the form returned by ::iocp::bt::device services or ::iocp::bt::device service_references.
attrfilterIf specified, only attribute names matching the filter using string match are printed. Optional, default *.

printn [::iocp::bt::sdr]Top, Main, Index

Prints a SDP record to a more human readable form.

printn recs ?attrfilter?
Parameters
recsA list of binary SDP records in the form returned by ::iocp::bt::device services or ::iocp::bt::device service_references.
attrfilterIf specified, only attribute names matching the filter using string match are printed. Optional, default *.