Make the HID keyboard with BLED112 - bluetooth

I use the BLED112 and want to make it act like a HID keyboard.
The BLED112 receives the keystroke from the Mobile. For example, "p".
Then the dongle act like a keyboard so we can see the "p" is written on Notepad of PC.
Sending data from Mobile to dongle is not matter. I have already done.
My problem is to send the keystroke event to the PC so the dongle works like a keyboard.
I want an example or the full guide.
Thanks.

BLED112 is a Bluetooth Low Energy dongle provided by Bluegiga (Now acquired by Silicon labs). If you have studied the BLED112 user manual and bluegiga API reference documents, you'd understand that there can be two possible ways to read/write data via BLED112:
Use bgscript
use the bglib library into your C/C++ application
BLED112 is enumerated as a virual com port. I don't recall the name of the windows application that comes with BLED112 but it sounded like BLEGUI or something. This application uses the APIs to handle connections, read and write events. In a nutshell, you need to implement the same thing that this application does. For that, you can leverage the logs it spits on the console. This log will help you with all the commands you need to send and all the response that you need to handle.
Then, you need to make your application communicate with the virtual com port over which these commands will be send and responses will be received at.
Once you establish this, you'd be able to display your keystrokes.
It is a substantial work if you haven't worked with BLE. But like people say, there aren't free lunches!

Related

Establish a connection between smartphone and PC via Bluetooth automatically

