-
-
Save gingerbeardman/05030c73714b3aa3202aeee7f21c3b1e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
# requirements: blueutil | |
echo "Hold both 1+2 buttons on Wii Remote and wait for 30 seconds" | |
# get MAC Address of Wii Remote | |
MAC=`$(which blueutil) --inquiry 5 2>&1 | grep 'address' | awk '{print substr($2,1,17)}'` | |
(killall -m 'blueutil*' 2>&1) >/dev/null | |
echo "MAC: $MAC" | |
# prepare HEX | |
HEX=`echo $MAC | tr -d '-'` | |
# PIN is MAC Address HEX pairs in reverse order | |
PIN="\x${HEX:10:2}\x${HEX:8:2}\x${HEX:6:2}\x${HEX:4:2}\x${HEX:2:2}\x${HEX:0:2}" | |
# try to PAIR with PIN | |
echo "ATTEMPTING PAIR" | |
echo "$PIN" | $(which blueutil) --pair $MAC >/dev/null 2>&1 | |
# fail? | |
if [ $? -ne 0 ]; then | |
echo "PAIR FAILED" | |
else | |
# now we can CONNECT | |
echo "ATTEMPTING CONNECT" | |
$(which blueutil) --connect $MAC >/dev/null 2>&1 | |
fi |
I'm not sure why you are seeing 4 addresses rather than just one.
You can run blueutil manually, but entering the pin (which consists of characters that cannot be typed) requires a script or program. If it failed, it's a macOS thing.
You can also try the GUI at https://stemed.online/wiimote/
Would there be a way to just get the pin without having to go through blueutil with the MAC address? Specifically this part of the script: PIN="\x${HEX:10:2}\x${HEX:8:2}\x${HEX:6:2}\x${HEX:4:2}\x${HEX:2:2}\x${HEX:0:2}"
I had some security concerns when working with the STEM GUI (I'm fairly certain the utility downloaded some files to my computer without me knowing), so I'm going to stick with this tool for now. I might be a bit paranoid but I'd just prefer to use this one so I know what's going on under the hood.
The pin is each pair of the MAC address in reverse. But the resulting information is not human readable and cannot be typed using a keyboard because it's out of the range of the alphabet. Which is why it's managed here by a script.
It's a shame Nintendo picked such a pin. And it's a shame macOS has removed most support for Nintendo controllers.
I by no means know shell script well but i tried to hardcode in the MAC address here because blueutil was acting weirdly. Anyways I get the error Failed to pair "d8-6b-f7-db-a2-5e" with error 0x1f (Unspecified Error)
Here is the code:
#!/usr/bin/env bash
MAC="d8-6b-f7-db-a2-5e"
(killall -m 'blueutil*' 2>&1) >/dev/null
echo "MAC: $MAC
PIN="\xe5\x2a\xbd\x7f\xb6\x8d"
echo "ATTEMPTING PAIR"
echo -n -e "$PIN" | $(which blueutil) --pair $MAC
if [ $? -ne 0 ]; then
echo "PAIR FAILED"
else
echo "ATTEMPTING CONNECT"
$(which blueutil) --connect $MAC
fi
I'm having this problem, is there any way to fix it? I'm on Monetary 12.6.9 on an Intel mac. Is there any place to see an error output?