::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.
CommandsTop, Main, Index
attribute [::iocp::bt::sdr]Top, Main, Index
A command ensemble.
Description
The ensemble supports the following subcommands:
exists | Checks if an attribute exists in a service discovery record. |
get | Get the value of an universal attribute from a service discovery record. |
raw | Get an attribute value from an service discovery record. |
text | Get 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
Parameters
sdr | A decoded service discovery record in the form returned by decode. |
attr_id | Attribute integer id or Bluetooth universal attribute name. |
varname | If 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.
Parameters
sdr | Decoded service discovery record. |
attr_id | Universal attribute name or numeric identifier. |
varname | Optional 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 the attribute is present, the command returns
1
and stores the attribute value in the variable. - If the attribute is not present, the command returns 0.
If $varname
is an empty string,
- If the attribute is present, the command returns its value.
- If the attribute is not present, the command raises an error.
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.
AdditionalProtocolDescriptorList | List of protocol stacks. This supplements the ProtocolDescriptorList attribute. |
BluetoothProfileDescriptorList | List 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. |
BrowseGroupList | List 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. |
ClientExecutableURL | URL pointing to the client application that may be used to utilize the service. |
DocumentationURL | URL for the service documentation. |
IconURL | URL for icon that may be used to represent the service. |
LanguageBaseAttributeIDList | Nested dictionary of language-specific attribute offsets (see below). |
ProtocolDescriptorList | List of protocol stacks (see below) that may be used to access the service described by the service record. |
ProviderName | Name of entity providing the service in the primary language of the service record. |
ServiceAvailability | A 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. |
ServiceClassIDList | List 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 . |
ServiceDescription | A description of the service in the primary language of the record. |
ServiceID | UUID that uniquely identifies a service instance. |
ServiceInfoTimeToLive | The number of seconds from the time it was generated that the service record information is expected to be valid. |
ServiceName | The human-readable name of the service in the primary language of the record. |
ServiceRecordHandle | A numeric value that uniquely identifies a service record within a SDP server. |
ServiceRecordState | Numeric 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:
Uuid | The UUID of the protocol for the layer. |
Name | The name of the protocol. |
Params | The 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.
Parameters
sdr | A decoded service discovery record in the form returned by sdr_decode. |
attr_id | Attribute 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.
Parameters
sdr | Decoded service discovery record. |
attr_id | Universal attribute name or numeric identifier. |
lang | Language identifier as specified in iso639, e.g. en for english, fr for french etc. or the keyword primary . |
varname | 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 the attribute is present, the command returns
1
and stores the attribute value in the variable. - If the attribute is not present, the command returns 0.
If $varname
is an empty string,
- If the attribute is present, the command returns its value.
- If the attribute is not present, the command raises an error.
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
Parameters
sdr | A 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
Parameters
binsdr | A 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.
Parameters
rec | A binary SDP record in the form returned by ::iocp::bt::device services or ::iocp::bt::device service_references. |
attrfilter | If 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.
Parameters
recs | A list of binary SDP records in the form returned by ::iocp::bt::device services or ::iocp::bt::device service_references. |
attrfilter | If specified, only attribute names matching the filter using string match are printed. Optional, default * . |