Dual pair BLE 4.0 Keyboard with MacOS and Linux - linux

I have a Microsoft surface keyboard, it works over BLE 4.0.
I would like to pair it with 2 hosts, my macbook and a linux workstation.
The bluetooth dongle is inserted in a KVM switch, and I need it to be paired with one machine at a time.
There are plenty of tutorials on the internet which achieve a similar thing between Windows & MacOS or MacOS & Linux.
The general idea is to pair with both and then replace the pairing keys & some other parameters on the other hosts so they match.
MacOS settings for High Sierra are located in /private/var/root/Library/Preferences/com.apple.bluetoothd.plist
Linux(Arch) settings are in /var/lib/bluetooth/DONGLE_MAC/DEVICE_MAC/info
Keys which require synchronization are:
IdentityResolvingKey.Key
LocalSignatureKey.Key
LongTermKey.Key
LongTermKey.EDiv
LongTermKey.Rand
I have found a match for all of them, but a LocalSignatureKey. The matching pair on Windows is called CSRK, but I can't find a version of it on MacOS.
Apart from SMPDistributionKeys dictionary on Mac, which contains all the other keys from the list, I have some other top-level keys, which I hope may represent the CSRK/LocalSignatureKey:
MagicCloudPairingMasterHint
MagicCloudPairingMasterKey
SMPCloudLocalNonce
SMPCloudLocalPrivateKey
SMPCloudLocalPublicKey
Does anyone have an idea what would be the mapping for LocalSignatureKey on Mac? Or CSRK on Windows to Mac?

Related

Is there a reliable way to reconnect a paired ZAGG - Logitech Bluetooth Keyboard upon power-up?

