<?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>ble_event and ble_event_handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9708/ble_event-and-ble_event_handler</link><description>I&amp;#39;m new to Bluetooth LE, Python and C. I have the S130 python examples for heart rate testing. I am attempting to modify the heart rate collector code to act as our central device which can read and write data to a TI based peripheral. 
 The example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Oct 2015 07:11:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9708/ble_event-and-ble_event_handler" /><item><title>RE: ble_event and ble_event_handler</title><link>https://devzone.nordicsemi.com/thread/35919?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2015 07:11:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9b67d2e-f39b-4c12-af1e-3def46c2a2cc</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;No problem :) Maybe you could accept my answer by clicking the grey circle next to it? I&amp;#39;m not too familiar with Python myself, but if you have a specific question you can add it here. Maybe someone can answer :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_event and ble_event_handler</title><link>https://devzone.nordicsemi.com/thread/35918?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 15:46:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ac7411c-fd8d-4d73-93b5-c8e06d6561b3</guid><dc:creator>Owlman</dc:creator><description>&lt;p&gt;Thanks for clearing up  many things. I interpreted the ble_event.header.evt_id being called once because in the python def main code it was called once, but as you stated the event triggers every time a BLE event occurs. I think what is still confusing is in Python. Procedurally speaking if there is no visible way to pass an event to ble_event parameter in the def ble_evt_handler it should always be none based on appearance in how the code is laid out.&lt;/p&gt;
&lt;p&gt;Actually def log_message_handler is the same way. It has two parameters in the function but when called there aren&amp;#39;t any. Again I don&amp;#39;t know the particular quirks of python to understand why this is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_event and ble_event_handler</title><link>https://devzone.nordicsemi.com/thread/35917?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 12:06:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6296bfd-24d5-4598-8187-404836b93d2d</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;If you are using the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_softdevice_handler.html?cp=4_1_0_3_20"&gt;SoftDevice handler library&lt;/a&gt; you set the BLE event handler with softdevice_ble_evt_handler_set().&lt;/p&gt;
&lt;p&gt;The SoftDevice uses software interrupt 2 (SWI2_IRQHandler) to tell the application that an event is ready to be pulled. In this interrupt routine intern_softdevice_events_execute() is called which pulls the events from the SoftDevice and calls the previously set BLE event handler.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Also how does the
ble_event.header.evt_id ever become
something other than CONNECT when its
only called once?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&amp;#39;m not sure why you would think it is only called once. It is called every time the SoftDevice has a BLE event for the application.&lt;/p&gt;
&lt;p&gt;For example if you do a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v1.0.0/group___b_l_e___g_a_t_t_c___v_a_l_u_e___r_e_a_d___m_s_c.html?cp=2_7_2_1_0_2_2_0_5"&gt;GATTC Characteristic or Descriptor Value Read&lt;/a&gt; by calling sd_ble_gattc_read() the application will get the BLE_GATTC_EVT_READ_RSP event.&lt;/p&gt;
&lt;p&gt;When you get this event the ble_gattc_evt_read_rsp_t struct will contain information about the read operation:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */
typedef struct
{
  uint16_t            handle;         /**&amp;lt; Attribute Handle. */
  uint16_t            offset;         /**&amp;lt; Offset of the attribute data. */
  uint16_t            len;            /**&amp;lt; Attribute data length. */
  uint8_t             data[1];        /**&amp;lt; Attribute data, variable length. */
} ble_gattc_evt_read_rsp_t;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You don&amp;#39;t need to handle events that never will occur, events that don&amp;#39;t contain information you need, or events that don&amp;#39;t need a respons.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>