@@ -88,16 +88,13 @@ func createTmpCopy(path string) (*os.File, error) {
8888// ```
8989func (r * Registry ) GetBluetoothLinkKey (controllerMAC , deviceMAC string ) (string , error ) {
9090 // Normalize MAC addresses to Windows format (lowercase, no colons)
91- controllerMAC = normalizeMAC (controllerMAC )
92- deviceMAC = normalizeMAC (deviceMAC )
93-
94- scanner := bufio .NewScanner (bytes .NewReader (r .dump .Bytes ()))
91+ searchSection := fmt .Sprintf ("%s\\ %s" , "ControlSet001\\ Services\\ BTHPORT\\ Parameters\\ Keys" , normalizeMAC (controllerMAC ))
92+ searchDevice := fmt .Sprintf (`"%s"=hex:` , normalizeMAC (deviceMAC ))
9593
9694 controllerFound := false
97- searchSection := fmt .Sprintf ("%s\\ %s" , "ControlSet001\\ Services\\ BTHPORT\\ Parameters\\ Keys" , controllerMAC )
98- searchDevice := fmt .Sprintf (`"%s"=hex:` , deviceMAC )
99-
10095 inSection := false
96+
97+ scanner := bufio .NewScanner (bytes .NewReader (r .dump .Bytes ()))
10198 for scanner .Scan () {
10299 line := scanner .Text ()
103100 line = strings .TrimSpace (line )
@@ -126,10 +123,10 @@ func (r *Registry) GetBluetoothLinkKey(controllerMAC, deviceMAC string) (string,
126123 }
127124
128125 if ! controllerFound {
129- return "" , fmt .Errorf ("controller not found in registry" )
126+ return "" , fmt .Errorf ("controller (%s) not found in the Windows registry" , controllerMAC )
130127 }
131128
132- return "" , fmt .Errorf ("device not found in registry" )
129+ return "" , fmt .Errorf ("device (%s) not found in the Windows registry" , deviceMAC )
133130}
134131
135132func normalizeMAC (mac string ) string {
0 commit comments