<?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>SDK15: Serialization example crashes</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33853/sdk15-serialization-example-crashes</link><description>I started today with the following examples to make a start with serialization: 
 - ..\examples\connectivity\ble_connectivity\pca10040\ser_s132_hci 
 - ..\examples\ble_peripheral\ble_app_hrs\pca10040\ser_s132_hci 
 
 Both projects are installed on a PCA10040</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 May 2018 11:16:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33853/sdk15-serialization-example-crashes" /><item><title>RE: SDK15: Serialization example crashes</title><link>https://devzone.nordicsemi.com/thread/130787?ContentTypeID=1</link><pubDate>Thu, 03 May 2018 11:16:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89e2dab1-0373-4e69-82d8-6915aefa86ea</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Erwin,&lt;/p&gt;
&lt;p&gt;Unfortunately, event handling for BLE_GAP_EVT_ADV_SET_TERMINATED&amp;nbsp;is not implemented in the connectivity&amp;nbsp;FW as you&amp;#39;ve noticed.&amp;nbsp;&amp;nbsp;This leads to a code&amp;nbsp;assertion once the&amp;nbsp;timeout occurs&amp;nbsp;instead of entering system OFF mode. I have reported this as a bug internally, will keep you posted.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 5/7 - 2018&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Looks like &lt;a href="https://devzone.nordicsemi.com/members/erwin-v.-h_2e00_"&gt;Erwin v. H.&lt;/a&gt; found the missing pieces, see reply here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/33106/bug-ble_gap_evt_adv_set_terminated-is-never-raised"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/33106/bug-ble_gap_evt_adv_set_terminated-is-never-raised&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Quickly tried it here, and it seems to fix the issue with not going to sleep. Here are the changes:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="diff"&gt;diff --git a/components/serialization/application/codecs/ble/serializers/ble_event.c b/components/serialization/application/codecs/ble/serializers/ble_event.c
index e32a905..e046072 100644
--- a/components/serialization/application/codecs/ble/serializers/ble_event.c
+++ b/components/serialization/application/codecs/ble/serializers/ble_event.c
@@ -295,6 +295,9 @@ uint32_t ble_event_dec(uint8_t const * const p_buf,
         case BLE_GAP_EVT_SCAN_REQ_REPORT:
             fp_event_decoder = ble_gap_evt_scan_req_report_dec;
             break;
+				
+				case BLE_GAP_EVT_ADV_SET_TERMINATED:
+						fp_event_decoder = ble_gap_evt_adv_set_terminated_dec;
         default:
             break;
     }
diff --git a/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h b/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h
index b36e70b..053b0ed 100644
--- a/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h
+++ b/components/serialization/application/codecs/ble/serializers/ble_gap_evt_app.h
@@ -536,6 +536,30 @@ uint32_t ble_gap_evt_data_length_update_dec(uint8_t const * const p_buf,
                                  uint32_t              packet_len,
                                  ble_evt_t * const     p_event,
                                  uint32_t * const      p_event_len);
+																 
+/**
+ * @brief Decodes ble_gap_evt_data_length_update event.
+ *
+ * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
+ *
+ * @param[in] p_buf            Pointer to the beginning of an event packet.
+ * @param[in] packet_len       Length (in bytes) of the event packet.
+ * @param[in,out] p_event      Pointer to a \ref ble_evt_t buffer where the decoded event will be
+ *                             stored. If NULL, required length will be returned in \p p_event_len.
+ * @param[in,out] p_event_len  \c in: Size (in bytes) of \p p_event buffer.
+ *                             \c out: Length of decoded contents of \p p_event.
+ *
+ * @retval NRF_SUCCESS               Decoding success.
+ * @retval NRF_ERROR_NULL            Decoding failure. NULL pointer supplied.
+ * @retval NRF_ERROR_INVALID_LENGTH  Decoding failure. Incorrect buffer length.
+ * @retval NRF_ERROR_DATA_SIZE       Decoding failure. Length of \p p_event is too small to
+ *                                   hold decoded event.
+ */
+																 
+uint32_t ble_gap_evt_adv_set_terminated_dec(uint8_t const * const p_buf,
+                                 uint32_t              packet_len,
+                                 ble_evt_t * const     p_event,
+                                 uint32_t * const      p_event_len);
 #endif
 /** @} */
 
