This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: BLE HID Mouse

Part Number: CC2640R2F
Other Parts Discussed in Thread: LAUNCHXL-CC2640R2,

Hi Teams,

I had built up HID MOUSE codes with changed MOUSE hiReportMap[], MOUSE GATT Service and Characteristics

After compiler and download completed the result as followings, 
   a. OK! can connect to iPhone SE with OS 14.4 
   b. OK! can send KEYBOARD character, on LEFT key pressed, by calling HidEmuKbd_sendReport()
   c. but FAILED! can NOT see MOUSE's cursor, on RIGHT key pressed, by calling HidEmuKbd_sendMouseReport()

Any suggest?

Notes: Working Tools Version based on followings,

(1) Hardware: LAUNCHXL_CC2640R2 Rev: 1.0

(2) CCS: V7.3.0

(3) SDK: V1.50.0.58

(4) XDCTOOLS: 3.50.3.33_core

(5) TI ARM Compiler: V16.9.4 LTS

(6) Project Folder: C:\ti\simplelink_cc2640r2_sdk_ble_example_pack_1_50_00_62\examples\rtos\CC2640R2_LAUNCHXL\bleapps\hid_emu_kbd


static CONST uint8 hidReportMap[] =
{
0x05, 0x01, // Usage Pg (Generic Desktop)
0x09, 0x06, // Usage (Keyboard)
0xA1, 0x01, // Collection: (Application)
0x85, 0x01, // REPORT_ID (1) // (24.02) added

//
0x05, 0x07, // Usage Pg (Key Codes)
0x19, 0xE0, // Usage Min (224)
0x29, 0xE7, // Usage Max (231)
0x15, 0x00, // Log Min (0)
0x25, 0x01, // Log Max (1)
//
// Modifier byte
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report Count (8)
0x81, 0x02, // Input: (Data, Variable, Absolute)
//
// Reserved byte
0x95, 0x01, // Report Count (1)
0x75, 0x08, // Report Size (8)
0x81, 0x01, // Input: (Constant)
//
// LED report
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x05, 0x08, // Usage Pg (LEDs)
0x19, 0x01, // Usage Min (1)
0x29, 0x05, // Usage Max (5)
0x91, 0x02, // Output: (Data, Variable, Absolute)
//
// LED report padding
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x91, 0x01, // Output: (Constant)
//
// Key arrays (6 bytes)
0x95, 0x06, // Report Count (6)
0x75, 0x08, // Report Size (8)
0x15, 0x00, // Log Min (0)
0x25, 0x65, // Log Max (101)
0x05, 0x07, // Usage Pg (Key Codes)
0x19, 0x00, // Usage Min (0)
0x29, 0x65, // Usage Max (101)
0x81, 0x00, // Input: (Data, Array)
//
0xC0, // End Collection


//* refer: e2e.ti.com/.../how-to-send-2byte-consumer-control-code-in-hidadvremote
//*************************************************
//* MOUSE
//* buf[0] := [b0] [b1] [b2] [b3 b4 b5 b6 b7] // BUTTON 1 2 3
//* buf[1] := [b0 b1 b2 b3 b4 b5 b6 b7] // X
//* buf[2] := [b0 b1 b2 b3 b4 b5 b6 b7] // Y
//* buf[3] := [b0 b1 b2 b3 b4 b5 b6 b7] // WHEEL
//* calling: buf[0..3] := {0x00, x, y, 0x00}
//*************************************************
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x85, 0x02, // Report Id (2)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x09, // Usage Page (Buttons)
0x19, 0x01, // Usage Minimum (01) - Button 1
0x29, 0x03, // Usage Maximum (03) - Button 3
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x03, // Report Count (3)
0x81, 0x02, // Input (Data, Variable, Absolute) - Button states
0x75, 0x05, // Report Size (5)
0x95, 0x01, // Report Count (1)
0x81, 0x01, // Input (Constant) - Padding or Reserved bits
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (3)
0x81, 0x06, // Input (Data, Variable, Relative) - X & Y coordinate
0xC0, // End Collection
0xC0 // End Collection
//===
};

Ragards,

