<?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>Can&amp;#39;t receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80034/can-t-receive-bytes-sent-via-bytearray-in-nrfconnect-app</link><description>I created a custom BLE service following this tutorial and I am able to connect to the BLE service and write data to it, but ideally, I want to send character bytes as opposed to just decimal values. 
 In the nRFConnect app, seemingly ByteArray is a field</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Oct 2021 07:33:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80034/can-t-receive-bytes-sent-via-bytearray-in-nrfconnect-app" /><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/332246?ContentTypeID=1</link><pubDate>Mon, 04 Oct 2021 07:33:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aacdece9-a2e0-4c65-951e-b26e6baff055</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The &lt;code&gt;max_len&lt;/code&gt; field indicates the &lt;em&gt;&lt;span style="text-decoration:underline;"&gt;maximum&lt;/span&gt; &lt;/em&gt;length, so it is up to. You can always write a smaller value, the point is that it cannot be larger than the specified maximum.&lt;/p&gt;
&lt;p&gt;(I see now that my statement &amp;quot;&lt;em&gt;The max_len here dictates the maximum length of the value, neither more or less&lt;/em&gt;&amp;quot; can be confusing. The point was that &lt;code&gt;max_len&lt;/code&gt; does not do anything other than limiting the maximum length. So, it does not say anything about number of writes before you get an interrupt or similar as you asked about before I answered that).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/332218?ContentTypeID=1</link><pubDate>Sat, 02 Oct 2021 06:05:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:530fbf61-34c1-4462-b766-31d66622e2f3</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;is it UP TO or&amp;nbsp;neither more nor less which you indicated earlier? Unless I&amp;#39;m misinterpreting&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/332082?ContentTypeID=1</link><pubDate>Fri, 01 Oct 2021 08:59:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be34dddc-7f56-4192-b86c-2ba420fd69c5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;This looks OK for writing up to 5 bytes. Does it not work if you use ByteArray with hex or UTF8 with characters?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/332021?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 20:46:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:992e27e0-8699-450c-a371-5ede74fd48ae</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint32_t custom_value_char_add(BleCust * p_cus, const BleCustInit_t * p_cus_init)
{
    uint32_t            err_code;
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_md_t cccd_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

    memset(&amp;amp;char_md, 0, sizeof(char_md));

    char_md.char_props.read   = 1;
    char_md.char_props.write  = 1;
    char_md.char_props.notify = 0; 
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = NULL; 
    char_md.p_sccd_md         = NULL;
		
    memset(&amp;amp;attr_md, 0, sizeof(attr_md));

    attr_md.read_perm  = p_cus_init-&amp;gt;customCharAttr.read_perm;
    attr_md.write_perm = p_cus_init-&amp;gt;customCharAttr.write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

    ble_uuid.type = p_cus-&amp;gt;uuidType;
    ble_uuid.uuid = CUSTOM_VALUE_CHAR_UUID;

    memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid    = &amp;amp;ble_uuid;
    attr_char_value.p_attr_md = &amp;amp;attr_md;
    attr_char_value.init_len  = sizeof(uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof(uint8_t) * 5;

    err_code = sd_ble_gatts_characteristic_add(p_cus-&amp;gt;serviceHandle, &amp;amp;char_md,
                                               &amp;amp;attr_char_value,
                                               &amp;amp;p_cus-&amp;gt;customValueHandle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331840?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 07:28:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:894153d5-7d09-45b2-a812-a12590704742</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="morpho"]Okay, so I tried again and despite having max_len at sizeof(uint8_t) * 5, I can send/receive &amp;lt; 5 bytes. Do you see why would that be? (p_evt_write-&amp;gt;len &amp;lt; 5)[/quote]
&lt;p&gt;Can you share your code so that I can see?&lt;/p&gt;
[quote user="morpho"]Secondly, there&amp;#39;s no way for you to send string bytes?[/quote]
&lt;p&gt;When you have selected ByteArray, then yes. If you select UTF8, you can enter a string and it will be automatically converted to ASCII for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331812?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2021 03:13:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d6daef9-71c6-4a0d-b241-905d04498ca8</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;Okay, so I tried again and despite having max_len at sizeof(uint8_t) * 5, I can send/receive &amp;lt; 5 bytes. Do you see why would that be? (p_evt_write-&amp;gt;len &amp;lt; 5)&lt;/p&gt;
&lt;p&gt;Secondly, there&amp;#39;s no way for you to send string bytes? Would you have to consult to the ASCII table to make sure you&amp;#39;re sending the expected chars?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331674?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 10:51:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be5a5881-b3c0-4757-bb88-b1dcc13ba757</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="morpho"]I set the max_len to 5 * sizeof(uint8_t), which means I should only be able to send 5 bytes assuming uint8_t is a byte, yes?[/quote]
&lt;p&gt;Yes.&lt;/p&gt;
[quote user="morpho"]This video is with max_len&amp;nbsp;sizeof(uint8_t) * 50; (just randomly put in a number)[/quote]
&lt;p&gt;I do not see in the video which characteristic you try to write to. Is it the correct one? Also, with byte array you should use hex characters, so not for instance &amp;quot;Hello&amp;quot; as you use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331598?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 06:13:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b74afa2-9416-435c-ad92-8c8130b797e1</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;alright I am still not super clear on max_len and how it&amp;#39;s working as my experience with the app has been a bit different. I set the max_len to 5 * sizeof(uint8_t), which means I should only be able to send 5 bytes assuming uint8_t is a byte, yes? when I do so, the app doesn&amp;#39;t allow me to send.&lt;br /&gt;&lt;br /&gt;This video is with max_len&amp;nbsp;sizeof(uint8_t) * 50; (just randomly put in a number)&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/RPReplay_5F00_Final1632895423.MP4"&gt;devzone.nordicsemi.com/.../RPReplay_5F00_Final1632895423.MP4&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331477?ContentTypeID=1</link><pubDate>Tue, 28 Sep 2021 10:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb431511-5925-4e33-a492-3a5eb65f65fa</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The max_len here dictates the maximum length of the value, neither more or less. So it is not possible to send more than 1 byte at a time with this configuration. If you want to send data that is larger than 1 byte, you must increase the max_len.&lt;/p&gt;
&lt;p&gt;Regarding the Rx characteristic I cannot see much from this video. Is there an error on the nRF side? For instance detected by an APP_ERROR_CHECK()? Have you debugged to check?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331409?ContentTypeID=1</link><pubDate>Tue, 28 Sep 2021 05:00:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6eea5c1-0cbb-4329-a1d4-0f2baab4f435</guid><dc:creator>morpho</dc:creator><description>&lt;p&gt;max_len indicates the max number of bytes that could be sent before the application starts processing/interrupt is triggered then?&amp;nbsp; because currently, every byte I send, on_write is invoked through the ble event handler call.&lt;/p&gt;
&lt;p&gt;Also now the RX characteristics button doesn&amp;#39;t seem to recognize the tap to bring up the options for the data. do you see what&amp;#39;s happening now?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/RPReplay_5F00_Final1632804981.MP4"&gt;devzone.nordicsemi.com/.../RPReplay_5F00_Final1632804981.MP4&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't receive bytes sent via ByteArray in nRFConnect App</title><link>https://devzone.nordicsemi.com/thread/331386?ContentTypeID=1</link><pubDate>Mon, 27 Sep 2021 18:33:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad0f4de9-4e66-449d-bbb0-1f141222d990</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you say more about the characteristic you write to? What is the maximum length? I ask because referring to this snippet from the tutorial, the max length is set to sizeof(uint8_t), which is 1:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    /* This code belongs in custom_value_char_add() in ble_cus.c*/

    memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid    = &amp;amp;ble_uuid;
    attr_char_value.p_attr_md = &amp;amp;attr_md;
    attr_char_value.init_len  = sizeof(uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof(uint8_t);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you want to write more than one byte at a time, you must set a higher value for max_len.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>