Is it possible to make a computer behave as a bluetooth HID device? - linux

Is it possible to make a computer behave as a bluetooth HID device? That is, given a local machine with a standard USB keyboard plugged into it, other devices could discover this machine and use it as a bluetooth keyboard.
I'd like to create a linux or OS X application (or use an existing one, though I've found none) which can behave as described above, but I'm not sure where to start, or if it's even possible.
So:
Is what I'm describing possible?
Are there any existing applications that do what I describe?
If no application already exists (I'm assuming not), are there bluetooth libraries or bindings that will help? (I'm pretty comfortable using most of today's popular languages, so I'd prefer a library most directly suited to the task, so long as it's available in linux or OS X.)
Failing any of the above, the bluetooth spec looks pretty dense. Are there specific guides or other starting points applicable to the problem at hand that I can read?
I realize that such an application would most likely need to steal the normal keyboard input, possibly providing some KVM-like hotkey for switching between providing input to the host operating system and sending the input over bluetooth to the connected device, but I'm considering that problem to be outside the scope of this question.

It is definitely possible on Linux. Some time ago I found this project:
http://nohands.sourceforge.net/index.html
They emulate a full-blown headset with audio and keyboard controls on the Linux bluetooth stack. If they can emulate something like that, you would probably be able to emulate something simpler like a keyboard.

It is possible, however I don't think I'll be able explain it very well and I don't know the entire answer. A BT HID device works as a server and waits for connections to come to it. In linux, using the bluez stack, first you would have to advertise the HID service for other devices to see. I think you do that using the sdp.h and sdp-lib.h header files(the second header maybe called something else, I'm on a windows computer and can't check). So you would have to add the HID service record to you computer for other devices to see it. You would have to create a program that first adds this service to the record, then waits for other devices to connect, then handle the pairing process, Bluez might handle this for you, or you might have to do some things to it, I'm not quite sure. You should also read the Bluetooth HID Spec found at the http://www.bluetooth.com/English/Technology/Building/Pages/Specification.aspx site. This document contains the details of the SDP record relevant to HID. Also the book Bluetooth essentials for programmers is pretty good to introduce you into bluetooth programming
I would like to have given a more concise answer, with more detail, but that's all I know ATM. I am also trying do something similar, but spare time is so hard to find ;) I'm also not on my Linux box and can't check all the details. If your are still interested, let me know and i'll try to expand my answer.

I don't know if this is helpful, nor if it is still alive and working, but perhaps you could try this link.
Another one that might or might not be helpful in some way is remuco, but I don't know if they are using a Bluetooth HID profile.

It is indeed entirely possible with Linux and Bluez. See: https://github.com/lkundrak/virtkbd/blob/master/btkbdd.pod

Try Across, unfortuantly for me my phone was lacking support.

Related

Is it possible to command the Nintendo switch's joy cons with a PC?

I want to create a TAS that can play the Nintendo Switch games that are only compatible with the joy cons.
There are turbo pro controllers in the market but there is no turbo joy cons, so my next idea is one of two:
To use the Bluetooth to connect a devise that I could control with my PC and can be connected to the Nintendo switch via Bluetooth (or USB) and trick it into thinking that it is a joy con and not a pro controller.
Use the idea above but the devise is the joy con itself, in this case, I would have to connect the joy cont to the PC and command it while it is still paired with the Nintendo Switch
Is there any way to achieve what i'm looking for? Thanks in advise.
Also, if there is a better branch in stack-overflow to post this question I will move it.
Looks like it's already been done, and you'll need a product called vJoy.
https://www.pcgamesn.com/nintendo/nintendo-switch-joy-con-pc-guide
Looks like you'd need to reverse engineer the communication protocol used by those controllers and then emulate that protocol with software. Here is a resource I have found regarding RE bluetooth. Another one I have found here. Redfang may help you in that endeavor, it is software that helps you find bluetooth addresses of devices that you you can't discover normally.
Another idea I would have is to open your controller and solder on some wires to a micro controller, such as an Arduino, Raspberry or something similar to the buttons and analogue controllers and 'input' the commands that way.
Unfortunately I can not offer you any more advice. I hope this helps in some way.
One possible way is to use JoyCon Droid app in Android to controll the Nintendo Switch. If this app can work, it should be possible to make one as PC software too.
Luckily, there are a few easy ways to control Android from PC such as using AirDroid which allows you to touch the Android screen from PC. You can refer to How to remote control Android device from a computer with AirDroid?. It can both mirror the screen and give you the touchscreen control, which you can utilize it to control the JoyCon Droid app.
I've just found another way which is to use a microcontroller as a USB controller here.

bluez5: is possible to create a BLE connection asking for PIN/password?

I have a BLE server running, but I would like to limit the connection of remotes devices by asking/requesting for a PIN, passkey, or similar.
Is that possible in Low Energy? I do not mean classic bluetooth.
I am not really sure if it is possible or how to enable set it. I was unable to find any internet thread on how to enable or play with it (using bluez5).
According to the thread
How to change BLE pin programmatically, I see that
There is no password-protecting mechanism in the BLE standard for "login to a device".
Is that correct?
I have digging into this a little bit and, as commented, I was not able to find anything for that. But, I was looking into the bluez(5.46) code, and in "tools/btmgmt.c", function "prompt_input", there are PIN and PASSKEY request cases.
Or well, there is an alternative method? Maybe something like OOB pairing exchanging the TK? https://eewiki.net/display/Wireless/A+Basic+Introduction+to+BLE+Security#ABasicIntroductiontoBLESecurity-PairingMethodsforLESecureConnections(4.2devicesonly)

Stream audio from place 1 to place 2 over the internet

So I'm kinda stuck here.
I have a radio station, but we are mobile. So I have a studio on wheels. The problem is, we have an antenna, but we always have to place that really close to our studio. Now I want to make an device that can stream the audio from the audio mixer to the internet and can be received by another device in another network and send that signal to the antenna (audio output).
to make this clear, I made a schema with raspberry pi's;
I want this to be plug and play So I only have to plug in the device in the modem (or network we have) on both sides and the devices should find each other.
I don't know HOW I can do this, so I need to know a couple of things:
What hardware should I use?
What software should I use?
What is the best configuration to accomplish this?
Can I use 2 raspberry pi's?
How can I let the devices find each other over the internet?
There need to be some features;
The system needs to be able to buffer the audio for 5-10 seconds
It needs to be direct, so it's live and not a file that needs to be played
The system must be failless (beside the fact the internet can die).
Plug and play is a must, I don't want to have a really messy configuration to do. (if possible, without any kind of portforwarding).
I would really appreciate help and a decent explaination.
regards,
Robin
Well, it depends on your capabilities as a programmer.
If you're really fixated on the RPi for it's convenient form factor, there's a ton of community support, so I'd start with something like this project to kick start you in the right direction. If you already know python pretty well, modify away and have fun.
If you have no programming experience, you'll probably want to put a desktop in place of the RPi and launch some instances of VLC. It's not necessarily plug n play, but you can get close enough by getting a command line VLC to launch at startup.
Either way, the more difficult problem here is the "over the internet" part. This would really need to be a server-client model, but who is your server depends on who is more stationary (I'm guessing Location 2?) because the client will need to know the IP address of the server somehow. There are dozens of ways to make this happen, but at the end of the day, you'll want to use sockets accomplish the
It needs to be direct, so it's live and not a file
... which unfortunately gets complicated. See this answer for confirmation. Would love to help with some tips on implementation, but we need more information about your willingness to "dig into the code", the necessity of the RPi, and whether the stationary location has a static web address.

Is there any way to see on linux the USB devices on realtime?

My question is simple, is there a way to see in a terminal what usb devices do I have connected to my computer in real time?
I already know lsusb, but it just show me the devices on the moment I ask it, I would like to be able to see if one connects and disconects at some point.
Edit: Thought the answer marked underneath gives a good alternative, in order to debug the program I was working on I found usefull useing the C++ function
std::system("lsusb");
This way I could check if I had lost or not the USB device.
Sure there is, you can use the udev device manager for kernel.
Moreover you can define rules to detect plugged/unplugged devices you are interested e.g. in your case usb devices.
Here is a tutorial on how to write a udev rule

Simulating a keyboard's output (making a computer pose as another computer's keyboard)

I want to be able to connect a computer A's USB port to computer B's USB port so as to make computer A act as computer B's keyboard.
Any idea how I would go about doing that?
I'm not looking for a ready-made solution (though if one already exists and is open-sources I
would not object), but for a starting point or a good resource.
I imagine I'd need to write a driver that simulates the keyboard's protocol, and I would also need to sort out the entire USB master/slave scenario.
Anyway, any help would be appreciated.
P.S.
I want to do it with the mouse as well, but I imagine it will be a very similar process, and I think (but I might be wildly mistaken) that starting with the keyboard will be easier.
I am really excited to have found something that will do this from Hagstrom Electronics. It take a serial input and sends a USB keyboard output to another PC. If you combine this with a readily available USB to serial adaptor, then you are golden.
http://www.hagstromelectronics.com/products/usbkm232.html
I have been searching for weeks to find this, so I decided to go back to some forums and share the discovery.
Linux has support for USB gadget mode, but I think you need special hardware for that. I.e. the USB port in a normal PC can not do gadget mode.
An alternative is to wire an LPT port to a PS/2 keyboard input, this is technically simpler.
If it wasn't for the USB, I'd connect the two via LAN and have a client/server C# program that emulates a keyboard / mouse (e.g. via DirectInput).
For the USB part as far as I can tell you'll need some hardware adapter. If you're into hardware development or at least unafraid of a soldering iron and some µc programming, have a look at http://www.obdev.at/products/vusb/hidkeys.html where a HID stack for a small atmel chip is available for free. For this solution you'd need two atmega chips which communicate via I²C or SPI or such.
I'd recommend electrical separation of the two pcs, too. You never know if they share the same electrical ground or not.

Resources