iocp package reference (V1.1.0)

# ::iocp::bt::namesTop, Main, Index

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, Index

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

Maps a attribute name to it numeric attribute identifier.

attribute_id name

##### Parameters

`name` | Attribute 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.

Show source

    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, Index

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

attribute_name attr_id

##### Parameters

`attr_id` | Numeric attribute identifier.

##### Return value

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

Show source

    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\"."
    }

#### is_uuid [::iocp::bt::names]names, Top, Main, Index

is_uuid uuid

##### Parameters

`uuid` | Not documented.

Show source

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

        regexp {^[[:xdigit:]]{8}-([[:xdigit:]]{4}-){3}[[:xdigit:]]{12}$} $uuid
    }

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

Prints known UUID's and their mapped mnemonics.

print

Show source

    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, Index

Maps a UUID to a Bluetooth profile name.

profile_name uuid

##### Parameters

`uuid` | UUID to be mapped.

##### Return value

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

Show source

    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, Index

Maps a UUID to a protocol name.

protocol_name uuid

##### Parameters

`uuid` | UUID to be mapped.

##### Return value

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

Show source

    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, Index

Maps a protocol name to a UUID.

protocol_uuid name

##### Parameters

`name` | Protocol 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.

Show source

    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, Index

Maps a UUID to a service class name.

service_class_name uuid

##### Parameters

`uuid` | UUID to be mapped.

##### Return value

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

Show source

    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, Index

Maps a service class name to a UUID.

service_class_uuid name

##### Parameters

`name` | Service 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.

Show source

    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, Index

Map a UUID to a name.

to_name uuid

##### Parameters

`uuid` | Bluetooth 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.

Show source

    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 && ![is_uuid $name]} {
            return $name
        }
        return [protocol_name $uuid]
    }

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

Map a name to a UUID.

to_uuid name_or_uuid

##### Parameters

`name_or_uuid` | Bluetooth 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.

Show source

    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]
    }

# Start page

# Index

# iocp::bt

# iocp::bt::names

# iocp::bt::sdr

# iocp::inet

# iocp::bt::names

## Commands

#### attribute_id Maps a attribute name to it numeric attribute identifier.

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

#### is_uuid

#### print Prints known UUID's and their mapped mnemonics.

#### profile_name Maps a UUID to a Bluetooth profile name.

#### protocol_name Maps a UUID to a protocol name.

#### protocol_uuid Maps a protocol name to a UUID.

#### service_class_name Maps a UUID to a service class name.

#### service_class_uuid Maps a service class name to a UUID.

#### to_name Map a UUID to a name.

#### to_uuid Map a name to a UUID.

Document generated by Ruff!