I'm trying to establish a connection between my PC running Ubuntu and my iPhone via Bluetooth automatically when it becomes available, after being manually paired beforehand. I've seen this to be possible with certain peripherals, mainly audio. For example, my phone will automatically connect to a Bluetooth speaker when it is turned on and Bluetooth is active on my phone; another example is my phone automatically connects to my car's radio system via Bluetooth when I turn the car on.
I'm not able to connect my phone to my PC without first initiating the connection from the smartphone's Bluetooth menu. I'm thinking that I could possibly write an application for the PC to attempt to connect to the device every few minutes or something, but it seems that the phone needs to be the device to initiate the connection.
The only information that I need for what I'm trying to do ultimately is that the devices can pair successfully. Essentially I'm trying to build a sort of proximity trigger between my phone and my PC without using Wi-Fi and GPS - I can't use these for some specific reasons.
Is there any way to make this happen?
Yes this should be doable as long as you use the Background Processing feature for iOS apps. In the example I'll give below, we'll have the PC be the peripheral and the phone be the central, but you can really have it working either way. You will need to do the following:-
First initial connection needs to be performed in the foreground (this is due to iOS's background limitations).
On the iOS side, you need an application that acts as a central that scans and connects to the remove device (check this example as a starting point).
Upon connection, you need to bond with the PC. Bonding is important as it will prevent you from having to do the pairing again in the future. However, pairing/bonding is managed by the iPhone's OS so you cannot write it in your application, so the workaround is to have an encrypted characteristic on the PC side that will force the iPhone to bond (this is covered later).
On the PC side, you need to have a BlueZ script that acts as a peripheral that is always advertising. You can do this using bluetoothctl (check the examples here and here).
Before you start advertising, you need to have a GATT server on the PC side (to do this, check this example).
When registering characteristics, ensure that one of them has the encrypt-read property (you can find a full list of the properties here).
Now when you attempt to read this characteristic from the iOS side, the two devices should bond (make sure that your PC is bondable which you can do this via these commands).
Once the devices are paired, your iOS app needs to be working in the background constantly scanning and attempting to connect to the same peripheral (have a look at this and this example).
You can find more useful information at the links below:-
Getting started with Bluetooth Low Energy
The Ultimate Guide to CoreBluetooth Development
How to manage Bluetooth devices on Linux using bluetoothctl

Bluetooth data to HID for BLED112

We have bought BLED112 to interface our target via BT.
An android app interacting with target via BT & USB (HID).
We have used some Bluetooth communication to write a program and send data to dongle.
Now can somebody here having any experince in converting that BT data to a HID signal.
Have anybody tried that?
Is there any BGScript code which we need to write to achieve that?
Please let me know if the thought is completely wrong.
Referring to a comment above which states,
We are writing an Android App which can send data to BLED112 over BLE interface or GATT. My question is how can I convert that data (basically a command) to an HID (key event), correct me if my understanding is wrong?
If I understand the use-case correctly, I think, in the initial stages of the development, you will need to use the BLE-GUI utility that BlueGiga provides.
With that utility you can see the communication between the BLED112 Dongle and the BLE112 Module. BLED112 shall be simulating what the android app would do?
First, you will need to know the GATT structure stored in BLED112 to write to or read from the BLED112.
Secondly, the way BLE112 works is an event-based implementation. Going through the API reference document for BLE112 shall help you understand the events generation conditions and codes that are generated modified when a characteristic value is updated by the android application, or read by android application. You get events for connection, disconnection, read from, write to, notification enabled for, indication enabled for, etc.
On the BLE112 side, depending upon what service and what characteristics in that service is going to be used for data transfer between Client (Android App) and Server (BLE112), you need to write suitable implementation in event callback handlers.
There is a standard service called Human Interface Device which has a reserved UUID: 0x1812.
Once you configure your BLE112 as a HID over GATT device, your android app shall see a service with UUID: 0x1812. Parse the service descriptor and get the characteristics bundled up into the service. You can read from or write to that service depending upon access parameters set in gatt.xml
As an example, say, if it is a Keyboard, you can send the scancode for (make and break) of the key depending upon what key is pressed. How to get a scancode is out of the scope of this question anyway, and sadly I had worked on PS2 keyboards, so I don't really know how to get the scancode from a USB keyboard.
So, you have the scancode for the key pressed, and you know the characteristics to write that into. Write it, the application should enable the Notifications for that characteristics, so that it is notified whenever the key is pressed and value is written into the characteristics. To let application enable notifications or indications for the characteristics, study the developer guide that talks about how to write a gatt.xml for Bluegiga-based BLE devices. I'll give you a hint: in xml, in the characteristics configuration you have to write notify="true".
About parsing of the service and characteristics in Android, Unfortunately I am not an android developer, but an embedded developer, I know how the BLE112 module part is to be implemented, while I have no insight of how android parses the data. But, there are plenty of question and discussions about it online, which you might understand better than me since you have an android background.

How do I make a device recognize my computer as a game controller?

As an experiment, I'm trying to use my computer as an input for the Wii U. Basically, what I want to do is connect my computer to the Wii U via a male-to-male USB cable and make the Wii U think my computer is a Gamecube adapter (which uses USB).
To start, I was able to connect a Gamecube adapter to my computer and use Node.js to receive inputs. I did this to figure out which button corresponded to which input bytes.
Next, I connected my computer to the Wii U via USB but my computer doesn't recognize the Wii U (obviously). The Wii U is expecting a game controller, not a computer. Is there something that can make my computer emulate a game controller? I.e. make the Wii U identify my computer as a game controller so that it accepts inputs from my computer.
This isn't doable without some hardware modification. Your USB chipset handles a lot of the work here, and you're not going to get your computer emulate a device. However...
Gamecube and N64 controllers just use 3.4V serial lines for communication. If you took apart one of those USB-to-Gamecube adapters and wired it up to a USB-to-serial converter (3.3v like an old cell phone cable, not RS-232!) then you might be able to play with the timings to get it right and send the data you want. If that doesn't work, you could likely program an Arduino kit or similar to accept commands from your software and send them as Gamecube.
Info on the underlying protocol here: http://www.int03.co.uk/crema/hardware/gamecube/gc-control.html
You cannot simply connect two USB master ports. The controller side (your computer) needs a slave port, aka gadget port. You might want to check out the USB gadget framework (for Linux but a good staring point in any case). Or, if you prefer to get some AVR-based computer there is LUFA to get you started.
Another option is to go for emulating the Wiimote (using bluetooth) istead. Not saying that's necesserily easier thou.

Teensy 2.0 / Atmega32u4 as Keyboard: Send and Receive

I'm currently working on a device which is able to work as a keyboard and communicate via Serial with a self-written software.
Now I have to install serial drivers (from Arduino) on different computers if I want to communicate with my application which I actually want to avoid.
Is there any other solution to solve this problem? Is it possible that my microcontroller works as a keyboard AND is able to send and receive data as HID device?
Thanks and greetings!
I actually do something similar with a 32u4, but it receives its serial over the built-in UART. I do this because it's linking between two separate systems. If it were only one system I could implement a 2nd interface. (Don't forget, a USB HID device must have an IN endpoint even if you are not using it.) Or you could just throw a $2 USB/TTL converter on and do it the same as I did.

Emulate a Bluetooth Device from PC

I wonder whether it is possible to emulate a specific bluetooth device like a Remote Controller for a TV or another device with my PC. I'd be okay with installing an additional hardware device for my computer (e. g. a BlueTooth PCIe card).
I imagined something like "recording" all single commands of my original remote controller using my Bluetooth card and afterwards use these recorded commands to turn on my TV for example.
Is something like this possible (with additional hardware maybe)?
Of course this is possible. Bluetooth is just a protocol and you can impliment it in your custom software to emulate all kinds of devices. If you need to emulate simple devices like keyboard or mouse, there are many ready solutions like this.
But if you have non standard device, there won't be any ready solutions and you will have to implement it yourself. What can help you:
If you have some kind of controller for PC and you want to emulate device with unknown protocol, you can use WireShark or other sniffer to understand what's going on.
There is an emulator called BT-Sim, but it is so poorly documented that I can't even guess what it does.
You can can take as example different android software like described in answers to this question.
You can check different program samples for PC like this.
For hardware you need only simple Bluetooth dongle. However, if you want to spy on some BLE (Bluetooth Low Energy) devices, you can buy hardware sniffer like this.
(At least in Windows 10) Microsoft Store has an application called "Bluetooth LE Explorer" which is able to simulate different kind of Bluetooth GATT profiles as a peripheral.

Resources