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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

RN42.txt 12KB

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