Open deed02392 opened 4 years ago
try this https://github.com/digitalbirdo/BT-LinkkeySync/issues/22#issuecomment-759577237 it converts BTKeys.Reg from Windows to blued.plist for macOS
Cool @roddy20. I haven't tested it but how sure are you that the offsets you use with sed are reliable?
it works for me :) it is not "ready to release product", just an idea, feеl free to make it better
about offsets, I think these lines always have equal length [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys**342387feece6] "d49a207f0a02"=hex:ec,f3,a6,90,8e,3c,af,50,ff,0b,76,e3,b8,8e,77,75**
but I agree, parsing from | to ], from " to " and from : to the end will be better
we can make it more simple Mac-addresses of Mouse and BTDongle are exactly the same in Windows and macOS, so we really need this value only hex:ec,f3,a6,90,8e,3c,af,50,ff,0b,76,e3,b8,8e,77,75
What d'you mean by mac addresses? The number on the left before =? I guess that's some kind of device ID?
What d'you mean by mac addresses? The number on the left before =? I guess that's some kind of device ID?
https://en.wikipedia.org/wiki/MAC_address
"d49a207f0a02" is macaddress for Mouse and 342387feece6 is macadress for BT Dongle, they are constants until you change the hardware
hex:ec,f3,a6,90,8e,3c,af,50,ff,0b,76,e3,b8,8e,77,75 is a pairing key and it is new for each new re-connection so we need to sync it between all the systems
Right. You still need both values - the MAC in order to know which key to update on the other OS.
Right. You still need both values - the MAC in order to know which key to update on the other OS.
Ok
here it is without sed
maybe it will be better
`cd "$(dirname "$0")"
rm /tmp/temp.plist
/usr/libexec/PlistBuddy -c "Add LinkKeys dict" /tmp/temp.plist
input=BTKeys.reg
while IFS= read -r line
do
if [[ "$line" == 'HKEY_LOCAL_MACHINE' ]]
then
t=$(printf "%s" ${line} | awk -F \ '{print $8}' | tr -d ']')
echo
echo "BT:"$t
/usr/libexec/PlistBuddy -c "Add LinkKeys:$t dict" /tmp/temp.plist
fi
if [[ "$line" == '=hex' ]] then key=$(printf "%s" ${line} | awk -F '=' '{print $1}' | tr -d '"') value=$(printf "%s" ${line} | awk -F ':' '{print $2}' | tr -d ',') echo $key $value printf $value | xxd -r -p > /tmp/bin /usr/libexec/PlistBuddy -c "Import LinkKeys:$t:$key /tmp/bin" /tmp/temp.plist plutil -convert binary1 /tmp/temp.plist fi
done < "$input" echo mv /tmp/temp.plist ./blued.plist `
and the missing part
psexec64 -s reg export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys C:\BTKeys.reg
This is nice @roddy20 :) you could try writing this as Python and submitting a pull request, then you would appear as a contributing author to this repository
This is nice @roddy20 :) you could try writing this as Python and submitting a pull request, then you would appear as a contributing author to this repository
I understand nothing in Python, so you may use it "as is" or add to main project as some kind of alternative solution or ask someone else to rewrite to Python or C++ or anything else ))
This is nice @roddy20 :) you could try writing this as Python and submitting a pull request, then you would appear as a contributing author to this repository
if we have WinClone installed, we can read directly from Window's Registry /Applications/Winclone.app/Contents/Resources/tools/bin/registry_lookup
Example: registry_lookup "/Volumes/Bootcamp/Windows/System32/config/SYSTEM" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys " but it does not work for me yet
and one more script for those who has a lot of different macOSes installed `if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi
if [[ -f "/private/var/root/Library/Preferences/com.apple.bluetoothd.plist" ]] then source="/private/var/root/Library/Preferences/com.apple.bluetoothd.plist" fi
if [[ -f "/private/var/root/Library/Preferences/blued.plist" ]] then source="/private/var/root/Library/Preferences/blued.plist" fi
if [[ $source ]] then defaults read $source else echo "File not found" exit fi
for s in /Volumes/*/private/var/root/Library/Preferences do
if [[ -f "$s/com.apple.bluetoothd.plist" ]] then target="$s/com.apple.bluetoothd.plist" fi
if [[ -f "$s/blued.plist" ]] then target="$s/blued.plist" fi
cp -v "${source}" "${target}"
done`
I just did this manually and it was pretty straightforward.
From a paired device in Windows 10 (the Bose 700s, which interestingly support LE but were not paired by LE), I exported the link key data, changed the endianness to MacOS, then replaced this in the Mojave
/private/var/root/Library/Preferences/com.apple.bluetoothd.plist
(I used a hex editor to find and replace the existing paired key with Windows').The only gotcha was that I had to not only disable Bluetooth before modifying the
plist
file, but also perform a system reboot before starting Bluetooth again. Otherwise, something was reverting the key change to theplist
file. I tried to see if I could figure out which specific service was doing this but didn't have any luck.I appreciate that perhaps replacing the key on Windows is easier than the above but wanted to share that it is indeed possible nevertheless.