chrome.hid API with composite device - google-chrome-app

The chrome.hid.getDevices call does not enumerate the HID interface for a composite device. Using the hid sample app https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/hid, I can see a usb mouse and connect to it, but I can not find the HID interface on a composite device (HID + audio) plugged in. The chrome.usb.getDevices call does find it, but even then I can't claim the HID interface manually. Is this something that should work? How to debug? The specific HID interface is Class:3, SubClass:0, Protocol:0 (not a keyboard, which is Protocol: 1, so shouldn't be blacklisted because of that)
Judging by /var/log/message and ls -l /dev/hidraw*, I see that the regular mouse has it's group changed to dev-broker, but the group for my composite device stays as root. The message in the logs say "DenyClaimedHidrawDeviceRule: DENY" indicating that perhaps another kernel driver is owning my hid interface, or usb audio is owning the entire device? This thread here at chromium.org seems to be the issue I am seeing, but doesn't mention any work-around/fix. Normally I'd add a udev rule, or blacklist the driver, or even use sys/bus/usb///unbind foo, but none of that works on a chromebook platform which is what I need to run this on.

Related

Connect CBPeripheral so that macOS MIDI Studio recognises the connection

This is probably in a book but I don't know which.
I'm trying to connect a BLE MIDI CBPeripheral so that it becomes connected on MIDI Studio, i.e. usable as a MIDI source/sink by all the apps in the system. Although I get the indication that it is connected, it doesn't appear so in MIDI Studio or other apps. I know it's possible because Korg's Bluetooth MIDI Connect is able to do it. But it does seem to open the system's 'Bluetooth Configuration' window, so maybe there's no programmatic way of doing it.
I'm creating a CBCentralManager and keeping a reference to it;
When state is poweredOn I do a scanForPeripherals;
When I get a didDiscover:CBPeripheral, I keep the reference to the CBPeripheral and call central.connect(peripheral...);
I get a didConnect:CBPeripheral and keep my app running, but it doesn't appear as connected to anyone else.
I know 'connected' means connected to my app. But I'd really like to have it available for others.
If this is a purposefully Apple-designed limitation, does anyone know what the purpose is?
If not, is there some CoreMIDI API I can use?
Maybe I am missing something, but the apple guide gives you a hint on how to connect a BLE MIDI device to your Mac:
In the Audio MIDI Setup app on your Mac, choose Window > Show MIDI
Studio.
In the MIDI Studio window, click the Configure Bluetooth button in
the toolbar.
Set your Bluetooth MIDI peripheral in pairing mode.
Select the peripheral in the list of devices, then click Connect.
There is no need for custom coding. It should be possible for multiple apps to use the same BLE device, but the apps need to connect to it. BLE devices usually don't show up in the system settings but this might be different for MIDI devices.
For items connected by USB, it does keep the connection information. Once you use the Bluetooth Configuration screen and select the devices, do they appear on the MIDI Studio screen. You may have to create a new External Device.
I think it's like using a new printer. You have to add the new printer using manual methods. However, you can print to it using code.
I have an Objective-C program in the BRossTools directory of the GitHub repository https://github.com/BradleyRoss/ObjectiveC-Examples . If you run the program, it might be interesting to see what happens when you use "Show Configuration" and "Show Sources/Destinations"

How I do to emulate a bluetooth HID keyboard in linux?

