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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. Roving RN-42
  2. ============
  3. TODO
  4. ----
  5. Power saving:
  6. - When not connected in a few minuts get into deep sleep to save battery life
  7. - CTS is needed for waking up from deep sleep? How deep sleep is activated?
  8. Improving:
  9. - Status LED; connecting, liked, low battery, sleeping, deep sleeping
  10. - Battry voltage display by command; like full(solid), medium(blink), low(flash)
  11. - move rn42 to protocol directory when it becomes reusable stack
  12. - LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
  13. - keyboard LED update
  14. Testing:
  15. - Factroy reset doesn't work; need to **test again** 10K pull-up is too high?
  16. - Lipo voltage ADC value is not stabilized
  17. - DCDC converter: squeaky inducter; try other inductors
  18. - Keymap layer bug: during space is pressed(mousekey) press Fn(HHKB) then release space before Fn, in result HHKB layer is locked(toggled) unintentionally.
  19. DONE:
  20. - Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm
  21. - use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB
  22. - Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done
  23. - CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done
  24. - add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24
  25. - LINKED: add trace on PIO2 to PF6 07.24
  26. - Lipo voltage ADC sensing
  27. - Lipo charger MCP73831: needs capacitor 4.7uF *2
  28. - USB connection check - 07.01
  29. - BT on/off check: whether RX line is pulled up? - checking RTS 07.01
  30. - USB/BT switching BT is on -> BT, BT is off -> USB - 07.01
  31. - Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01
  32. - Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough 07.01
  33. - Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
  34. TROUBLE SHOOT
  35. -------------
  36. 07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
  37. Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
  38. 07/18 On Linux, had an USB related trouble; keyobard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
  39. Lipo
  40. ----
  41. 850mA lasts around 9 hours(07/28)
  42. Sparkfun Polymer Lithium Ion Battery 850mAh:
  43. https://www.sparkfun.com/products/341
  44. Lipo Cell spec:
  45. https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf
  46. Protection spec:
  47. http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf
  48. min typical max
  49. over-charge 4.255 4.280 4.305
  50. over-charge discover? 4.030 4.080 4.130
  51. over-discharge 2.827 2.900 2.973
  52. over-discharge discover 3.022 3.100 3.178
  53. ADC voltage monitor: voltage divider 10K+10K(0.5)
  54. ADC=V*0.5/2.56*1024
  55. V ADC
  56. ------------------
  57. 4.20 0x347(839)
  58. 3.10 0x26b(619)
  59. Configuration
  60. -------------
  61. Ver 6.15 04/26/2013
  62. (c) Roving Networks
  63. ***Settings***
  64. BTA=0006664B3AE3
  65. BTName=tmkBT-3AE3
  66. Baudrt(SW4)=115K
  67. Mode =DTR
  68. Authen=2
  69. Bonded=0
  70. Rem=000000000000
  71. ***ADVANCED Settings***
  72. SrvName= keyboard/mouse
  73. SrvClass=0000
  74. DevClass=0000
  75. InqWindw=0100
  76. PagWindw=0100
  77. CfgTimer=255
  78. StatuStr=NULL
  79. HidFlags=3c
  80. DTRtimer=8
  81. KeySwapr=0
  82. ***OTHER Settings***
  83. Profile= HID
  84. CfgChar= $
  85. SniffEna=8010
  86. LowPower=0
  87. TX Power=0
  88. IOPorts= 0
  89. IOValues=0
  90. Sleeptmr=0
  91. DebugMod=0
  92. RoleSwch=0
  93. Serial connection
  94. -----------------
  95. Serial line: 115200bps, 8bit, 1-stopbit, non-parity, no flow control
  96. SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
  97. To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD')
  98. To exit type '---'(you will see 'END') and '+' to get local echo.
  99. Setting command mode
  100. --------------------
  101. S-,tmkBT // Device name
  102. SS,keyboard/mouse // service name
  103. SM,4 // Auto Connect DTR mode
  104. SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
  105. S~,6 // HID profile
  106. SH,003C // HID register
  107. SY,0004 // Transmit power
  108. Other options:
  109. SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc)
  110. SD,05C0 // bit 12-8 7 6 5-0
  111. // 00101 1 1 0
  112. // peripheral pointing keybaord joystick, gamepad, ...
  113. SM,6 // Pairing mode: auto connect
  114. SM,4 // Master mode: Connection can be controled with GPIO6
  115. HID profile
  116. -----------
  117. S~,6 HID profile
  118. S~,0 SPP profile
  119. R,1 reboot
  120. Apple iOS
  121. ---------
  122. Keyboard can be used with iPhone, but mouse cannot.
  123. To operate iOS with keyboard is not so useful, though.
  124. There may be iOS specific scancodes?
  125. HID flag register
  126. -----------------
  127. SH,0200
  128. GH
  129. 10 0000 0000(0200) default
  130. 00 0011 1000(0038) Combo
  131. || | | |\_\____ number of paired devices to which the module can reconnect
  132. || | | \_______ send out reports over UART (0xFF <len> <data>)
  133. || \__\_________ descriptor type
  134. |\______________ toggle virtual keyboard on iOS when first connected
  135. \_______________ Force HID mode if GPIO11 is high on power-up
  136. Descriptor type:
  137. 0000: keybaord
  138. 0001: Game Pad
  139. 0010: Mouse
  140. 0011: Combo
  141. 0100: Joystick
  142. 1xxx: reserved
  143. Out report - Indicator
  144. ----------------------
  145. 0xFE 0x02 0x01 <LED_state>
  146. LED Status
  147. ----------
  148. Configuring 10 times per sec
  149. Startup/configuration timer 2 times per sec
  150. Discoverable/Inquiring/Idle once per sec
  151. Connected solid on
  152. Pairing
  153. -------
  154. First, host initiates pairing process and once it is done, auto connect will work thereafter.
  155. SM,3 Master mode
  156. SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
  157. confirm: auto connect works and control connection with GPIO6
  158. SM,5 Auto Connect ANY Mode (Mode =ANY)
  159. each time GPIO is set, make inquiry and connect to the first found device
  160. SM,6 automatically reconnect(Mode =Pair)
  161. confirm: auto connect works well but difficult to enter command mode.
  162. Fast data mode
  163. --------------
  164. The module enters fast data mode after 'remote configuration timer' window is passed from power on.
  165. In this mode the module does not accept '$$$' to enter command mode.
  166. Power Management
  167. ----------------
  168. Inquiry and Page window Idle or Active (3.1.1)
  169. Downside: delay in discovery or connection time
  170. SI, // set inquiry scan window(discovery) on/off duty?
  171. SJ, // set page scan window(connection)
  172. This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
  173. Sniff mode Transmit
  174. Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
  175. In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
  176. SW,<val> // set interval timer(*0.625ms) 0000-7FFF
  177. Deep sleep Idle (3.1.2)
  178. 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.
  179. SW,8320 // deep sleep enable(interval=0x320*0.625=500ms)
  180. 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.
  181. To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
  182. *send a charactor to the UART(first charactor will be lost)
  183. *toggle CTS low to high and wait 5ms
  184. *wake automatically every slot time(<val>*0.625ms)
  185. Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
  186. Downside: latency and data loss
  187. Disable Output driver Idle or Active (3.1.3)
  188. S%,1000 // set all GPIO pins(0-11) to inputs.
  189. Lower Transmit Power Idle or Active (3.1.4)
  190. SY,<hex> // transmit power setting(takes effect after a power cycle and reboot)
  191. Downside: reducing effective range
  192. Optimizig for Latency
  193. ---------------------
  194. By default the firmware is optimized for throughput.
  195. SQ,16 // set latency bit
  196. SQ,0 // unset latency bit
  197. Configuration timer settings
  198. ----------------------------
  199. Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
  200. 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.)
  201. ST,0 // no remote, no local when connected
  202. ST,<1-252> // local and remote with timeout in seconds from power up
  203. ST,253 // local only without timeout
  204. ST,254 // remote only without timeout
  205. ST,255 // local and remote without timeout
  206. Android
  207. -------
  208. 3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
  209. Commands
  210. --------
  211. SC,
  212. SM,<val>
  213. SD,
  214. SP,<string> Pin code(alpahnumeric)
  215. SQ,<mask> Special configuration(GPIO, discovery mode, low latency, reboot, UART)
  216. SR,<hex> Store remote address
  217. SR,Z Erase all address
  218. SS,<string> Set service name(1-20)**
  219. ST,<val> Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
  220. SU,<val> UART baud rate
  221. SW,<val> low-power sniff mode** deep sleep and wake up every 625us * <val>
  222. SX,<0|1> bonding enable only acceps device that matches the stored address
  223. SY,<hex> power setting**
  224. SZ,<val> non-standard raw baud rate <val>=baud*0.004096
  225. S~,<val> Profile 0:SPP, 5:APL, 6:HID
  226. S-,<string> Device name -15 alphanumeric charactors
  227. S?,<0|1> role switch enable
  228. S$,<char> command mode char
  229. $|,<hex> low-power connect mode deep sleep/active(discoverable and connectable) cycle
  230. D display basic setting
  231. E display extended setting
  232. GB display the device's Bluetooth address
  233. GF display Bluetooth address of connected device
  234. GK show connection status
  235. GR show remote address for reconnecting
  236. G& show GPIO pin
  237. G<char> show stored setting
  238. + toggle local echo on/off
  239. & show GPIO 3,4,6,7(DIP switch)
  240. C connect to stored remote address
  241. C,<address> connect last address
  242. CFI connect and go into fast data mode
  243. CFR connect and go into fast data mode
  244. CT,<address>,<val> connect to the address and disconnect after val?
  245. F,1 fast data mod:
  246. H display help
  247. I,<time>,<cod> inquiry scan with <cod>
  248. IN
  249. IQ scan
  250. IS inquiry scan with 001F00
  251. J hide pin code
  252. K, kill disconnects current connection
  253. L link quality
  254. M show modem signlal status
  255. O display other settings
  256. P,<car> pass through?
  257. Q quiet mode make the module not discoverable
  258. Q,0 discoverable and connectable
  259. Q,1 not discoverable and not connectable
  260. Q,2 not discoverable and connectable
  261. Q,? display current quiet mode
  262. R,1 reboot
  263. T,<0|1> pass received data while in command mode
  264. U,<baud>,<parity> change UART setting tentatively
  265. V display firmware version
  266. W wake from quiet mode enable discovery and connection
  267. Z deep sleep mode(<2mA)
  268. help
  269. ----
  270. *** SET COMMANDS ***
  271. SA,<3,0> - Authentication
  272. SC,<hex> - Service Class
  273. SD,<hex> - Device Class
  274. SE,<1-16> - UUID
  275. SF,1 - Factory Defaults
  276. SH,<hex> - HID flags
  277. SI,<hex> - Inquiry Scan Window
  278. SJ,<hex> - Page Scan Window
  279. SL,<E,O,N> - Parity
  280. SM,<0-5> - Mode (0=slav,1=mstr,2=trig,3=auto,4=DTR,5=Any)
  281. SN,<name> - Name
  282. SO,<text> - conn/discon Status
  283. SP,<text> - Pin Code
  284. SR,<adr> - Remote Address
  285. SS,<text> - Service Name
  286. ST,<num> - Config Timer
  287. SU,<rate> - Baudrate
  288. SW,<hex> - Sniff Rate
  289. SX,<1,0> - Bonding
  290. SY,<hex> - TX power
  291. SZ,<num> - Raw Baudrate
  292. S~,<0-6> - Profile (0=SPP,1=DCE,2=DTE,3=MDM,4=D&S,6=HID
  293. S?,<0-1> - role switch
  294. S$,<char> - CMD mode char
  295. S@,<hex> - io port dir
  296. S&,<hex> - io port val
  297. S%,<hex> - io boot dir
  298. S^,<hex> - io boot val
  299. S*,<hex> - pio(8-11) set
  300. S|,<hex> - low power timers
  301. S+,<num> - DTR timer
  302. S=,<hex> - Key mapper
  303. S:,<num> - sleep timer
  304. *** DISPLAY ***
  305. D - Basic Settings
  306. E - Extended Settings
  307. G<X> - Stored setting
  308. GB - BT Address
  309. GF - BT Address of Last Connection
  310. GK - Connect Status
  311. G& - I/O Ports
  312. V - Firmare version
  313. *** OTHER ***
  314. C,<adr> - Connect
  315. F,1 - Fast Mode
  316. I,<time>,<cod> - Device Scan Inquiry
  317. J - Hide Pin Code
  318. K, - Kill (disconnect)
  319. L, - toggle local echo
  320. P,<text> - Pass Thru
  321. Q - Quiet (no discovery)
  322. R,1 - Reboot
  323. T,<0,1> - send data in CMD mode
  324. U,<rate>,<E,O,N> - Temp Uart Change
  325. Z - low power sleep
  326. & - Read switches