<?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>How to define event and event handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9089/how-to-define-event-and-event-handler</link><description>when I use softDevice S110, there exists ble_evt_dispatch function, Can I define event ? if I can, how to define event and how to use event handler . Thank you !</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Sep 2015 08:51:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9089/how-to-define-event-and-event-handler" /><item><title>RE: How to define event and event handler</title><link>https://devzone.nordicsemi.com/thread/33457?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 08:51:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:deb42e19-fd3a-4bfc-aa24-52c3db7cee72</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Is there a question here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to define event and event handler</title><link>https://devzone.nordicsemi.com/thread/33455?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 08:51:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75df0a0a-2398-4a3c-a8dc-b8be6fa91b4d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Try to search for &lt;code&gt;softdevice_ble_evt_handler_set();&lt;/code&gt;. This is the function used in SDK 9 to register the &lt;code&gt;ble_evt_dispatch()&lt;/code&gt; event handler.&lt;/p&gt;
&lt;p&gt;What do you mean exactly by &amp;quot;&lt;em&gt;and the write characteristic operate will generate what events&amp;quot;&lt;/em&gt;? When you perform a write operation the GATT event &amp;quot;&lt;em&gt;BLE_GATTS_EVT_WRITE&lt;/em&gt;&amp;quot; will be passed to &lt;code&gt;ble_evt_dispatch()&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to define event and event handler</title><link>https://devzone.nordicsemi.com/thread/33456?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 08:01:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5307aee-b3b2-4538-ba64-5bb055b1d3f1</guid><dc:creator>fanqh</dc:creator><description>&lt;pre&gt;&lt;code&gt;static uint32_t jawbone_char_TriggerEventHistoryReset_add(ble_jawbone_t * p_jawbone, const ble_jawbone_init_t * p_jawbone_init)
{
    uint32_t            err_code;
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
		ble_srv_cccd_security_mode_t  char_attr_security_mode_md;

    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&amp;amp;char_attr_security_mode_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;char_attr_security_mode_md.write_perm);
	

    memset(&amp;amp;char_md, 0, sizeof(char_md));
    char_md.char_props.read   = 0;
		char_md.char_props.write   = 1;
    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;

    BLE_UUID_BLE_ASSIGN(ble_uuid, UUID_TRIGGER_EVENT_HISTORY_RESET_CHAR);

    memset(&amp;amp;attr_md, 0, sizeof(attr_md));

    attr_md.read_perm  = char_attr_security_mode_md.read_perm;
    attr_md.write_perm = char_attr_security_mode_md.cccd_write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

    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  = TRIGGER_EVENT_DATA_LEN;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = TRIGGER_EVENT_DATA_LEN;
   attr_char_value.p_value = &amp;quot;abcde&amp;quot;; 
    err_code = sd_ble_gatts_characteristic_add(p_jawbone-&amp;gt;service_handle, &amp;amp;char_md,
                                               &amp;amp;attr_char_value,
                                               &amp;amp;p_jawbone-&amp;gt;TriggerEventHistoryReset_handle);	
		if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
		return NRF_SUCCESS;
}	
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to define event and event handler</title><link>https://devzone.nordicsemi.com/thread/33454?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 07:59:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1eeb8e8-cfa4-4356-a109-1ac22b3377ac</guid><dc:creator>fanqh</dc:creator><description>&lt;p&gt;first sorry for my english , i can not find sofedevice_handler_set message,  and the write charactristic operate will gernerate what events?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to define event and event handler</title><link>https://devzone.nordicsemi.com/thread/33453?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 07:39:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fffcc03-fe8f-47db-a180-6c02e759c773</guid><dc:creator>shibshab</dc:creator><description>&lt;p&gt;The events come from the S110, and you can not define these events yourself.&lt;/p&gt;
&lt;p&gt;To handle these event, set the handler function by calling &lt;code&gt;softdevice_handler_set&lt;/code&gt; if you are using the softdevice handler from the SDK. If you are not using the softdevice handler from the SDK you can handle these events by calling &lt;code&gt;sd_ble_evt_get&lt;/code&gt; directly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>