diff --git a/components/serialization/connectivity/codecs/ble/serializers/ble_event_enc.c b/components/serialization/connectivity/codecs/ble/serializers/ble_event_enc.c
index ff075f1..5111e8b 100644
--- a/components/serialization/connectivity/codecs/ble/serializers/ble_event_enc.c
+++ b/components/serialization/connectivity/codecs/ble/serializers/ble_event_enc.c
@@ -284,6 +284,10 @@ uint32_t ble_event_enc(ble_evt_t const * const p_event,
         case BLE_GAP_EVT_SCAN_REQ_REPORT:
             ret_val = ble_gap_evt_scan_req_report_enc(p_event, event_len, p_buf, p_buf_len);
             break;
+				
+				case BLE_GAP_EVT_ADV_SET_TERMINATED:
+						ret_val = ble_gap_evt_adv_set_terminated_enc(p_event, event_len, p_buf, p_buf_len);
+						break;
 
         default:
             ret_val    = NRF_ERROR_NOT_SUPPORTED;
diff --git a/components/serialization/connectivity/codecs/ble/serializers/ble_gap_evt_conn.h b/components/serialization/connectivity/codecs/ble/serializers/ble_gap_evt_conn.h
index 889d0b6..c7bc2f0 100644
--- a/components/serialization/connectivity/codecs/ble/serializers/ble_gap_evt_conn.h
+++ b/components/serialization/connectivity/codecs/ble/serializers/ble_gap_evt_conn.h
@@ -433,6 +433,26 @@ uint32_t ble_gap_evt_data_length_update_enc(ble_evt_t const * const p_event,
                                  uint32_t                event_len,
                                  uint8_t * const         p_buf,
                                  uint32_t * const        p_buf_len);
+																 
+
+
+/**
+ * @brief Encodes ble_gap_evt_adv_set_terminated event.
+ *
+ * @param[in] p_event          Pointer to the \ref ble_evt_t buffer that shall be encoded.
+ * @param[in] event_len        Size (in bytes) of \p p_event buffer.
+ * @param[out] p_buf           Pointer to the beginning of a buffer for encoded event packet.
+ * @param[in,out] p_buf_len    \c in: Size (in bytes) of \p p_buf buffer.
+ *                             \c out: Length of encoded contents in \p p_buf.
+ *
+ * @retval NRF_SUCCESS               Encoding success.
+ * @retval NRF_ERROR_NULL            Encoding failure. NULL pointer supplied.
+ * @retval NRF_ERROR_INVALID_LENGTH  Encoding failure. Incorrect buffer length.
+ */																 
+uint32_t ble_gap_evt_adv_set_terminated_enc(ble_evt_t const * const p_event,
+                                 uint32_t                event_len,
+                                 uint8_t * const         p_buf,
+                                 uint32_t * const        p_buf_len);
 #endif
 /** @} */
 
diff --git a/components/serialization/connectivity/codecs/common/conn_mw_nrf_soc.c b/components/serialization/connectivity/codecs/common/conn_mw_nrf_soc.c
index 62d034e..a03e536 100644
--- a/components/serialization/connectivity/codecs/common/conn_mw_nrf_soc.c
+++ b/components/serialization/connectivity/codecs/common/conn_mw_nrf_soc.c
@@ -57,6 +57,7 @@ uint32_t conn_mw_power_system_off(uint8_t const * const p_rx_buf,
 
     err_code = sd_power_system_off();
     /* There should be no return from sd_power_system_off() */
+		while(1);
 
     return err_code;
 }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that the program will return from&amp;nbsp;sd_power_system_off() if the chip is in debug interface mode which leads to a code assert, see &amp;quot;emulated system off&amp;quot;:&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=2_1_0_17_1_0#unique_1199040052"&gt;http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=2_1_0_17_1_0#unique_1199040052&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>