::iocp::bt::namesTop, Main

Most objects in Bluetooth services are identified using UUIDs or in some cases numeric identifiers. The iocp::bt::names namespace contains utility commands to map these to human readable names.

Commandsnames, Top, Main

attribute_id [::iocp::bt::names]names, Top, Main

Maps a attribute name to it numeric attribute identifier.

attribute_id name
Parameters
nameAttribute name to be mapped.
Description

The command will raise an error if the name is unknown.

Return value

Returns the numeric attribute identifier corresponding to the passed name.

proc ::iocp::bt::names::attribute_id {name} {

    # Maps a attribute name to it numeric attribute identifier.
    #  name - Attribute name to be mapped
    # The command will raise an error if the name is unknown.
    # Returns the numeric attribute identifier corresponding to
    # the passed name.
    variable attribute_names
    if {[string is integer -strict $name]} {
        return $name
    }
    return [dict get $attribute_names $name]
}

attribute_name [::iocp::bt::names]names, Top, Main

Maps a attribute id (numeric or name) to a attribute name.

attribute_name attr_id
Parameters
attr_idNumeric attribute identifier.
Return value

Returns a human-readable name for the attribute or the numeric id itself if no mapping could be performed.

proc ::iocp::bt::names::attribute_name {attr_id} {

    # Maps a attribute id (numeric or name) to a attribute name.
    #  attr_id - numeric attribute identifier
    # Returns a human-readable name for the attribute or
    # the numeric id itself if no mapping could be performed.
    variable attribute_names
    dict for {name id} $attribute_names {
        if {$attr_id == $id || [string equal -nocase $name $attr_id]} {
            return $name
        }
    }
    if {[string is integer -strict $attr_id]} {
        return $attr_id
    }
    error "Unknown attribute \"$attr_id\"."
}

print [::iocp::bt::names]names, Top, Main

Prints known UUID's and their mapped mnemonics.

print
proc ::iocp::bt::names::print {} {

    # Prints known UUID's and their mapped mnemonics.
    variable service_class_names
    dict for {uuid16 name} $service_class_names {
        puts "[Uuid16 $uuid16] $name"
    }
}

profile_name [::iocp::bt::names]names, Top, Main

Maps a UUID to a Bluetooth profile name.

profile_name uuid
Parameters
uuidUUID to be mapped.
Return value

Returns a human-readable name or the UUID itself if no mapping could be performed.

proc ::iocp::bt::names::profile_name {uuid} {

    # Maps a UUID to a Bluetooth profile name.
    # uuid - UUID to be mapped
    # Returns a human-readable name or the UUID itself
    # if no mapping could be performed.

    # Profiles seem to come from same service class UUID space.
    return [service_class_name $uuid]
}

protocol_name [::iocp::bt::names]names, Top, Main

Maps a UUID to a protocol name.

protocol_name uuid
Parameters
uuidUUID to be mapped.
Return value

Returns a human-readable name or the UUID itself if no mapping could be performed.

proc ::iocp::bt::names::protocol_name {uuid} {

    # Maps a UUID to a protocol name.
    # uuid - UUID to be mapped
    # Returns a human-readable name or the UUID itself
    # if no mapping could be performed.
    variable protocol_names
    return [MapUuidToName $uuid protocol_names]
}

protocol_uuid [::iocp::bt::names]names, Top, Main

Maps a protocol name to a UUID.

protocol_uuid name
Parameters
nameProtocol name to be mapped.
Description

The command raises an error if the name could not be mapped to a UUID.

Return value

Returns the UUID corresponding to the name.

proc ::iocp::bt::names::protocol_uuid {name} {

    # Maps a protocol name to a UUID.
    #  name - Protocol name to be mapped.
    # The command raises an error if the name could not be mapped to
    # a UUID.
    #
    # Returns the UUID corresponding to the name.
    variable protocol_names
    return [MapNameToUuid $name protocol_names]
}

service_class_name [::iocp::bt::names]names, Top, Main

Maps a UUID to a service class name.

service_class_name uuid
Parameters
uuidUUID to be mapped.
Return value

Returns a human-readable name or the UUID itself if no mapping could be performed.

proc ::iocp::bt::names::service_class_name {uuid} {

    # Maps a UUID to a service class name.
    # uuid - UUID to be mapped
    # Returns a human-readable name or the UUID itself
    # if no mapping could be performed.
    variable service_class_names
    set name [MapUuidToName $uuid service_class_names]
    if {$name ne $uuid} {
        return $name
    }
    # Well known private uuids
    if {[string equal -nocase "02030302-1d19-415f-86f2-22a2106a0a77" $uuid]} {
        return "Wireless iAP v2"; # iPod Accessory Protocol
    }
    return $uuid
}

service_class_uuid [::iocp::bt::names]names, Top, Main

Maps a service class name to a UUID.

service_class_uuid name
Parameters
nameService class name to be mapped.
Description

The command raises an error if the name could not be mapped to a UUID.

Return value

Returns the UUID corresponding to the name.

proc ::iocp::bt::names::service_class_uuid {name} {

    # Maps a service class name to a UUID.
    #  name - Service class name to be mapped.
    # The command raises an error if the name could not be mapped to
    # a UUID.
    #
    # Returns the UUID corresponding to the name.
    variable service_class_names
    return [MapNameToUuid $name service_class_names]
}

to_name [::iocp::bt::names]names, Top, Main

Map a UUID to a name.

to_name uuid
Parameters
uuidBluetooth UUID.
Description

The command attempts to map the UUID as a service name or protocol name in that order.

Return value

Returns the mapped name or the uuid if no mapping is possible.

proc ::iocp::bt::names::to_name {uuid} {

    # Map a UUID to a name.
    #  uuid - Bluetooth UUID
    # The command attempts to map the UUID as a service name or protocol
    # name in that order.
    #
    # Returns the mapped name or the uuid if no mapping is possible.

    set name [service_class_name $uuid]
    if {$name ne $uuid} {
        return $name
    }
    return [protocol_name $uuid]
}

to_uuid [::iocp::bt::names]names, Top, Main

Map a name to a UUID.

to_uuid name_or_uuid
Parameters
name_or_uuidBluetooth UUID or name.
Description

The command attempts to map the name as a service class name or protocol name in that order.

Return value

Returns the mapped uuid raises an error if no mapping is possible.

proc ::iocp::bt::names::to_uuid {name_or_uuid} {

    # Map a name to a UUID.
    #  name_or_uuid - Bluetooth UUID or name
    # The command attempts to map the name as a service class name or protocol
    # name in that order.
    #
    # Returns the mapped uuid raises an error if no mapping is possible.
    variable service_class_names
    if {[MapNameToUuidV $name_or_uuid service_class_names name]} {
        return $name
    }
    return [protocol_uuid $name_or_uuid]
}
Document generated by Ruff!