How I do in Linux, to emulate a Bluetooth HID keyboard in Linux, with perl?
I have tried with the Net::Bluetooth ( http://search.cpan.org/~addutko/Net-Bluetooth-0.41/Bluetooth.pm ) module, but can't find anywhere I put in the HID descriptor, and I can't find anywhere if I should use RFCOMM or L2CAP. (05010906a101050719e029e71500250175019508810295017508810395057501050819012905910295017503910395067508150025650507190029658100c0)
I also do NOT want to tie a physical keyboard to the Bluetooth "output" like "hidclient" do, rather I want to either expose a device similiar to "/dev/hidg0" where I can write raw HID packets (like "\x00\x00\x04\x00\x00\x00\x00\x00" for the key "a"), or a similiar perl interface where I can write such packets.
Also, in addition to this, I want to be able to read off some static unique serial number or similiar from the remote device (the "host" that the "emulated keyboard" is connected to) to authenticate the host to the keyboard.
I also have only found python examples of emulating HID devices. Anyone that can Point me in the right direction on how to register SDP services in Perl?

How to configure libnfc to use a specific device?

I have a Raspberry PI with two NFC readers attached. Problem is that the readers get different device numbers each time the system reboots or a reader is detached and attached again.
I therefore created udev rules that create a fixed device name depending on the physical port a device is attached to. E.g. plug in NFC reader in the upper left port leads always to /dev/nfc_a and plugged into the upper right port leads always to /dev/nfc_b.
How can I now configure libnfc to use these devices and report the device names such as /dev/nfc_a as a part of the reading? I am using Node-RED with node-red-contrib-nfc (https://github.com/hardillb/node-red-contrib-nfc) on top of libnfc. My ultimate goal is to safely distinguish the two readers within my Node-RED flow to act differently upon the readings.
I already found the "connstring" configuration but I don't know how to correctly set it for using /dev/nfc_a.
It's been a LONG time since I wrote this node, but looking back at the nodejs library it's based on (nfc) the output message should contain a field called deviceID which should indicate which NFC reader triggered the input.
When I run on my machine I get:
deviceID: 'pn53x_usb:001:005'
Where 001 is the USB bus id and 005 is the device ID, which matches up with the output from lsusb. These should stay static as long as the readers are always plugged into the same USB sockets.

Methods for enabling/disabling passcode lock based on device connection in iOS

I tried searching around, but couldn't come up with much on the topic of this.
Is there an API or code within various Security API's that would allow some sort of passcode locking mechanism to enable whenever a device is connected (by Bluetooth, etc) and disable whenever said device is paired with the phone? An interesting concept I had thought up earlier today but can't seem to determine a method available for this.
The concept is pretty much this: if the phone is close enough to be connected over Bluetooth to the device (would be something like a smartwatch or other wearable computing) then the phone is on you and passcode entry can be disabled. However, when the device is not found by the iPhone, there is a physical distance between the two devices and the phone should lock up and not allow entry. This could even be some form of superficial lock mechanism on some apps (which exists already) that could activate based on this proximity awareness. This method is meant to failsafe by being a "lock first, then check" mentality that is paired to a specific address of the wearable computing. This could, in theory, be hacked, yes, but for general usage allows a user to have a no-maintenance method that can save some passcode entries from time to time should one find it annoying, but still want it's security potential.
Again, this idea is based on the assumption that said device connecting to your iPhone that the phone itself is searching for is physically latched to you somehow.
Thanks and I appreciate any sort of input or direction.

Does any interrupt occur when a usb device is connected?

I am working on USB HIDs on linux platform. Keyboards, mouse etc., are examples of Human Interface Devices. Whenever a HID is inserted to a system, at first device enumeration occurs. Then an entry in the form of hidraw appears in the /dev directory.
In linux, "usbhid and hid" are the modules which are called when an HID device is inserted. When I disabled these modules (using rmmod and system restart), the devices were not enumerated and no hidraw entry appeared on /dev(as expected).
Now my question is there any way to know if any USB HID device is connected to a system with the above two modules being disabled i.e does any interrupt or signal generate upon hardware insertion.
I am planning to execute some code when such signal or interrupt occurs(in C). Any kind of help is appreciated.
Thanks,
Insertion of the device is detected through the voltage level changes occuring on the D+ and the D- lines. I do not think that insertion of USB device generates any interrupt. The voltage level changes are read by the hub(root or any hub further down on the line) and according reported to the core.
The USB core driver would be notified about the same. So may be you can write a user-space driver which targets a specific device (using Vendor and Product ID) and through this you can carry out your functionality.
If you are doing this in user mode, you get get a notification using udev (which use netlink internally).
You can match a device using the vendorId and productId field in the rulefile.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="abcd", ATTRS{idProduct}=="1234"