Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RN42.txt 14KB

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