<?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>No Write Events Generated</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67063/no-write-events-generated</link><description>I am currently following the tutorial for creating custom services ( https://github.com/NordicPlayground/nRF5x-custom-ble-service-tutorial ). The only differences to this example is that I am using SDK v17 and SoftDevice s140. 
 Everything has been going</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Oct 2020 14:15:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67063/no-write-events-generated" /><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274703?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 14:15:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50956836-d430-425f-b68d-d7ca69c29d44</guid><dc:creator>TB-DaveMoore</dc:creator><description>&lt;p&gt;You absolute hero. Thanks for that, it&amp;#39;s working perfectly now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274700?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 14:11:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a77829b7-a93a-4cf8-b477-b93928fe4eb9</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ah, ok. In services_init() in main.c, you set the:&lt;/p&gt;
&lt;p&gt;BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cus_init.custom_value_char_attr_md.write_perm);&lt;/p&gt;
&lt;p&gt;(and read perm, equally)&lt;/p&gt;
&lt;p&gt;before you memset cus_init to 0. So basically, that would be like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint8_t a = 14;
uint8_t b = 15;

a = 0;
b = 0;

uint8_t c = a + b;

NRF_LOG_INFO(&amp;quot;c = %d&amp;quot;, c);  //expect c = 29, but you have c = 0.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Try moving it at least after memset(&amp;amp;cus_init,0,sizeof(cus_init);&lt;/p&gt;
&lt;p&gt;but even maybe inside ble_cus_init(&amp;amp;m_cus, &amp;amp;cus_init);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is also a common mistake when you reach step 7 in your guide. Make sure that this snippet:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; /* This code belongs in services_init in main.c*/

    // Set the cus event handler
    cus_init.evt_handler                = on_cus_evt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;is set&amp;nbsp;&lt;strong&gt;after&amp;nbsp;&lt;/strong&gt;memset(&amp;amp;cus_init,0,sizeof(cus_init)); or you will experience&amp;nbsp;some weird behavior.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274639?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 12:33:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9e8931a-6c4f-4d2a-a8a5-419296bdd71d</guid><dc:creator>TB-DaveMoore</dc:creator><description>&lt;p&gt;Apologies, that&amp;#39;s the wrong project! The correct one is attached. I&amp;#39;m building on the example for PCA10056 using SES.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2021.ble_5F00_app_5F00_template.zip"&gt;devzone.nordicsemi.com/.../2021.ble_5F00_app_5F00_template.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274635?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 12:27:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f08be232-ecdb-4d7e-a1cd-271fa8eb5c07</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Does that contain the project folder that you are using? What IDE are you using? And I don&amp;#39;t see any references to your custom service in services_init(). Are you sure you sent the correct folder?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274625?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 12:17:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edffd053-2358-480a-a254-dec72db43fe0</guid><dc:creator>TB-DaveMoore</dc:creator><description>&lt;p&gt;Attached - thanks!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0020.custom_5F00_ble_5F00_service_5F00_example.zip"&gt;devzone.nordicsemi.com/.../0020.custom_5F00_ble_5F00_service_5F00_example.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274623?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 12:16:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:191a068e-87bb-4fbb-98ac-1f1baa200c3b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I have followed a similar guide before (not that exact one, but one written for a different SDK), and it worked in that case. Is there a way for me to reproduce this? Can you zip the project folder containing the main.c file, project file and your custom files and send them here?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274595?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 11:42:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27c4c8c4-968a-4f18-8f49-5a47f30f7d78</guid><dc:creator>TB-DaveMoore</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Yep, I get logs from the custom characteristics file.&lt;/p&gt;
&lt;p&gt;BLE_CUS_DEF is as follows&lt;/p&gt;
&lt;pre&gt;#define BLE_CUS_DEF(_name)                         \
 static ble_cus_t _name;                            \
 NRF_SDH_BLE_OBSERVER(_name ## _obs,                \
                      BLE_HRS_BLE_OBSERVER_PRIO,    \
                      ble_cus_on_ble_evt, &amp;amp;_name)&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;And the ble_cus.c event handler&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;void ble_cus_on_ble_evt( ble_evt_t const * p_ble_evt, void * p_context){

    ble_cus_t * p_cus = (ble_cus_t *) p_context;

    if(p_cus == NULL || p_ble_evt == NULL){
      return;
    }

    NRF_LOG_INFO(&amp;quot;EVT: %d&amp;quot;,p_ble_evt-&amp;gt;header.evt_id);

    switch(p_ble_evt-&amp;gt;header.evt_id)
    {
      case BLE_GAP_EVT_CONNECTED:{
        NRF_LOG_INFO(&amp;quot;GAP_EVT_CONNECTED&amp;quot;);
        on_connect(p_cus, p_ble_evt);
        break;
      }

      case BLE_GAP_EVT_DISCONNECTED:{
      NRF_LOG_INFO(&amp;quot;GAP_EVT_DISCONNECTED&amp;quot;);
      on_disconnect(p_cus, p_ble_evt);
      break;
      }
        

      case BLE_GATTS_EVT_WRITE:{
        NRF_LOG_INFO(&amp;quot;GATTS_EVT_WRITE&amp;quot;);
        on_write(p_cus, p_ble_evt);
        break;
      }
        

      default:
      NRF_LOG_INFO(&amp;quot;GAP_EVT_UNDEFINED&amp;quot;);
        break;
    }

}&lt;/pre&gt;
&lt;p&gt;Those logs are triggered when I connect or disconnect through nRF Connect and the write event log is triggered when I subscribe or unsubscribe to the characteristic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: No Write Events Generated</title><link>https://devzone.nordicsemi.com/thread/274587?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 11:30:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b9b9d40-37fc-43ca-91d6-35f74ec39b5d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Adding logs to the on_ble_evt handler shows that no event is generated on write, so it&amp;#39;s not a case of incorrectly handling the event id.[/quote]
&lt;p&gt;&amp;nbsp;Do you see any logs from your custom characteristics file? (ble_cus.c?) Try to add some logs in your init function, and see if they appear.&lt;/p&gt;
&lt;p&gt;If you see other logs, then it may be that your event handler is not called. What does your&amp;nbsp;&lt;span&gt;#&lt;/span&gt;&lt;span&gt;define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;BLE_CUS_DEF&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;_name&lt;/span&gt;&lt;span&gt;) implementation look like? Can you compare it to the ble_cus.h implementation from the github repository that you linked to?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;That is, &lt;a href="https://github.com/NordicPlayground/nRF5x-custom-ble-service-tutorial/blob/7e83fbfc571f153ca6d097ab6ccc2f1d73631dbf/ble_cus.h#L14-L19"&gt;this one&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This definition is what tells the softdevice where to forward the ble events. In the file that I linked, it will be forwarded to the&amp;nbsp;&lt;span&gt;ble_cus_on_ble_evt().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>