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.
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.
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] }
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.
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\"." }
uuid | Not documented. |
proc ::iocp::bt::names::is_uuid {uuid} { regexp {^[[:xdigit:]]{8}-([[:xdigit:]]{4}-){3}[[:xdigit:]]{12}$} $uuid }
Prints known UUID's and their mapped mnemonics.
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" } }
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.
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] }
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.
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] }
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.
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] }
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.
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 }
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.
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] }
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.
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] }
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.
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] }