]> git.gir.st - tmk_keyboard.git/blob - keyboard/hhkb/rn42/RN42.txt
Merge pull request #164 from cub-uanic/patch-2
[tmk_keyboard.git] / keyboard / hhkb / rn42 / RN42.txt
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.
4
5
6 RN-42:
7 http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
8
9
10 Capabitlities:
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.
15 - RN-42 config mode
16 You can change power/connection configuration of the module if needed.
17 - Low battery alert
18 Red LED turns on when low voltage.
19 - RN-42 status indicator
20 LED indicates status of Bluetooth connection.
21 - Pairing
22 The module stores up to 8 connections.
23 - Auto connect
24 The module connects the last connected device automatically.
25 - iOS support
26 works as keyboard with iPhone5. No tested completely.
27 - Android support
28 works as keyboard and mouse with Nexus5. No tested completely.
29 - Mouse keys over BT
30 Note that iOS doesn't accept mouse device.
31
32
33 Limitations:
34 - Short battery life
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.
42
43 NOTE:
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.
48
49 Bugs:
50
51 Todos:
52
53
54 Lipo Battery
55 ------------
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.
58
59 Sparkfun 850mAh
60 https://www.sparkfun.com/products/341
61 Sparkfun 1000mAh
62 https://www.sparkfun.com/products/339
63
64 Sparkfun 2000mAh battery won't fit due to its size.
65
66 Learn about Lipo battery:
67 https://learn.adafruit.com/li-ion-and-lipoly-batteries
68
69
70
71
72
73 LED Status
74 ----------
75 Configuring 10 times per sec
76 Startup/configuration timer 2 times per sec
77 Discoverable/Inquiring/Idle once per sec
78 Connected solid on
79
80
81 RN-42 Magic Command
82 --------------------
83 Magic key combination is 'LShift+RShift' by default in case of HHKB.
84
85 Here is help.
86
87 ----- Bluetooth RN-42 Help -----
88 i: RN-42 info
89 b: battery voltage
90 Del: enter/exit RN-42 config mode
91 Slck: RN-42 initialize
92 p: pairing
93 u: toggle Force USB mode
94
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
100
101
102 RN-42 Config mode
103 -----------------
104 You can tune/operate RN-42 yourself with config(command) mode.
105
106 1. hook up USB cable
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:
110
111 Entering config mode ...
112 CMD
113 v
114 Ver 6.15 04/26/2013
115 (c) Roving Networks
116
117 5. do config with RN-42 commands. See documentations of RN-42.
118 6. to exit also press LShift+RShift+Delete(Fn+~)
119
120 Exiting config mode ...
121 ---
122 END
123
124
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.
128
129 1. hook up USB cable
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:
133
134 Entering config mode ...
135 CMD
136 Ver 6.15 04/26/2013
137 (c) Roving Networks
138 ECHO ON
139 SF,1
140 AOK
141 S-,TmkBT
142 AOK
143 SS,Keyboard/Mouse
144 AOK
145 SM,4
146 AOK
147 SW,8000
148 AOK
149 S~,6
150 AOK
151 SH,003C
152 AOK
153 SY,FFF4
154 AOK
155 R,1
156 Reboot!
157 Exiting config mode ...
158
159 5. output of command 'X' after cofiguration
160
161 Ver 6.15 04/26/2013
162 (c) Roving Networks
163 ***Settings***
164 BTA=00066667BBE9
165 BTName=TmkBT-BBE9
166 Baudrt(SW4)=115K
167 Mode =DTR
168 Authen=1
169 PinCod=1234
170 Bonded=0
171 Rem=NONE SET
172 ***ADVANCED Settings***
173 SrvName= Keyboard/Mouse
174 SrvClass=0000
175 DevClass=1F00
176 InqWindw=0100
177 PagWindw=0100
178 CfgTimer=255
179 StatuStr=NULL
180 HidFlags=3c
181 DTRtimer=8
182 KeySwapr=0
183 ***OTHER Settings***
184 Profile= HID
185 CfgChar= $
186 SniffEna=8000
187 LowPower=0
188 TX Power=fff4
189 IOPorts= 0
190 IOValues=0
191 Sleeptmr=0
192 DebugMod=0
193 RoleSwch=0
194
195
196 Switch to USB mode
197 ------------------
198 You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'.
199
200
201 Pairing mode
202 ------------
203 This disconnects current connect and enter pairing mode.
204
205
206
207
208 For deveropment
209 ===============
210
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)
215
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').
217
218
219 RN-42 Commands
220 --------------
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
225 S~,6 // HID profile
226 S~,0 // SPP profile
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
231 // 00101 1 1 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
236 R,1 // reboot
237 SR,Z // removes all remote addresses for reconnecting.
238 // can be used to connect another host
239 SR,I // registers last inquiry address
240
241
242 Operation Modes
243 ---------------
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.
251
252
253 HID flag register
254 -----------------
255 SH,0200
256 GH
257
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
265
266 Descriptor type:
267 0000: keybaord
268 0001: Game Pad
269 0010: Mouse
270 0011: Combo
271 0100: Joystick
272 1xxx: reserved
273
274
275 Out report - Indicator
276 ----------------------
277 0xFE 0x02 0x01 <LED_state>
278
279
280 Apple iOS
281 ---------
282 Keyboard can be used with iPhone, but mouse cannot.
283
284
285 Android
286 -------
287 3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
288
289
290 Power Management
291 ----------------
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)
297
298 Sniff mode Transmit
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
302
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
313
314 Disable Output driver Idle or Active (3.1.3)
315 S%,1000 // set all GPIO pins(0-11) to inputs.
316
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
320
321
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
327
328
329 Configuration timer settings
330 ----------------------------
331 Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
332
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
339
340
341 Commands
342 --------
343 S7, 7bit mode
344 SA, Authenticaiton
345 SB, Send break
346 SC, Service class
347 SD, Device class
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
371 G& show GPIO pin
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?
380 F,1 fast data mod:
381 H display help
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
386 J hide pin code
387 K, kill disconnects current connection
388 L link quality
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
397 R,1 reboot
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)
403
404
405 Reset to Factory Default
406 ------------------------
407 SF,1
408 R,1
Imprint / Impressum