This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Windows 8.1 repeated key event

I have an issue with my keyboard working with the windows suface (on windows 8.1). Occasionally, the last character sent is repeated several times instead of one. I do not have the same isue with the ipad (iOS 7.0.3). Therefore, I was thinking if may be any problem with the USB HID events. This is how I am sending and clearing each key stroke:

static uint8_t m_sample_key_release_pattern[8] =                /**< Key pattern to be sent to simulate releasing keys. */
{ 
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00
};

Sending the event an clearing code. The ASCII character goes on the 3rd byte of an 8 byte array (packet->keyboard_keys).

// Code
err_code = ble_hids_inp_rep_send(&s_hids,
            INPUT_REPORT_KEYS_INDEX,
            packet_size,
            (uint8_t*)packet->keyboard_keys);  
ASSERT(packet_size == 8);
ASSERT(packet->keyboard_keys != 0);
// ADD
if (err_code == NRF_SUCCESS)
{
   err_code = ble_hids_inp_rep_send(&s_hids,
            INPUT_REPORT_KEYS_INDEX,
            packet_size,
            m_sample_key_release_pattern);
}

Please let me know if you need more info.

Thanks for your help!

Parents
  • Thanks Ole.

    As you suggested I will try to keep track of the total packets sent. I have a couple of questions first. I am planning a variable that will keep track of the buffers availability. I will initialize this variable to the value return from sd_ble_tx_buffer_count_get function.

    Every time I sent a key, I put through 16 bytes (press+release). 1st question: what is the size of a buffer? Buffer size will help me to know how many buffers I am using every time I sent a key event and then decrease the precise number from total buffers available.

    Also, I will use the BLE_EVT_TX_COMPLETE event to increase the buffer once the packets have been sent. 2nd question: I would like to know when this event is called if it is every time a byte is sent or when a buffer is cleared.

    Basically I need to know how the softdevice buffers are managed.;)

Reply
  • Thanks Ole.

    As you suggested I will try to keep track of the total packets sent. I have a couple of questions first. I am planning a variable that will keep track of the buffers availability. I will initialize this variable to the value return from sd_ble_tx_buffer_count_get function.

    Every time I sent a key, I put through 16 bytes (press+release). 1st question: what is the size of a buffer? Buffer size will help me to know how many buffers I am using every time I sent a key event and then decrease the precise number from total buffers available.

    Also, I will use the BLE_EVT_TX_COMPLETE event to increase the buffer once the packets have been sent. 2nd question: I would like to know when this event is called if it is every time a byte is sent or when a buffer is cleared.

    Basically I need to know how the softdevice buffers are managed.;)

Children
  • The buffers in the softdevice is managed on packets, not data size. This means that you can queue a number of packets, no matter how big they are (but obviously limited by the MTU size of the link). Each time you call sd_ble_gatts_hvx() you therefore consume one buffer space. The BLE_EVT_TX_COMPLETE will be delivered for each connection event, i.e. each connection interval.

    There is some comments explaining the buffer behavior in ble_gatts.h, which may be useful. In addition, the document I linked to in my first answer should be useful.

Related