1 RN-42 Bluetooth Module Support
2 ==============================
3 Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board.
7 http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
11 - USB keyboard functions
12 completely equivarent to USB controller including mouse keys and NKRO.
13 - Switching between USB and Bluetooth
14 You can switch the two connections with BT switch or key combination.
16 You can change power/connection configuration of the module if needed.
18 Red LED turns on when low voltage.
19 - RN-42 status indicator
20 LED indicates status of Bluetooth connection.
22 The module stores up to 8 connections.
24 The module connects the last connected device automatically.
26 works as keyboard with iPhone5. No tested completely.
28 works as keyboard and mouse with Nexus5. No tested completely.
30 Note that iOS doesn't accept mouse device.
35 Around 12hr with 1000mAh
36 - No connection switching
37 RN-42 auto-connects to the last connected device.
38 Some of consumer products can switch between devices, for example Logitech K480.
39 http://www.logitech.com/en-us/product/multi-device-keyboard-k480?crid=26
40 - HHKB JP requires case modification for BT switch and LEDs.
41 without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled.
44 - LIPO BATTERY IS VERY DANGEROUS, TAKE EXTRA CARE OF YOUR SAFETY AND PROPERTY.
45 - RN-42 version 6.15 is supported.
46 - No NKRO over Bluetooth
47 - Check you country's wiress regulation and certification of RN-42.
56 You can use 3.7V Lithium Ion battery with JST PH 2pin connector and protection circuit.
57 Battery space inside HHKB is around 54mm x 50mm and its height is 7mm.
60 https://www.sparkfun.com/products/341
62 https://www.sparkfun.com/products/339
64 Sparkfun 2000mAh battery won't fit due to its size.
66 Learn about Lipo battery:
67 https://learn.adafruit.com/li-ion-and-lipoly-batteries
75 Configuring 10 times per sec
76 Startup/configuration timer 2 times per sec
77 Discoverable/Inquiring/Idle once per sec
83 Magic key combination is 'LShift+RShift' by default in case of HHKB.
87 ----- Bluetooth RN-42 Help -----
90 Del: enter/exit RN-42 config mode
91 Slck: RN-42 initialize
93 u: toggle Force USB mode
95 RN-42 info: displays information of the module on console.
96 battery voltage: displays current voltage of battery and uptime.
97 RN-42 initialize: does factory reset and configures RN-42
98 pairing: enters Pairing mode.
99 toggle Force USB mode: switch between USB and Bluetooth
104 You can tune/operate RN-42 yourself with config(command) mode.
107 2. run `hid_listen` command in console
108 3. turn on Bluetooth switch
109 4. press LShift+RShift+Delete(Fn+~) you will see output like followings:
111 Entering config mode ...
117 5. do config with RN-42 commands. See documentations of RN-42.
118 6. to exit also press LShift+RShift+Delete(Fn+~)
120 Exiting config mode ...
125 RN-42 Initial Configuration
126 ---------------------------
127 RN-42 is configured as SPP device at factory reset, you need to configure it as HID device. This is needed just once first time.
130 2. run `hid_listen` command in console
131 3. turn on Bluetooth switch
132 4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings:
134 Entering config mode ...
157 Exiting config mode ...
159 5. output of command 'X' after cofiguration
172 ***ADVANCED Settings***
173 SrvName= Keyboard/Mouse
198 You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'.
203 This disconnects current connect and enter pairing mode.
211 RN-42 Serial Connection
212 -----------------------
213 UART: 115200bps, 8bit, 1-stopbit, non-parity, no flow control
214 SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
216 To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD') and type '+' to get local echo. To exit type '---'(you will see 'END').
221 S-,tmkBT // Device name
222 SS,keyboard/mouse // service name
223 SM,4 // Auto Connect DTR mode
224 SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
227 SH,003C // HID register
228 SY,0004 // Transmit power
229 SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc)
230 SD,05C0 // bit 12-8 7 6 5-0
232 // peripheral pointing keybaord joystick, gamepad, ...
233 SM,6 // Pairing mode: auto connect
234 SM,4 // Master mode: Connection can be controled with GPIO6
235 SF,1 // Factroy reset
237 SR,Z // removes all remote addresses for reconnecting.
238 // can be used to connect another host
239 SR,I // registers last inquiry address
244 SM,3 Auto Connect Master mode
245 SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
246 confirm: auto connect works and control connection with GPIO6
247 SM,5 Auto Connect ANY Mode (Mode =ANY)
248 each time GPIO is set, make inquiry and connect to the first found device
249 SM,6 automatically reconnect(Mode =Pair)
250 confirm: auto connect works well but difficult to enter command mode.
258 10 0000 0000(0200) default
259 00 0011 1000(0038) Combo
260 || | | |\_\____ number of paired devices to which the module can reconnect
261 || | | \_______ send out reports over UART (0xFF <len> <data>)
262 || \__\_________ descriptor type
263 |\______________ toggle virtual keyboard on iOS when first connected
264 \_______________ Force HID mode if GPIO11 is high on power-up
275 Out report - Indicator
276 ----------------------
277 0xFE 0x02 0x01 <LED_state>
282 Keyboard can be used with iPhone, but mouse cannot.
287 3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
292 Inquiry and Page window Idle or Active (3.1.1)
293 Downside: delay in discovery or connection time
294 SI, // set inquiry scan window(discovery) on/off duty?
295 SJ, // set page scan window(connection)
296 This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
299 Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
300 In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
301 SW,<val> // set interval timer(*0.625ms) 0000-7FFF
303 Deep sleep Idle (3.1.2)
304 In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer.
305 SW,8320 // deep sleep enable(interval=0x320*0.625=500ms)
306 In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second.
307 To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
308 *send a charactor to the UART(first charactor will be lost)
309 *toggle CTS low to high and wait 5ms
310 *wake automatically every slot time(<val>*0.625ms)
311 Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
312 Downside: latency and data loss
314 Disable Output driver Idle or Active (3.1.3)
315 S%,1000 // set all GPIO pins(0-11) to inputs.
317 Lower Transmit Power Idle or Active (3.1.4)
318 SY,<hex> // transmit power setting(takes effect after a power cycle and reboot)
319 Downside: reducing effective range
322 Optimizig for Latency
323 ---------------------
324 By default the firmware is optimized for throughput.
325 SQ,16 // set latency bit
326 SQ,0 // unset latency bit
329 Configuration timer settings
330 ----------------------------
331 Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
333 The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.)
334 ST,0 // no remote, no local when connected
335 ST,<1-252> // local and remote with timeout in seconds from power up
336 ST,253 // local only without timeout
337 ST,254 // remote only without timeout
338 ST,255 // local and remote without timeout
348 SM,<val> Operation mode
349 SP,<string> Pin code(alpahnumeric)
350 SQ,<mask> Special configuration(GPIO, discovery mode, low latency, reboot, UART)
351 SR,<hex> Store remote address
352 SR,Z Erase all address
353 SS,<string> Set service name(1-20)**
354 ST,<val> Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
355 SU,<val> UART baud rate
356 SW,<val> low-power sniff mode** deep sleep and wake up every 625us * <val>
357 SX,<0|1> bonding enable only acceps device that matches the stored address
358 SY,<hex> power setting**
359 SZ,<val> non-standard raw baud rate <val>=baud*0.004096
360 S~,<val> Profile 0:SPP, 5:APL, 6:HID
361 S-,<string> Device name -15 alphanumeric charactors
362 S?,<0|1> role switch enable
363 S$,<char> command mode char
364 $|,<hex> low-power connect mode deep sleep/active(discoverable and connectable) cycle
365 D display basic setting
366 E display extended setting
367 GB display the device's Bluetooth address
368 GF display Bluetooth address of connected device
369 GK show connection status
370 GR show remote address for reconnecting
372 G<char> show stored setting
373 + toggle local echo on/off
374 & show GPIO 3,4,6,7(DIP switch)
375 C connect to stored remote address
376 C,<address> connect last address
377 CFI connect and go into fast data mode
378 CFR connect and go into fast data mode
379 CT,<address>,<val> connect to the address and disconnect after val?
382 I,<time>,<cod> inquiry scan with <cod>
383 IN,<time>,<cod> inquiry scan with <cod>, return without BT name
384 IR inquiry scan with 0055AA
385 IS inquiry scan with 001F00
387 K, kill disconnects current connection
389 M show modem signlal status
390 O display other settings
391 P,<char> pass through?
392 Q quiet mode make the module not discoverable
393 Q,0 discoverable and connectable
394 Q,1 not discoverable and not connectable
395 Q,2 not discoverable and connectable
396 Q,? display current quiet mode
398 T,<0|1> pass received data while in command mode
399 U,<baud>,<parity> change UART setting tentatively
400 V display firmware version
401 W wake from quiet mode enable discovery and connection
402 Z deep sleep mode(<2mA)
405 Reset to Factory Default
406 ------------------------