I have a bluetooth keyboard that I use on a regular basis. It has a Logitech logo, but is manufactured by ZAGG and has model number Y-R0023.
I have paired the keyboard with my Ubuntu desktop and it works great.
Upon powering up my computer and keyboard, I can sometimes reconnect without having to pair again, but other times I have to remove the existing pairing and reconnect before Ubuntu can receive keystrokes.
Extra information: Ubuntu displays a bluetooth symbol as a status when it connects (regardless if it is able to receive keystrokes or not). This symbol will appear and disappear roughly every 10 seconds until the two devices are able to successfully negotiate a valid connection.
I notice that I have best success when I press 'delete-delete-enter-enter' after powering the ZAGG keyboard up. (Sometimes, just repeatedly pressing a key every second or so seems to work too.)
I am wondering if the "delete-delete-enter" keystroke combination (or some other that I haven't discovered) is recognized by the Logitech BIOS as a special sequence to help retry a paired re-connection. I'd be interested in finding out if this trick works for devices other than those made by ZAGG. Otherwise, it would help just to know if there is a reliable script I can run that calls bluetoothctl to help improve the re-connection. (I want to avoid having to enter a pairing code on subsequent connections).
ZAGG sites and Logitech ones don't say anything about this key combination. So I don't think it's recognized as a special sequence, only advice they give is to re-pair the device when it's not working.
In summary I'm sure they would include this troubleshooting option in manual and/or troubleshooting guide if it was present.

How does Linux determine a device class?

Linux newbie question.
Just wondering how Linux determines which device class a device is? Specifically, when I plug a barcode scanner in how does it know it is an ttyACM device? I have a scanner that works with my Linux OS but the new model isn't recognized so I'm wondering if I can alter a file somewhere in the system that tells it to recognize the scanner as ttyACM0 and use the existing drivers.
USB devices (I assume your scanner is USB) are identified by vendorId and productId (two 16bit integers), each driver fill an array with the list of supported vendor/prods id (creating a relation vendor:prod->driver), I guess at compile time all the id in the array are merged together in a list which then is used for a lookup search when a device is plugged in.
Usually you can see vendor and product id of the attached device with dmesg command right after the device is plugged in (or with lsusb).
For ttyACM see acm_ids[] in drivers/usb/class/cdc-acm.c
Careful playing around with device drivers, even being ttyACM a terminal interface only if the interface tty->hardware is implemented poorly some command may break the hardware.
Perhaps this question should be in Unix & Linux stackexchange

USB bluetooth dongle with PuTTY

I have a USB Bluetooth dongle that I am trying to use in order to extract information from an ELM327 OBD-II interface.
I am trying to communicate with the ELM327 through PuTTY. According to the ELM327 documentation, I need to use baud rate 38,400 if the PP 0C pin hasn't been changed or 9,600 if pin 6 = 0 V.
I tried setting PuTTY according to the Device Manager details with:
Baud rate 9,600 or 38,400
8 data bits
No parity
1 stop bits
No flow control
When I open PuTTY, the window is blank, and I cannot send commands to the device.
What could be the issue here?
Your problem might be with PuTTY and Windows 10. Neither PuTTY nor Hyperterminal allowed me to connect to my ELM327 on Windows 10 (I am using the USB connection for talking to ELM327). It might be some kind of problem of these software on the latest version on Windows.
Looking for a similar software that works well on Windows 10 I found RealTerm. You can download it from this link. A brief tutorial about how to use RealTerm is available here (pay attention to the procedure to open a serial port by clicking twice on the button "open", an how to send commands from the send tab).
After downloading it, just configure your serial connection with the values you were using:
Baud rate 38,400 (or 9,600)
8 data bits
No parity
1 stop bits
No flow control
Also, do not forget to add a CR (carriage return) at the end of the commands you send to the ELM327, if you forget it, the ELM327 will ignore the commands. You can do it by clicking on the EOL options shown in the figure below.
This solved my problem and now I am able to talk to the ELM327 and receive its answers, e.g. the commands atz returns the ELM327 version. The OBD2 command 0100 returns the PIDs available on a car's ECU. I don't know why but the CR is shown on the RealTerm display and hides some characters (as it happens with the 'a' of the "atz" command in the figure).
I hope this helps you.

what is the OSX version of Linux's /dev/usb/lp0?

I'm writing to a centronics cable and blinking some LEDs via a simple "bufferized" circuit.
I'm able to write out the bits via C code referencing the device location on /dev/usb/lp0 on an Ubuntu machine.
However, I'd like to be able to do this on OSX Mavericks. I don't see the same type of device file as I do in Linux.
i.e. is there an OSX analog to /dev/usb/lp0 on Linux?
Thanks much.
Under the concept of "everything's a file" lp0 is just a special file that allows raw access to a device, in this case a 'special character file' for the first parallel device. The same would exist on OSX if a driver was present that matched the device, or something like /dev/parport0. OSX has a pretty limited collection of parallel drivers though. You could try to fudge it - create a 'character' device file pointing it to some generic parallel driver with mknod.
e.g. mknod lp0 c x y where x an y are the major and minor numbers for the device type. Typically you find these numbers in the documentation/devices.txt file on linux, not sure where this info is on OSX though.
I've seen devices handle this using generic printer drivers, such as a "gadget printer":
https://www.kernel.org/doc/Documentation/usb/gadget_printer.txt
(my initial assumption)
In this case the device will actually show up on the system as a printer. You can find a list of printers and their location using CUPS utilities like lpstat:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/lpstat.1.html#//apple_ref/doc/man/1/lpstat
There's also the environment variables LPDEST and PRINTER which should list the default print location:
echo $LDPEST

NXT bluetooth pairing always failed

Over 10 hours spend on this and really drive me crazy, any help is appreciate!
Tried with Android phone first:
Samsung NOTE2, Samsung Grand2, Samsung Glaxy S2 with android 2.2, android 4.2, androind 4.4 both with Original official NXT firmware, and latest LeJOS, If pairing from phone to NXT, the NXT would prompt window, just input the PIN same as in phone, but just quickly NXT returned to main menu, nothing more could see and still empty in Contracts list. otherwise, pairing from NXT to Phone, after Phone input the PIN, the NXT still say 'line is busy' or 'unsuccessful' in LeJOS, while the Phone state the NXT is paired successfully.
Tried with PC to NXT, both in WinXP and Win7, I even bought a standalone Bluetooth USB Key, similar, once Input the PIN in PC same as the one in NXT set, the NXT quickly to say 'Line is busy', then the PC always take couple minutes to finish the Driver installation seems like mapping to some COM Port, then PC state paired successfully, but it never did in NXT.
I googled a lot, no useful information can get. Any idea?
Finally I get it to work by replace the Bluetooth stack in my laptop, the experience proved the windows 7 stack can't suit, the one I used now is called bluesoleil, it also provide a management software, which I would say the UI really worried me at the beginning, it likes the very old days software, even more, it asking for license.
with this bluesoleil, I also get my arduino bluetooth sensor paired to my laptop.
I tried a generic stack provided by broadcom, but failed by it keep asking me to plug in the bluetooth adapter, and actually it's always there.
So I have to give up the paring between NXT and android phone, the andorid phone don't support replace the bluetooth stack except refresh another ROM.
Hope this information could help someone like me.

Resources