<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>HID keyboard example - What does the buffer do and why it needs to be dequeued?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5480/hid-keyboard-example---what-does-the-buffer-do-and-why-it-needs-to-be-dequeued</link><description>Hi, this question could be ridiculous question due to my lack of data structure knowledge. 
 As you see in the HID keyboard example (SDK 7.2), there are several buffers. 
 typedef struct hid_key_buffer
{
 uint8_t data_offset; /**&amp;lt; Max Data that can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Feb 2015 00:27:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5480/hid-keyboard-example---what-does-the-buffer-do-and-why-it-needs-to-be-dequeued" /><item><title>RE: HID keyboard example - What does the buffer do and why it needs to be dequeued?</title><link>https://devzone.nordicsemi.com/thread/19125?ContentTypeID=1</link><pubDate>Thu, 12 Feb 2015 00:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a3d72df-2365-47d3-a308-6db13e3b987e</guid><dc:creator>MANGO</dc:creator><description>&lt;p&gt;Hmm... Acutally, it does behave strange after I disconnect the device. I was facing that issue quite long. Anyway thanks for your detailed answer. I&amp;#39;ll write the issue later or so.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID keyboard example - What does the buffer do and why it needs to be dequeued?</title><link>https://devzone.nordicsemi.com/thread/19124?ContentTypeID=1</link><pubDate>Wed, 11 Feb 2015 15:29:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a6d75fb-329f-44b8-9df6-3782b985fb38</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;If you try to send another char, it will then still send &amp;#39;0x0b&amp;#39; instead of your intended char, as it has not been de-queued from the buffer. It will still work in the sense that the program runs, but it would not behave as it should :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID keyboard example - What does the buffer do and why it needs to be dequeued?</title><link>https://devzone.nordicsemi.com/thread/19123?ContentTypeID=1</link><pubDate>Tue, 10 Feb 2015 14:38:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df3635b9-ba47-4068-8f67-6afe40ae7f77</guid><dc:creator>MANGO</dc:creator><description>&lt;p&gt;Pardon me Håkon.&lt;/p&gt;
&lt;p&gt;In short I changed the code like this.&lt;/p&gt;
&lt;p&gt;At button_event_handler, when I press a button,&lt;/p&gt;
&lt;p&gt;I send one key. (For example, I send only &amp;#39;h&amp;#39; at each press.)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t my_key = 0x0b;

keys_send(1,&amp;amp; my_key);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After that I send 0 mask at BLE_EVT_TX_COMPLETE event and I did not call buffer_dequeue.&lt;/p&gt;
&lt;p&gt;The code worked. Is this okay?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID keyboard example - What does the buffer do and why it needs to be dequeued?</title><link>https://devzone.nordicsemi.com/thread/19122?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2015 15:57:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32771e28-c3b3-4ade-97f4-5776c9331fbd</guid><dc:creator>MANGO</dc:creator><description>&lt;p&gt;Thanks for the Desktop 2 solution. I&amp;#39;m afraid I understanded some parts incorrectly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Does the original HID keyboard example sends &amp;quot;hello&amp;quot; all at once when I press a button?
In my case, I receive one character per press. (h -&amp;gt; e -&amp;gt; l -&amp;gt; l -&amp;gt; o -&amp;gt; h -&amp;gt; e -&amp;gt; ...)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You mean the dequeue function&amp;#39;s purpose is not to dequeue the buffers after buffer_enqueue was called? Does the dequeue function always has to be called at BLE_EVT_TX_COMPLETE regardless of buffer_enqueue was called or not?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sorry to add more questions. I just want to implement a simple keyboard sending one key per button click.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID keyboard example - What does the buffer do and why it needs to be dequeued?</title><link>https://devzone.nordicsemi.com/thread/19121?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2015 14:19:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b1d83cb-16b4-4f79-9ba1-97e99015c8c3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Mango,&lt;/p&gt;
&lt;p&gt;This is not a ridiculous question.&lt;/p&gt;
&lt;p&gt;The buffer functionality an complex solution to obtain something simple; loop through the string &amp;quot;hello&amp;quot; in a HID appropriate format.
I have a reply to an older case here where I have explained a bit about this:
&lt;a href="https://devzone.nordicsemi.com/question/19287/how-are-keyboard-key-release-events-sent-in-example-code/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you do not dequeue in BLE_EVT_TX_COMPLETE (or BLE_GAP_EVT_DISCONNECT) you will go into the scenario where you do not flush your buffer. The next time you send a key, you will then be stuck at the first element, which is &amp;#39;h&amp;#39;, until you fill up your queue and the application stops working properly.&lt;/p&gt;
&lt;p&gt;If you are looking for a solution to base your keyboard matrix upon, I would recommend looking at our nRFready Desktop 2 solution.&lt;/p&gt;
&lt;p&gt;Cheers,
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>