Bluetooth

Version 10 (J. Simmons, 02/25/2017 08:29 pm)

1 1 J. Simmons
h1. Bluetooth
2 1 J. Simmons
3 1 J. Simmons
{{>toc}}
4 1 J. Simmons
5 4 J. Simmons
h2. Introduction
6 1 J. Simmons
7 5 J. Simmons
This page covers research into creating a Bluetooth HID connection from the Holoseat controller to the gaming system (PC or console).  The Holoseat controller will need to be able to present itself as either a keyboard & mouse combination or a joypad.  The material on this page covers some Bluetooth fundamentals (classic vs BLE), the types of Bluetooth hardware used in some of our target platforms (CHIP Pro, PS4, PCs), and available libraries for interacting with Bluetooth hardware in Node.js.  It closes with an interesting (but not usable) example from the maker/hacker community.
8 1 J. Simmons
9 4 J. Simmons
h2. Summary of Findings
10 4 J. Simmons
11 4 J. Simmons
Tbd
12 4 J. Simmons
13 4 J. Simmons
h2. Bluetooth Fundamentals 
14 4 J. Simmons
15 8 J. Simmons
Bluetooth has evolved dramatically in the last few years and now comes in multiple "flavors", classic and Bluetooth Low Energy (BLE).  "Classic Bluetooth":https://en.m.wikipedia.org/wiki/Bluetooth is the standard most users are familiar with.  It is used to connect smart phones to cars and headsets.  Classic is the older flavor, it is more common (though that is starting to change in some markets), and it commonly requires pairing.  Also, according to posts from Adafruit on their "forums":https://forums.adafruit.com/viewtopic.php?f=10&t=90851#p457917 making classic devices requires paying costly dues to the Bluetooth SIG.
16 8 J. Simmons
17 8 J. Simmons
"BLE":https://en.m.wikipedia.org/wiki/Bluetooth_low_energy is a newer Bluetooth flavor, targeting battery powered devices (often sensors) and widely supported by smart phones.  It appears to be far more maker friendly as well.  It is well supported by Adafruit ("Bluetooth products, overwhelmingly BLE":https://www.adafruit.com/categories/255) and spawned a new book from Make publishing, "Make: Bluetooth":http://shop.oreilly.com/product/0636920031932.do.  
18 8 J. Simmons
19 8 J. Simmons
Human Interface Devices (HID) can be built as either classic or BLE devices.  It is not clear if the same device (using the same radio board) can be made to present itself as a classic or BLE device.  However, it seems clear that smaller organizations are moving to BLE only development.
20 4 J. Simmons
21 4 J. Simmons
h2. Bluetooth Hardware on Holoseat Platforms
22 4 J. Simmons
23 5 J. Simmons
h3. CHIP Pro
24 1 J. Simmons
25 6 J. Simmons
From the "CHIP Pro datasheet":https://docs.getchip.com/chip_pro.html#wireless-connectivity, it uses a Realtek 8723DS combination module which provides Wi-Fi B/G/N and Bluetooth 4.2 LE connectivity."  Other documentation has indicated the Bluetooth driver can be set as either a host or a device.  So, it can be used to connect with classic and BLE devices or it can present itself as a BLE device (but not both at the same time).  See notes above about implementing devices that present themselves as classic devices.  
26 4 J. Simmons
27 5 J. Simmons
Unfortunately, at present Next Thing Computing has disabled the Bluetooth driver on the CHIP Pro (see this "forum post":https://bbs.nextthing.co/t/chip-pro-bluetooth-driver-not-available/14905 last updated 2017-02-15 for more details).  For the time being we cannot demonstrate any level of Bluetooth connectivity with the CHIP Pro and it is not clear when the driver will be enabled.
28 5 J. Simmons
29 4 J. Simmons
h3. PS4
30 4 J. Simmons
31 1 J. Simmons
tbd
32 1 J. Simmons
33 1 J. Simmons
h3. PCs
34 5 J. Simmons
35 9 J. Simmons
The following material is from Chapter 1 of Make: Bluetooth.  We will include all three PC platforms in this discussion (Windows, MacOS, and Linux).  Windows supports classic Bluetooth (specifically v2.1) in Windows XP, Vista, and 7.  Windows 8 and 10 support BLE.  Note, the availability of Bluetooth hardware on Windows PCs varies greatly, though modern laptops often have some flavor of Bluetooth hardware.  
36 5 J. Simmons
37 7 J. Simmons
h3. Conclusions About Bluetooth Hardware 
38 4 J. Simmons
39 4 J. Simmons
Tbd
40 4 J. Simmons
41 7 J. Simmons
h2. Useful Bluetooth Libraries
42 1 J. Simmons
43 7 J. Simmons
"Sandeep Mistry":https://github.com/sandeepmistry maintains three Bluetooth libraries which we will likely find useful.  Note, they are all BLE only libraries and they only work with specific Bluetooth hardware.
44 7 J. Simmons
45 7 J. Simmons
* Node.js Libraries
46 7 J. Simmons
** "Noble":https://github.com/sandeepmistry/noble - library to implement a BLE central module (aka host)
47 7 J. Simmons
** "Bleno":https://github.com/sandeepmistry/bleno - a library to implement a BLE peripheral (aka device)
48 7 J. Simmons
* Arduino
49 7 J. Simmons
** "Arduino BLEPeripheral":https://github.com/sandeepmistry/arduino-BLEPeripheral - a library to implement a BLE peripheral (device)
50 4 J. Simmons
51 3 J. Simmons
h2. Maker/Hacker Example
52 3 J. Simmons
53 4 J. Simmons
In this example, the firmware from the "RN-42":https://www.sparkfun.com/products/12574 onto the "HC-05":http://cdn.makezine.com/uploads/2014/03/hc_hc-05-user-instructions-bluetooth.pdf.  This kind of hacking, while interesting, is not strictly legal (obtaining the RN-42 firmware is not something one just does), so it is not a recommended approach.  However, it does demonstrate how capable a small system can be at capturing signals from one system (the joypad) and in real time translating them to HID over Bluetooth signals.  Consider this evidence that the kind of inline gameplay translation we want the Holoseat controller to do is possible.  Much of the following research was found by following the links from a Hackaday post - "Convert Any USB Keyboard to Bluetooth":http://hackaday.com/2016/09/04/convert-any-usb-keyboard-to-bluetooth/.
54 1 J. Simmons
55 1 J. Simmons
{{youtube(L7lEDS6xj5w)}}
56 1 J. Simmons
57 1 J. Simmons
{{youtube(5qXv7TJI324)}}
58 1 J. Simmons
59 1 J. Simmons
{{youtube(qyRJgtwX0cY)}}
60 1 J. Simmons
61 1 J. Simmons
The video below is a summary of this project - "Bluetooth HID gamepad using HC-05 module":https://mitxela.com/projects/bluetooth_hid_gamepad
62 1 J. Simmons
63 1 J. Simmons
{{youtube(fWXJDNcbZAA)}}
64 2 J. Simmons
65 2 J. Simmons
h2. ESP32 Wifi Bluetooth Module
66 2 J. Simmons
67 2 J. Simmons
"ESP32 Wifi Bluetooth Module":http://www.cnx-software.com/2016/09/05/you-can-now-buy-esp3212-esp32-wifi-bluetooth-module-for-6-95, another Bluetooth module that has people talking.  Need to do more research.