From a77ae5f84312e295daabfdc46c79a627b84fee4f Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 18 Apr 2013 15:51:14 +0900 Subject: [PATCH 1/3] Add support of iWRAP5 - mouse virtical wheel - consumer page --- keyboard/hhkb/Makefile.iwrap | 22 +- protocol/iwrap.mk | 18 +- protocol/iwrap/combo.desc | 1 + protocol/iwrap/consumer.desc | 1 + protocol/iwrap/{iWRAP.txt => iWRAP4.txt} | 0 protocol/iwrap/iWRAP5.txt | 345 +++++++++++++++++++++++ protocol/iwrap/iwrap.c | 15 +- protocol/iwrap/keyboard.desc | 1 + protocol/iwrap/main.c | 19 +- protocol/iwrap/mouse.desc | 1 + protocol/vusb.mk | 6 +- 11 files changed, 402 insertions(+), 27 deletions(-) create mode 100644 protocol/iwrap/combo.desc create mode 100644 protocol/iwrap/consumer.desc rename protocol/iwrap/{iWRAP.txt => iWRAP4.txt} (100%) create mode 100644 protocol/iwrap/iWRAP5.txt create mode 100644 protocol/iwrap/keyboard.desc create mode 100644 protocol/iwrap/mouse.desc diff --git a/keyboard/hhkb/Makefile.iwrap b/keyboard/hhkb/Makefile.iwrap index 8d7f4fc6..2d9d82c4 100644 --- a/keyboard/hhkb/Makefile.iwrap +++ b/keyboard/hhkb/Makefile.iwrap @@ -29,8 +29,6 @@ OPT_DEFS = -DDEBUG_LEVEL=0 # MCU name, you MUST set this to match the board you are using # type "make clean" after changing this, so all files will be rebuilt MCU = atmega328p -# avrdude doesn't know atmega168p -AVRDUDE_MCU = $(MCU) # Processor frequency. @@ -41,6 +39,15 @@ AVRDUDE_MCU = $(MCU) F_CPU = 12000000 +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=2048 + + # Build Options # comment out to disable the options. # @@ -75,8 +82,8 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex # to submit bug reports. #AVRDUDE_VERBOSE = -v -v -#AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER) +#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) @@ -89,9 +96,8 @@ PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) -#include $(TOP_DIR)/protocol/iwrap.mk -# To be swatchable btween Bluetooth and USB. Comment out if you don't need USB. -include $(TOP_DIR)/protocol/vusb.mk -#include $(TOP_DIR)/protocol.mk +include $(TOP_DIR)/protocol/iwrap.mk +# TODO: to be selectable: V-USB, LUFA or PJRC +#include $(TOP_DIR)/protocol/vusb.mk include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk diff --git a/protocol/iwrap.mk b/protocol/iwrap.mk index 96aa4140..e1d0efe6 100644 --- a/protocol/iwrap.mk +++ b/protocol/iwrap.mk @@ -2,10 +2,22 @@ IWRAP_DIR = protocol/iwrap OPT_DEFS += -DPROTOCOL_IWRAP -SRC += $(IWRAP_DIR)/iwrap.c \ +SRC += $(IWRAP_DIR)/main.c \ + $(IWRAP_DIR)/iwrap.c \ $(IWRAP_DIR)/suart.S \ - $(IWRAP_DIR)/sendchar_uart.c \ - $(IWRAP_DIR)/uart.c + $(COMMON_DIR)/sendchar_uart.c \ + $(COMMON_DIR)/uart.c + +# TODO: compatible with LUFA and PJRC +# V-USB +# +#VUSB_DIR = protocol/vusb +#OPT_DEFS += -DPROTOCOL_VUSB +#SRC += $(VUSB_DIR)/vusb.c \ +# $(VUSB_DIR)/usbdrv/usbdrv.c \ +# $(VUSB_DIR)/usbdrv/usbdrvasm.S \ +# $(VUSB_DIR)/usbdrv/oddebug.c +#VPATH += $(TOP_DIR)/protocol/vusb:$(TOP_DIR)/protocol/vusb/usbdrv # Search Path diff --git a/protocol/iwrap/combo.desc b/protocol/iwrap/combo.desc new file mode 100644 index 00000000..572f9990 --- /dev/null +++ b/protocol/iwrap/combo.desc @@ -0,0 +1 @@ +05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 diff --git a/protocol/iwrap/consumer.desc b/protocol/iwrap/consumer.desc new file mode 100644 index 00000000..d7f2217e --- /dev/null +++ b/protocol/iwrap/consumer.desc @@ -0,0 +1 @@ +050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 diff --git a/protocol/iwrap/iWRAP.txt b/protocol/iwrap/iWRAP4.txt similarity index 100% rename from protocol/iwrap/iWRAP.txt rename to protocol/iwrap/iWRAP4.txt diff --git a/protocol/iwrap/iWRAP5.txt b/protocol/iwrap/iWRAP5.txt new file mode 100644 index 00000000..e5ecc5c8 --- /dev/null +++ b/protocol/iwrap/iWRAP5.txt @@ -0,0 +1,345 @@ +Terminology +=========== +PSM +HIDP HID Protocol +L2CAP Logical Link Control Adaptation Protocol +MTU Maximum Transmission Unit + + + +HID Protocol Messages +===================== +3 of HID_SPEC_V11.pdf + +Control channel PSM=0x0011 +Interrupt channel PSM=0x0013 + +HANDSHAKE(0) +HID_CONTROL(1) +GET_REPORT(4) +------------- +Host requests report(DATA payload on Control channel) from Device + + Size Desc +------------------------------------------------------------------------------ +HIDP-Hdr 1 7..4: HIDP Message TYpe(4: GET_REPORT) + 3: Size(1:2-octed buffer size, 0:size of the report) + 2: 0 + 1..0: Report Type(1:input, 2:output, 3: feature) +ReportID 1 Optional +BufferSize 2 Optional(specified when Size=1) + +SET_REPORT(5) +GET_PROTOCOL(6) +SET_PROTOCOL(7) +DATA(A) +------- +Input/Output Report: All DATA payloads flow on Interrupt channel. +Other: flows on Control channel. + + Size Desc +------------------------------------------------------------------------------ +HIDP-Hdr 1 7..4 0xA + 3..2 Reserved(0) + 1..0 Report Type(0:Other, 1:Input, 2:Output, 3:Feature) +Payload N Data + + + + +Boot Protocol +============= +3.3.2 +No report descriptor, fixed report descriptors defined. + +Device ReportID Size +--------------------------------- +Reserved 0 +Keyboard 1 9octets +Mouse 2 4octets +Reserved 3-255 + +Report descriptor +----------------- +Report ID is added to USB HID boot protocol descriptor. +Boot Protocol device doesn't need to supply descriptors. and can send extra data on end of boot report this data will be ignored unless host supports report descriptor. + +Report Protocol devices can have specific descriptors. Using Boot protocol descriptor followed by extra data may be useful for compatibility to Boot protocol only supported host. + +NOTE: +Bluegiga HID sample say report ID of mouse is 1 but 2? +Bluegiga HID sample say report ID of consumer page is 2 but 3? +** mouse.desc and consumer.desc were fixed. + size +keyboard.desc 67 0x43 +mouse.desc 60 0x3c +consumer.desc 82 0x52 +combo.desc 209 0xd1 + + + +SDP +=== +attributes(3.3.2) +---------- +HIDDeviceSubclass + which type is supported in Boot Protocol Mode +7 6 +--- +0 1 Keyboard +1 0 Pointing device +1 1 Combo keyboard/pointing device + +HIDBootDevice + TRUE +HIDReconnectInitiate + TRUE + + +Class of Device/Service +======================= +http://phys.sci.hokudai.ac.jp/LABS/yts/pic/GB002/Bluetooth_assigned_numbers_baseband.pdf + +0x0005C0 Keyboard and Pointing deivce(combo) + + +23 16 15 8 7 0 +--------------------------------- +Service |Major |Minor |Format + +Format type +1 0 +--- +0 0 + +Minor Device Class of Peripheral Major +7 6 +--- +0 1 Keyboard +1 0 Pointing device +1 1 Combo keyboard/pointing device + + +Major device classes +12 11 10 9 8 +-------------- + 0 0 0 0 0 Miscellaneous + 0 0 0 0 1 Computer + 0 0 0 1 0 Phone + 0 0 0 1 1 LAN /Network Access point + 0 0 1 0 0 Audio/Video (headset,speaker,stereo, video display, vcr..... + 0 0 1 0 1 *Peripheral (mouse, joystick, keyboards, ..... ) + 0 0 1 1 0 Imaging (printing, scanner, camera, display, ...) + 1 1 1 1 1 Uncategorized, specific device code not specified + X X X X X All other values reserved + + +Major service classes +bit +-------------------------------------- +13 Limited Discoverable Mode [Ref #1] +14 (reserved) +15 (reserved) +16 Positioning (Location identification) +17 Networking (LAN, Ad hoc, ...) +18 Rendering (Printing, Speaker, ...) +19 Capturing (Scanner, Microphone, ...) +20 Object Transfer (v-Inbox, v-Folder, ...) +21 Audio (Speaker, Microphone, Headset service, ...) +22 Telephony (Cordless telephony, Modem, Headset service, ...) +23 Information (WEB-server, WAP-server, ...) + + + + +SET PROFILE HID 0d c0 100 0 en 0409 HHKB pro Bluetooth keyboard + +{function bit} uint8 +{subclass} uint8 +{version} uint16 +{country} uint8 +{BTlang} char[2] +{USBlang} uint16 +{name} string + + +SET PROFILE HID 0f c0 100 0 en 0409 TMK Bluetooth keyboard + +// composite device: keyboard and mouse +SET BT CLASS 005c0 + + + +Authentication SSP +------------------- +SET BT SSP 2 0 PASS KEY entering +SET BT SSP 3 0 NO PASS KEY entering +SET BT SSP + : 0:display only 1:display+yes/no button 2:keyboard only 3:none +SET BT SSP 2 1 # 2:keyboard only 1:Man-in-the-middle protection is needed +SET BT SSP 2 0 # 2:keyboard only 0:Man-in-the-middle protection is not needed + + +SET BT SSP 2 1 + bond only if MITM protection is supported by host +SET BT SSP 2 0 + bond even if MITM protection is not supported by host + +On Windows 'Add device' causes SSP PASSKEY event on iWRAP + SSP PASSKEY 78:dd:08:b7:e4:a2 ? + +If device has display(0 or 1) this event occurs. User should be shown this code on the device. + SSP CONFIRM 78:dd:08:b7:e4:a2 517572 + + +SET BT SSP 3 0 + No input/output, No MITM protection. + Without procedure of authentication the divice is bond to host. + + +Connect +======= +CALL 78:dd:08:b7:e4:a2 11 HID + + +Setting +======== +SET BT PAIR * +SET RESET + +SET BT CLASS 0005c0 +SET BT AUTH * 0000 +SET BT SSP 2 0 +SET CONTROL CONFIG 800 +SET PROFILE HID 0f c0 0100 00 en 0409 Bluetooth keyboard +SET PROFILE SPP + +SET CONTROL INIT SET CONTROL MUX 0 +SET BT NAME TMK Blootooth WT12 +SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) +SDP ADD 1124 HID +SET BT PAIRCOUNT 4 +SET BT POWER 3 3 3 +SET BT SNIFF 100 20 1 8 +RESET + +SET CONTROL BAUD 38400,8n1 + +# combo keyboard + mouse +HID SET 7f 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0 + +HID SET d1 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 + + +--------------------- +SET BT BDADDR 00:07:80:47:22:14 +SET BT NAME TMK BT WT12 +SET BT CLASS 0005c0 +SET BT AUTH * 0000 +SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP +SET BT LAP 9e8b33 +SET BT PAGEMODE 4 2000 1 +SET BT PAIRCOUNT 4 +SET BT PAIR 78:dd:08:b7:e4:a2 fe2fd79e86c6bbfa9351a032bceb2648 +SET BT POWER 3 3 3 +SET BT ROLE 1 f 12c0 +SET BT SNIFF 100 20 1 8 +SET BT SSP 3 0 +SET BT MTU 672 +SET CONTROL BAUD 38400,8n1 +SET CONTROL CD 00 0 +SET CONTROL ECHO 7 +SET CONTROL ESCAPE - 20 1 +SET CONTROL GAIN 0 5 +SET CONTROL INIT SET CONTROL MUX 0 +SET CONTROL MSC DTE 00 00 00 00 00 00 +SET CONTROL PIO 00 00 +SET CONTROL READY 00 +SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard +SET +SET control config list +SET CONTROL CONFIG 0000 0000 0000 410e CLOCK_CACHE INTERLACED_INQ INTERLACED_PAGE KLUDGE UART_LATENCY + + + +WRAP THOR AI (5.0.1 build 620) +Copyright (c) 2003-2012 Bluegiga Technologies Inc. +Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 + BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME + - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) + - Bluetooth version 3.0, Power class 2 + - Loader 8615, firmware 8825 (56-bit encryption), native execution mode + - up 0 days, 00:13, 0 connections (pool 1) + - User configuration: +&028b = 0000 1388 +&028c = 0001 0020 0100 0001 0008 0000 +&028d = 0000 +&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 +&0298 = c006 +&0299 = 0000 0000 +&02a3 = 0030 0030 0030 0030 +&02a4 = 009d 0000 +&02a5 = 0053 0045 0054 0020 0043 004f 004e 0054 0052 004f 004c 0020 004d 0055 0058 0020 0030 +&02a7 = 0000 05c0 +&02a8 = 400e 0000 0000 +&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +&02ab = 0001 000f 12c0 +&02ac = 0000 0020 002b 0000 0000 0000 0000 0000 0000 0000 000a 0000 0000 0000 0004 0000 0000 0000 0000 02a0 0000 0000 0000 0000 +&02ad = 4d54 204b 5442 5720 3154 0032 +&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 +&02b3 = 0004 0004 0004 0000 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 000d 0007 0005 8afb 0005 0000 1c13 0000 0c3d 0005 b435 0006 b450 0006 0000 1416 000d +&02b7 = 000f 00c0 0100 0000 0065 006e 0409 4d54 204b 6c42 6575 6f74 746f 2068 656b 6279 616f 6472 0000 +--------------------- + + +---------- +after SET RESET +---------- +WRAP THOR AI (5.0.1 build 620) +Copyright (c) 2003-2012 Bluegiga Technologies Inc. +READY. +set +SET BT BDADDR 00:07:80:47:22:14 +SET BT NAME WT12 +SET BT CLASS 001f00 +SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP +SET BT LAP 9e8b33 +SET BT PAGEMODE 4 2000 1 +SET BT POWER 3 3 3 +SET BT ROLE 0 f 7d00 +SET BT SNIFF 0 20 1 8 +SET BT SSP 3 0 +SET BT MTU 667 +SET CONTROL BAUD 115200,8n1 +SET CONTROL CD 00 0 +SET CONTROL ECHO 7 +SET CONTROL ESCAPE 43 00 1 +SET CONTROL GAIN 0 5 +SET CONTROL MSC DTE 00 00 00 00 00 00 +SET CONTROL PIO 00 00 +SET CONTROL READY 00 +SET PROFILE SPP Bluetooth Serial Port +SET + + +SET CONTROL CONFIG 0000 0000 0000 0100 KLUDGE + + +info config +WRAP THOR AI (5.0.1 build 620) +Copyright (c) 2003-2012 Bluegiga Technologies Inc. +Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 + BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME + - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) + - Bluetooth version 3.0, Power class 2 + - Loader 8615, firmware 8825 (56-bit encryption), native execution mode + - up 0 days, 00:00, 0 connections (pool 1) + - User configuration: +&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 +&0299 = 0000 0000 +&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 +&02ad = 5457 3231 +&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 +READY. +---------- diff --git a/protocol/iwrap/iwrap.c b/protocol/iwrap/iwrap.c index 3cc9ca30..d65d9e38 100644 --- a/protocol/iwrap/iwrap.c +++ b/protocol/iwrap/iwrap.c @@ -334,7 +334,7 @@ static void send_keyboard(report_keyboard_t *report) // HID raw mode header xmit(0x9f); xmit(0x0a); // Length - xmit(0xa1); // keyboard report + xmit(0xa1); // DATA(Input) xmit(0x01); xmit(report->mods); xmit(0x00); // reserved byte(always 0) @@ -355,9 +355,16 @@ static void send_mouse(report_mouse_t *report) // HID raw mode header xmit(0x9f); xmit(0x05); // Length - xmit(0xa1); // mouse report + xmit(0xa1); // DATA(Input) xmit(0x02); - xmit(report->buttons); + /* vertical wheel support */ + int8_t wheel = report->v; + if (wheel < -15) { + wheel = -15; + } else if (wheel > 15) { + wheel = 15; + } + xmit(((wheel&0x1f)<<3) | (report->buttons&0x07)); xmit(report->x); xmit(report->y); MUX_FOOTER(0x01); @@ -457,7 +464,7 @@ static void send_consumer(uint16_t data) MUX_HEADER(0x01, 0x07); xmit(0x9f); xmit(0x05); // Length - xmit(0xa1); // consumer report + xmit(0xa1); // DATA(Input) xmit(0x03); xmit(bits1); xmit(bits2); diff --git a/protocol/iwrap/keyboard.desc b/protocol/iwrap/keyboard.desc new file mode 100644 index 00000000..d9e7a4c5 --- /dev/null +++ b/protocol/iwrap/keyboard.desc @@ -0,0 +1 @@ +05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c0 diff --git a/protocol/iwrap/main.c b/protocol/iwrap/main.c index ac83280f..3abdce8d 100644 --- a/protocol/iwrap/main.c +++ b/protocol/iwrap/main.c @@ -25,6 +25,7 @@ along with this program. If not, see . #include "keyboard.h" #include "matrix.h" #include "host.h" +#include "action.h" #include "iwrap.h" #ifdef PROTOCOL_VUSB # include "vusb.h" @@ -40,7 +41,7 @@ along with this program. If not, see . static void sleep(uint8_t term); static bool console(void); -static uint8_t console_command(uint8_t c); +static bool console_command(uint8_t c); static uint8_t key2asc(uint8_t key); @@ -108,10 +109,13 @@ static void init_vusb(void) void change_driver(host_driver_t *driver) { + /* host_clear_keyboard_report(); host_swap_keyboard_report(); host_clear_keyboard_report(); host_send_keyboard_report(); + */ + clear_keyboard(); _delay_ms(1000); host_set_driver(driver); } @@ -168,6 +172,7 @@ int main(void) if (host_get_driver() == vusb_driver()) vusb_transfer_keyboard(); #endif + // TODO: depricated if (matrix_is_modified() || console()) { last_timer = timer_read(); sleeping = false; @@ -176,6 +181,7 @@ int main(void) iwrap_check_connection(); } + // TODO: suspend.h if (host_get_driver() == iwrap_driver()) { if (sleeping && !insomniac) { _delay_ms(1); // wait for UART to send @@ -201,11 +207,6 @@ static void sleep(uint8_t term) WD_SET(WD_OFF); } -ISR(WDT_vect) -{ - // wake up -} - static bool console(void) { // Send to Bluetoot module WT12 @@ -244,12 +245,12 @@ static bool console(void) } } -uint8_t command_extra() +bool command_extra(uint8_t code) { - return console_command(key2asc(host_get_first_key())); + return console_command(key2asc(code)); } -static uint8_t console_command(uint8_t c) +static bool console_command(uint8_t c) { switch (c) { case 'h': diff --git a/protocol/iwrap/mouse.desc b/protocol/iwrap/mouse.desc new file mode 100644 index 00000000..f2c43250 --- /dev/null +++ b/protocol/iwrap/mouse.desc @@ -0,0 +1 @@ +05010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0 diff --git a/protocol/vusb.mk b/protocol/vusb.mk index 77b1c633..3227ca7b 100644 --- a/protocol/vusb.mk +++ b/protocol/vusb.mk @@ -10,10 +10,10 @@ SRC += $(VUSB_DIR)/main.c \ ifdef NO_UART -SRC += sendchar_null.c +SRC += $(COMMON_DIR)/sendchar_null.c else -SRC += sendchar_uart.c \ - uart.c +SRC += $(COMMON_DIR)/sendchar_uart.c \ + $(COMMON_DIR)/uart.c endif From 90da1c59bd4e2d501bb0ccb670a90677f2f9c4e7 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 19 Apr 2013 08:38:05 +0900 Subject: [PATCH 2/3] Rescue script from iWRAP MUX mode stuck --- protocol/iwrap/mux_exit.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 protocol/iwrap/mux_exit.rb diff --git a/protocol/iwrap/mux_exit.rb b/protocol/iwrap/mux_exit.rb new file mode 100644 index 00000000..1f6be48a --- /dev/null +++ b/protocol/iwrap/mux_exit.rb @@ -0,0 +1,7 @@ +# +# Rescue from Bluegiga iWRAP MUX mode +# 6.75 of iWRAP5_User_Guid.pdf +# +[0xBF, 0xFF, 0x00, 0x11, 0x53, 0x45, 0x54, 0x20, 0x43, 0x4f, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x20, 0x4d, 0x55, 0x58, 0x20, 0x30, 0x00].each do |x| + print x.chr +end From 663027751831eb0e80d64c90aaf82d2921533aed Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 19 Apr 2013 23:43:52 +0900 Subject: [PATCH 3/3] Add support of mouse horizontal wheel to iWRAP --- protocol/iwrap/iWRAP5.txt | 139 ++++++++++++++++++++------------------ protocol/iwrap/iwrap.c | 21 +++--- protocol/iwrap/mouse.desc | 41 ++++++++++- 3 files changed, 121 insertions(+), 80 deletions(-) diff --git a/protocol/iwrap/iWRAP5.txt b/protocol/iwrap/iWRAP5.txt index e5ecc5c8..65bbe042 100644 --- a/protocol/iwrap/iWRAP5.txt +++ b/protocol/iwrap/iWRAP5.txt @@ -204,64 +204,73 @@ CALL 78:dd:08:b7:e4:a2 11 HID Setting ======== +Following settings need to be done before wiring into keyboard. +- UART speed: 38400bps(115200bps didn't work with software serial) +- No SSP procedure(without MITM protection) +- No Power Saving + +# clear pairing record and set default SET BT PAIR * SET RESET +SET CONTROL INIT SET CONTROL MUX 0 +SET CONTROL BAUD 38400,8n1 +SET BT NAME TMK Blootooth WT12 SET BT CLASS 0005c0 SET BT AUTH * 0000 -SET BT SSP 2 0 -SET CONTROL CONFIG 800 -SET PROFILE HID 0f c0 0100 00 en 0409 Bluetooth keyboard +SET BT SSP 3 0 +SET CONTROL CONFIG 4800 +SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) SET PROFILE SPP -SET CONTROL INIT SET CONTROL MUX 0 -SET BT NAME TMK Blootooth WT12 -SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) -SDP ADD 1124 HID -SET BT PAIRCOUNT 4 -SET BT POWER 3 3 3 +# power saving? SET BT SNIFF 100 20 1 8 -RESET - -SET CONTROL BAUD 38400,8n1 - -# combo keyboard + mouse -HID SET 7f 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0 - -HID SET d1 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 ---------------------- +# Report Descriptor +# combo keyboard + mouse + consumer +HID SET d2 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012908150025017501950881020501093009311581257f750895028106093895018106050c0a380295018106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 + + + + + + +---------- +after setting +---------- +set SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME TMK BT WT12 +SET BT NAME TMK Blootooth WT12 SET BT CLASS 0005c0 SET BT AUTH * 0000 SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP SET BT LAP 9e8b33 SET BT PAGEMODE 4 2000 1 -SET BT PAIRCOUNT 4 -SET BT PAIR 78:dd:08:b7:e4:a2 fe2fd79e86c6bbfa9351a032bceb2648 +SET BT PAIR 78:dd:08:b7:e4:a2 9e3d85c91bcae73fef8cc10bec18b42f SET BT POWER 3 3 3 -SET BT ROLE 1 f 12c0 -SET BT SNIFF 100 20 1 8 +SET BT ROLE 0 f 7d00 +SET BT SNIFF 0 20 1 8 SET BT SSP 3 0 -SET BT MTU 672 +SET BT MTU 667 SET CONTROL BAUD 38400,8n1 SET CONTROL CD 00 0 SET CONTROL ECHO 7 -SET CONTROL ESCAPE - 20 1 +SET CONTROL ESCAPE 43 00 1 SET CONTROL GAIN 0 5 SET CONTROL INIT SET CONTROL MUX 0 SET CONTROL MSC DTE 00 00 00 00 00 00 +SET CONTROL MUX 1 SET CONTROL PIO 00 00 SET CONTROL READY 00 -SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard +SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) SET -SET control config list -SET CONTROL CONFIG 0000 0000 0000 410e CLOCK_CACHE INTERLACED_INQ INTERLACED_PAGE KLUDGE UART_LATENCY - + +set control config list +SET CONTROL CONFIG 0000 0000 0000 4900 KLUDGE INTERACTIVE_PIN UART_LATENCY +info config WRAP THOR AI (5.0.1 build 620) Copyright (c) 2003-2012 Bluegiga Technologies Inc. Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 @@ -269,42 +278,59 @@ Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) - Bluetooth version 3.0, Power class 2 - Loader 8615, firmware 8825 (56-bit encryption), native execution mode - - up 0 days, 00:13, 0 connections (pool 1) + - up 0 days, 01:50, 2 connections (pool 2) - User configuration: -&028b = 0000 1388 -&028c = 0001 0020 0100 0001 0008 0000 -&028d = 0000 +&028d = 0001 &0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 -&0298 = c006 +&0298 = c053 &0299 = 0000 0000 &02a3 = 0030 0030 0030 0030 &02a4 = 009d 0000 &02a5 = 0053 0045 0054 0020 0043 004f 004e 0054 0052 004f 004c 0020 004d 0055 0058 0020 0030 &02a7 = 0000 05c0 -&02a8 = 400e 0000 0000 +&02a8 = 0800 0000 0000 0000 &02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 -&02ab = 0001 000f 12c0 -&02ac = 0000 0020 002b 0000 0000 0000 0000 0000 0000 0000 000a 0000 0000 0000 0004 0000 0000 0000 0000 02a0 0000 0000 0000 0000 -&02ad = 4d54 204b 5442 5720 3154 0032 +&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 +&02ad = 4d54 204b 6c42 6f6f 6f74 746f 2068 5457 3231 &02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 -&02b3 = 0004 0004 0004 0000 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 000d 0007 0005 8afb 0005 0000 1c13 0000 0c3d 0005 b435 0006 b450 0006 0000 1416 000d -&02b7 = 000f 00c0 0100 0000 0065 006e 0409 4d54 204b 6c42 6575 6f74 746f 2068 656b 6279 616f 6472 0000 ---------------------- +&02b3 = 0004 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0005 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 +&02b7 = 000f 00c0 0100 0000 0065 006e 0409 4d54 204b 6c42 6575 6f74 746f &02bb = 8000 +READY. +---------- ----------- -after SET RESET ----------- + +----- +After 5.0.1 Firmware update +Firmware: ai-5.0.1-620-25b.bc4.dfu +PSR: wt12-a.ai-5.0.1-620-25b.psrf +----- +info config WRAP THOR AI (5.0.1 build 620) Copyright (c) 2003-2012 Bluegiga Technologies Inc. +Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 + BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME + - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) + - Bluetooth version 3.0, Power class 2 + - Loader 8615, firmware 8825 (56-bit encryption), native execution mode + - up 0 days, 00:03, 0 connections (pool 1) + - User configuration: +&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 +&0299 = 0000 0000 +&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 +&02ad = 5457 3231 412d +&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 READY. + set SET BT BDADDR 00:07:80:47:22:14 -SET BT NAME WT12 +SET BT NAME WT12-A SET BT CLASS 001f00 SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP SET BT LAP 9e8b33 SET BT PAGEMODE 4 2000 1 +SET BT PAIR 78:dd:08:b7:e4:a2 af18f81faa107e6dd068762ef921f48b SET BT POWER 3 3 3 SET BT ROLE 0 f 7d00 SET BT SNIFF 0 20 1 8 @@ -321,25 +347,6 @@ SET CONTROL READY 00 SET PROFILE SPP Bluetooth Serial Port SET - +set control config list SET CONTROL CONFIG 0000 0000 0000 0100 KLUDGE - - -info config -WRAP THOR AI (5.0.1 build 620) -Copyright (c) 2003-2012 Bluegiga Technologies Inc. -Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 - BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME - - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) - - Bluetooth version 3.0, Power class 2 - - Loader 8615, firmware 8825 (56-bit encryption), native execution mode - - up 0 days, 00:00, 0 connections (pool 1) - - User configuration: -&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 -&0299 = 0000 0000 -&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 -&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 -&02ad = 5457 3231 -&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 -READY. ----------- +--------- diff --git a/protocol/iwrap/iwrap.c b/protocol/iwrap/iwrap.c index d65d9e38..6a404116 100644 --- a/protocol/iwrap/iwrap.c +++ b/protocol/iwrap/iwrap.c @@ -335,7 +335,7 @@ static void send_keyboard(report_keyboard_t *report) xmit(0x9f); xmit(0x0a); // Length xmit(0xa1); // DATA(Input) - xmit(0x01); + xmit(0x01); // Report ID xmit(report->mods); xmit(0x00); // reserved byte(always 0) xmit(report->keys[0]); @@ -351,22 +351,17 @@ static void send_mouse(report_mouse_t *report) { #if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE) if (!iwrap_connected() && !iwrap_check_connection()) return; - MUX_HEADER(0x01, 0x07); + MUX_HEADER(0x01, 0x09); // HID raw mode header xmit(0x9f); - xmit(0x05); // Length + xmit(0x07); // Length xmit(0xa1); // DATA(Input) - xmit(0x02); - /* vertical wheel support */ - int8_t wheel = report->v; - if (wheel < -15) { - wheel = -15; - } else if (wheel > 15) { - wheel = 15; - } - xmit(((wheel&0x1f)<<3) | (report->buttons&0x07)); + xmit(0x02); // Report ID + xmit(report->buttons); xmit(report->x); xmit(report->y); + xmit(report->v); + xmit(report->h); MUX_FOOTER(0x01); #endif } @@ -465,7 +460,7 @@ static void send_consumer(uint16_t data) xmit(0x9f); xmit(0x05); // Length xmit(0xa1); // DATA(Input) - xmit(0x03); + xmit(0x03); // Report ID xmit(bits1); xmit(bits2); xmit(bits3); diff --git a/protocol/iwrap/mouse.desc b/protocol/iwrap/mouse.desc index f2c43250..11898f2b 100644 --- a/protocol/iwrap/mouse.desc +++ b/protocol/iwrap/mouse.desc @@ -1 +1,40 @@ -05010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0 +05010902a1010901a1008502050919012908150025017501950881020501093009311581257f750895028106093895018106050c0a380295018106c0c0 + +Length: 67(0x43) +virtical/horizontal wheel support + + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x02, // USAGE (Mouse) + 0xa1, 0x01, // COLLECTION (Application) + 0x09, 0x01, // USAGE (Pointer) + 0xa1, 0x00, // COLLECTION (Physical) + 0x85, 0x02, // REPORT_ID (2) + // ---------------------------- Buttons + 0x05, 0x09, // USAGE_PAGE (Button) + 0x19, 0x01, // USAGE_MINIMUM (Button 1) + 0x29, 0x08, // USAGE_MAXIMUM (Button 8) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x08, // REPORT_COUNT (8) + 0x81, 0x02, // INPUT (Data,Var,Abs) + // ---------------------------- X,Y position + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x30, // USAGE (X) + 0x09, 0x31, // USAGE (Y) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x02, // REPORT_COUNT (2) + 0x81, 0x06, // INPUT (Data,Var,Rel) + // ---------------------------- Vertical wheel + 0x09, 0x38, // USAGE (Wheel) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x06, // INPUT (Data,Var,Rel) + // ---------------------------- Horizontal wheel + 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) + 0x0a, 0x38, 0x02, // USAGE (AC Pan) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x06, // INPUT (Data,Var,Rel) + 0xc0, // END_COLLECTION + 0xc0, // END_COLLECTION