Kevin

  • Kevin,

    Thank you for your inquiry. I notified a colleague and he will reply as soon as possible.

    Best regards,

    Rafael

  • Hi Kevin,

    Thank you for the provided information. Looking through your report map. It looks good at first glance. However, I see that you have that you have not set a physical minimum and physical maximum for the mouse movement inputs. Can you add that section to the report map to see if a change is detected. Are you able to take a sniffer capture to see what is going on over the air? This will help is determine if the mouse notifications are being sent and what data is contained within. If you are able to to provided a non-encrypted sniffer log, then that would be very helpful in getting to the bottom of this.

    Best Regards,

    Jan

  • Hi Jan,

    1. I will try to add  physical minimum and physical maximum for the mouse movement inputs what you mentioned

    2.  I will try to take a sniffer capture to determine the notification are being sent and hopefully have a sniffer log to you

    3.  Please guide me what kind of TOOL as a  sniffer what you mentioned

         It's BTool? If so I need an another board of 'LAUNCHXL-CC2640R2 Rev:1.0' as SNIFFER right?  

    Regards,

    Kevin

  • Hi Kevin,

    There are several Bluetooth Analyzers on the market. Any of these should work fine (Ellisys, Frontline, etc.). You are able to make a simple packets sniffer by using a second CC2640R2 with the SmartRF Packet Sniffer 2 program. I recommend using one of the commercially available Bluetooth Analyzer as these provide a lot of information and are very powerful tools for BLE development. Can you verify if you are able to connect to a Windows PC and if the mouse movement can be seen on the PC?

    Best Regards,

    Jan

  • Hi Jan,

    1. I had checked by BTool(V1.41.21) and found HID Service and MOUSE characteristic

    2. by using SNIFFER (V2.18.1) 

       I logged some pressed on LEFT or RIGHT keys several times

    3. Please help double check what kind of reason caused malfunction on RIGHT key to move mouse X and Y,

        See attached file of 'snifferLog01.psd' for detail as following,

    snifferLog01.psd

    Regards,

    Kevin

  • Hi Kevin,

    Thank you for providing the logs. Could you specify in which moment in time you are sending the mouse movement notifications? Also, were you able to implement the physical max and min attributes? Was the provided log generated while the CC2640R2 was connected to a PC or was it connected to the iPhone?

    Best Regards,

    Jan

  • Hi Jan,

    My brief answers as followings,

    Q1: could you specify in which moment in time you are sending the mouse movement notifications?

    A1: when BLE_device connected to iPhone_SE

        by using SNIFFER tool based on PC Windows 10 platform

        I just press LEFT key first about 6 times

        then press RIGHT key about 6 times

    Q2: Also, were you able to implement the physical max and min attributes?

    A2: I do know where is the exact location and statements to implement it

        what you mention bout PHYSICAL attribute 

        so I do nothing here kindly show me how to implement it

    Q3: Was the provided log generated while the CC2640R2 was connected to a PC or was it connected to the iPhone?

    A3: The LAUNCHXL-CC2640R2 Rev1.0 EVM was connected to iPhone SE on OS 14.4

          and the CC2540USB_Dongle was plugged to PC with Windows 10

        by using software tool of SNIFFER(V2.18.1)  

    Regards,

    Kevin

  • Hi Kevin,

    With regards to 1, are you able to find in the logs the notifications being sent? If so, can you specify which packets are the ones sending the notifications in the provided logs? Do you have access to a dedicated packet sniffer? I would recommend taking logs with a dedicated packet sniffer that is able to capture notifications.

    With regards to 2, this modification would be made in the report map. I recommend using the following HID tool as a reference: https://www.usb.org/document-library/hid-descriptor-tool

    With regards to 3,

    Are you able to connect to a Windows PC and verify if the mouse movement works there?

    Best Regards,

    Jan

  • Hi Jan,

    I can see MOUSE cursor dot looks like a little grey circle on host iPhone SE now

    but this cursor dot could not be moved by x, y setting and cursor dot disappeared for several seconds

    Does mouse x, y moving values failed or other issue? 

    I wrote a simple codes sent by MOUSE moving with x and y values see followings,

    calling HidEmuKbd_sendMouseReport() on RIGHT key pressed based on LAUNCHXL-CC2640R2 board 

    static void HidEmuKbd_sendMouseReport(uint8_t buttons)
    {
       static int8_t JBL_I8 = 0; // try -100 to 100 by step 2
       int8_t buf[HID_MOUSE_IN_RPT_LEN]; // 4

       //* test by RAMP method here
       buf[0] = 0x00; // button

       buf[1] = JBL_I8; // X
       buf[2] = JBL_I8; // Y
       buf[3] = 0x00; // Wheel

       //* calling:  HidDev_Report (2, 1, 4, buf)

       HidDev_Report(HID_RPT_ID_MOUSE_IN, HID_REPORT_TYPE_INPUT, HID_MOUSE_IN_RPT_LEN, buf);

       //* test by RAMP method; set JBL_U8 := -100..100 by step 2 looping
       JBL_I8 += 2; 
       if(JBL_I8 >= 100){
          JBL_I8 = -100;
       }

    }

    Any suggest on MOUSE cursor moving?

    Regards,

    Kevin

     

  • Hi Kevin,

    As a quick test can you set the value of Y to 0 and the value of X to 2. This should move the mouse steadily across the screen. Can you clarify what change you performed to be able to see the cursor show up on the iPhone SE? I also suggest getting a BLE Traffic log using a commercial Bluetooth traffic analyzer. These logs will help greatly in future development. Are you able to connect to a Windows PC and see any mouse movement?

    Best Regards,

    Jan

  • Hi Jan,

    1. It does not work when the mouse moving value changed as  X=2 and Y=0 

    2. I try to migrate from  BLE CC254X V1.4.0 codes (had MOUSE function) to BLECC2640R2F codes carefully 

        The main statements modified based on two important files as followings, 

        "C:\ti\BLE-CC254x-1.4.0-master\Projects\ble\HIDAdvRemote\Source\hidAdvRemote.c"

        "C:\ti\BLE-CC254x-1.4.0-master\Projects\ble\Profiles\HIDDevKbM\hidkbmservice.c"

       after step by step migration wanted codes and compiled and download it

       As a results: When BLE device connected to iPhone SE

                           the BLE device can work on KEYBOARD function but MOUSE function not working so far

       Any comments?

    3.  Could you show BLE HID MOUSE project example codes based on Bluetooth 5.0?

    Regards,

    Kevin 

  • Hi Kevin,

    Thank you for running the test. Are you able to acquire a Bluetooth traffic sniffer? I believe we need to get a BLE traffic log in order to continue debugging. The log you provided earlier is a Bluetooth packet log which does not contain all the traffic. Particularly, I want to see the notifications that are being sent from the BLE HID mouse program to the iPhone. A BLE traffic log would allow us to see exactly what is being sent over there air when the mouse movement notifications are being sent. It is possible that the notifications are not being prepared or parsed properly and a BLE traffic log would allow us to verify this. Would it be possible to acquire this log?

    Best Regards,

    Jan

  • Hi Jan,

    It's hard to get the BLE traffic log tool for debugging in recent time

    Now I try to migrate the HID Mouse codes from BLE4 stack to BLE5 statck based on CCS 9.0.1, SDK 3.10.0.15, Project_Zero and CC2640R2F

    Need few days to migrate and test it!

    Regards,

    Kevin

  • Hi Kevin,

    Got it. We look forward to hearing the results of your test. Let us know if there are any further questions once the tests are completed.

    Best Regards,

    Jan

  • Hi Jan,

    Now I try to compile the HID Mouse codes based on BLE5 stack as followings,

    (1) Working Enviroment:

    - CCS 10.4.0,

    - SDK 5.10.0.2

    - Project : C:\ti\simplelink_cc2640r2_sdk_5_10_00_02\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\project_zero

    - Board: LAUNCHXL-CC2640R2 

    (2) Result: got the MEMORY management issue after compilation, (some HID SEVICES be added in)

    It seems that some extra HID SEVICES had been added in to PROFILE folder, right?

    (3) Any suggest on HID Sevices added?

    Regards,

    Kevin

  • Hi Kevin,

    The BLE5 stack does consume a lot more memory than the BLE stack, so this is likely the reason that the device has ran out of space. I recommend looking through the profile list and removing the ones that are not needed for your usecase. This will help free up some memory. You may find the following threads useful:

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/707553/launchxl-cc2640r2-running-out-of-flash-space

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/728227/launchxl-cc2640r2-reduce-flash-size-on-ble5-simple_peripheral

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/632265/rtos-cc2640r2f-is-there-a-way-to-reduce-flash-size-used-by-ble-stack-and-ti-rtos

    Best Regards,

    Jan

  • Hi Jan,

    1. I comment out three services of button_service, data_service and led_service in project_zero.c

        then passed compilation it seems the momory consuming issue fixed

    2. Due to some other topics coming urgently

        My BLE HID MOUSE project is pending here although still had problems waiting to conquer 

        I would like to close this thread now!

    Regards,

    Kevin