]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - keyboard/hhkb/rn42/RN42.txt
Merge branch 'rn42_integrate'
[max/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 Limitations:
7 - short battery life
8 - connection switching
9     the module always connects to the last linked device. Remote address setting does not work as expected.
10 - HHKB JP requires case modification for power switch and LEDs.
11     without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled.
12 - Wiress certification of RN-42
13     Japan, Korea, Taiwan, Europe, FCC, Canada
14     http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
15
16 NOTE:
17 - Lipo battery is not included. Cannot ship it from Japan due to regulations.
18
19 Bugs:
20
21 Todos:
22
23
24
25
26
27 LED Status
28 ----------
29 Configuring                     10 times per sec
30 Startup/configuration timer     2 times per sec
31 Discoverable/Inquiring/Idle     once per sec
32 Connected                       solid on
33
34
35 RN-42 Magic Command
36 --------------------
37 Magic key combination is 'LShift+RShift' by default in case of HHKB.
38
39 Here is help.
40
41     ----- Bluetooth RN-42 Help -----
42     i:       RN-42 info
43     b:       battery voltage
44     Del:     enter/exit RN-42 config mode
45     Slck:    RN-42 initialize
46     p:       pairing
47     u:       toggle Force USB mode
48
49     RN-42 info:             displays information of the module on console.
50     battery voltage:        displays current voltage of battery and uptime.
51     RN-42 initialize:       does factory reset and configures RN-42
52     pairing:                enters Pairing mode.
53     toggle Force USB mode:  switch between USB and Bluetooth
54
55
56 RN-42 Config mode
57 -----------------
58 You can tune/operate RN-42 yourself with config(command) mode.
59
60 1. hook up USB cable
61 2. run `hid_listen` command  in console
62 3. turn on Bluetooth switch
63 4. press LShift+RShift+Delete(Fn+~) you will see output like followings:
64
65     Entering config mode ...
66     CMD
67     v
68     Ver 6.15 04/26/2013
69     (c) Roving Networks
70
71 5. do config with RN-42 commands. See documentations of RN-42.
72 6. to exit also press LShift+RShift+Delete(Fn+~)
73
74     Exiting config mode ...
75     ---
76     END
77
78
79 RN-42 Initial Configuration
80 ---------------------------
81 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.
82
83 1. hook up USB cable
84 2. run `hid_listen` command  in console
85 3. turn on Bluetooth switch
86 4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings:
87
88     Entering config mode ...
89     CMD
90     Ver 6.15 04/26/2013
91     (c) Roving Networks
92     ECHO ON
93     SF,1
94     AOK
95     S-,TmkBT
96     AOK
97     SS,Keyboard/Mouse
98     AOK
99     SM,4
100     AOK
101     SW,8000
102     AOK
103     S~,6
104     AOK
105     SH,003C
106     AOK
107     SY,FFF4
108     AOK
109     R,1
110     Reboot!
111     Exiting config mode ...
112
113 5. output of command 'X' after cofiguration
114
115     Ver 6.15 04/26/2013
116     (c) Roving Networks
117     ***Settings***
118     BTA=00066667BBE9
119     BTName=TmkBT-BBE9
120     Baudrt(SW4)=115K
121     Mode  =DTR 
122     Authen=1
123     PinCod=1234
124     Bonded=0
125     Rem=NONE SET
126     ***ADVANCED Settings***
127     SrvName= Keyboard/Mouse
128     SrvClass=0000
129     DevClass=1F00
130     InqWindw=0100
131     PagWindw=0100
132     CfgTimer=255
133     StatuStr=NULL
134     HidFlags=3c
135     DTRtimer=8
136     KeySwapr=0
137     ***OTHER Settings***
138     Profile= HID
139     CfgChar= $
140     SniffEna=8000
141     LowPower=0
142     TX Power=fff4
143     IOPorts= 0
144     IOValues=0
145     Sleeptmr=0
146     DebugMod=0
147     RoleSwch=0
148
149
150 Switch to USB mode
151 ------------------
152 You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'.
153
154
155 Pairing mode
156 ------------
157 This disconnects current connect and enter pairing mode.
158
159
160
161
162 For deveropment
163 ===============
164
165 RN-42 Serial Connection
166 -----------------------
167 UART:           115200bps, 8bit, 1-stopbit, non-parity, no flow control
168 SSP:            115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
169
170 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').
171
172
173 RN-42 Commands
174 --------------
175 S-,tmkBT            // Device name
176 SS,keyboard/mouse   // service name
177 SM,4                // Auto Connect DTR mode
178 SW,8010             // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
179 S~,6                // HID profile
180 S~,0                // SPP profile
181 SH,003C             // HID register
182 SY,0004             // Transmit power
183 SC,0000             // COD: 000005C0    (see HID spec/Bluegiga doc)
184 SD,05C0             //     bit 12-8         7           6           5-0
185                     //         00101        1           1           0
186                     //         peripheral   pointing    keybaord    joystick, gamepad, ...
187 SM,6                // Pairing mode: auto connect
188 SM,4                // Master mode: Connection can be controled with GPIO6
189 SF,1                // Factroy reset
190 R,1                 // reboot
191 SR,Z                // removes all remote addresses for reconnecting.
192                     // can be used to connect another host
193 SR,I                // registers last inquiry address
194
195
196 Operation Modes
197 ---------------
198 SM,3        Auto Connect Master mode
199 SM,4        Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
200                 confirm: auto connect works and control connection with GPIO6
201 SM,5        Auto Connect ANY Mode (Mode =ANY)
202                 each time GPIO is set, make inquiry and connect to the first found device
203 SM,6        automatically reconnect(Mode =Pair)
204                 confirm: auto connect works well but difficult to enter command mode.
205
206
207 HID flag register
208 -----------------
209 SH,0200
210 GH
211
212 10 0000 0000(0200)  default
213 00 0011 1000(0038)  Combo
214 || |  | |\_\____ number of paired devices to which the module can reconnect
215 || |  | \_______ send out reports over UART (0xFF <len> <data>)
216 || \__\_________ descriptor type
217 |\______________ toggle virtual keyboard on iOS when first connected
218 \_______________ Force HID mode if GPIO11 is high on power-up
219
220     Descriptor type:
221     0000:   keybaord
222     0001:   Game Pad
223     0010:   Mouse
224     0011:   Combo
225     0100:   Joystick
226     1xxx:   reserved
227
228
229 Out report - Indicator
230 ----------------------
231 0xFE 0x02 0x01 <LED_state>
232
233
234 Apple iOS
235 ---------
236 Keyboard can be used with iPhone, but mouse cannot.
237
238
239 Android
240 -------
241 3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
242
243
244 Power Management
245 ----------------
246 Inquiry and Page window     Idle or Active  (3.1.1)
247     Downside: delay in discovery or connection time
248     SI,         // set inquiry scan window(discovery) on/off duty?
249     SJ,         // set page scan window(connection)
250     This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
251
252 Sniff mode                  Transmit
253     Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
254     In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
255     SW,<val>    // set interval timer(*0.625ms) 0000-7FFF
256
257 Deep sleep                  Idle            (3.1.2)
258     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.
259     SW,8320     // deep sleep enable(interval=0x320*0.625=500ms)
260     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.
261     To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
262         *send a charactor to the UART(first charactor will be lost)
263         *toggle CTS low to high and wait 5ms
264         *wake automatically every slot time(<val>*0.625ms)
265     Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
266     Downside: latency and data loss
267
268 Disable Output driver       Idle or Active  (3.1.3)
269     S%,1000     // set all GPIO pins(0-11) to inputs.
270
271 Lower Transmit Power        Idle or Active  (3.1.4)
272     SY,<hex>    // transmit power setting(takes effect after a power cycle and reboot)
273     Downside: reducing effective range
274
275
276 Optimizig for Latency
277 ---------------------
278 By default the firmware is optimized for throughput.
279 SQ,16           // set latency bit
280 SQ,0            // unset latency bit
281
282
283 Configuration timer settings
284 ----------------------------
285 Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
286
287 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.)
288     ST,0        // no remote, no local when connected
289     ST,<1-252>  // local and remote with timeout in seconds from power up
290     ST,253      // local only       without timeout
291     ST,254      // remote only      without timeout
292     ST,255      // local and remote without timeout
293
294
295 Commands
296 --------
297 S7,                     7bit mode
298 SA,                     Authenticaiton
299 SB,                     Send break
300 SC,                     Service class
301 SD,                     Device class
302 SM,<val>                Operation mode
303 SP,<string>             Pin code(alpahnumeric)
304 SQ,<mask>               Special configuration(GPIO, discovery mode, low latency, reboot, UART)
305 SR,<hex>                Store remote address
306 SR,Z                    Erase all address
307 SS,<string>             Set service name(1-20)**
308 ST,<val>                Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
309 SU,<val>                UART baud rate
310 SW,<val>                low-power sniff mode** deep sleep and wake up every 625us * <val>
311 SX,<0|1>                bonding enable  only acceps device that matches the stored address
312 SY,<hex>                power setting**
313 SZ,<val>                non-standard raw baud rate  <val>=baud*0.004096
314 S~,<val>                Profile     0:SPP, 5:APL, 6:HID
315 S-,<string>             Device name     -15 alphanumeric charactors
316 S?,<0|1>                role switch enable
317 S$,<char>               command mode char
318 $|,<hex>                low-power connect mode  deep sleep/active(discoverable and connectable) cycle
319 D                       display basic setting
320 E                       display extended setting
321 GB                      display the device's Bluetooth address
322 GF                      display Bluetooth address of connected device
323 GK                      show connection status
324 GR                      show remote address for reconnecting
325 G&                      show GPIO pin
326 G<char>                 show stored setting
327 +                       toggle local echo on/off
328 &                       show GPIO 3,4,6,7(DIP switch)
329 C                       connect to stored remote address
330 C,<address>             connect last address
331 CFI                     connect and go into fast data mode
332 CFR                     connect and go into fast data mode
333 CT,<address>,<val>      connect to the address and disconnect after val?
334 F,1                     fast data mod:
335 H                       display help
336 I,<time>,<cod>          inquiry scan with <cod>
337 IN,<time>,<cod>         inquiry scan with <cod>, return without BT name
338 IR                      inquiry scan with 0055AA
339 IS                      inquiry scan with 001F00
340 J                       hide pin code
341 K,                      kill    disconnects current connection
342 L                       link quality
343 M                       show modem signlal status
344 O                       display other settings
345 P,<char>                pass through?
346 Q                       quiet mode  make the module not discoverable
347 Q,0                     discoverable and connectable
348 Q,1                     not discoverable and not connectable
349 Q,2                     not discoverable and connectable
350 Q,?                     display current quiet mode
351 R,1                     reboot
352 T,<0|1>                 pass received data while in command mode
353 U,<baud>,<parity>       change UART setting tentatively
354 V                       display firmware version
355 W                       wake from quiet mode    enable discovery and connection
356 Z                       deep sleep mode(<2mA)
357
358
359 Reset to Factory Default
360 ------------------------
361 SF,1
362 R,1