<?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 C++ Wrapper</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23501/ble-c-wrapper</link><description>I am trying to wrap BLE into a nice c++ class.
For this i am using ble_app_uart example.
I think it was working fine until i was up to clean the helper functions.
After that i got error_code: 8 at SOFTDEVICE_HANDLER_INIT(&amp;amp;clock_lf_cfg, NULL); . 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Sep 2017 07:13:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23501/ble-c-wrapper" /><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92329?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 07:13:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab804436-71c8-4d4b-8f24-eb088cbb89a5</guid><dc:creator>Sebastien Huet</dc:creator><description>&lt;p&gt;in your header:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;...
public:
    static BleWrapper &amp;amp;getInstance() {
   static BleWrapper instance{};
   return instance;
}
    void init(void);
    void start(void);
...
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92328?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 07:09:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6e591b2-ae8e-4fc9-9f9e-10475fd6621a</guid><dc:creator>schef</dc:creator><description>&lt;p&gt;How would i implement this instead of my code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92327?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 06:53:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:490bb8d7-cfef-4bc1-9ef0-a7280b577827</guid><dc:creator>Sebastien Huet</dc:creator><description>&lt;p&gt;this is thread safe when using c++11 and up. your are sure to have only one instance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92326?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 06:46:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:faa39a68-87a3-4da7-ab2e-21aaf8100b27</guid><dc:creator>schef</dc:creator><description>&lt;p&gt;Thanks for the suggestion. What do you mean by stronger?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92325?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 06:35:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80c43d28-3048-4d1e-8ec3-2c637fe4c513</guid><dc:creator>Sebastien Huet</dc:creator><description>&lt;p&gt;Nice work, thanks.&lt;/p&gt;
&lt;p&gt;you could construct your singleton like below, this is stronger.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static BleWrapper &amp;amp;getInstance() {
   static BleWrapper instance{};
   return instance;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92324?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2017 06:08:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:186d4981-106c-451a-994f-3b71ea059bb4</guid><dc:creator>schef</dc:creator><description>&lt;p&gt;I moved to sdk14 but here you go. &lt;a href="https://gist.github.com/schef/f945611d3835dc708371269407b29c6b"&gt;gist.github.com/.../f945611d3835dc708371269407b29c6b&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92322?ContentTypeID=1</link><pubDate>Fri, 08 Sep 2017 09:41:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:076ea10a-e762-410b-9397-823d78d2be20</guid><dc:creator>Sebastien Huet</dc:creator><description>&lt;p&gt;Hi @schef did you manage to write your wrapper? may you please share it? thx&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92323?ContentTypeID=1</link><pubDate>Mon, 17 Jul 2017 08:06:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4eb0503-cb33-4636-b63a-fef1c1a141ca</guid><dc:creator>schef</dc:creator><description>&lt;p&gt;Thanks for the anwser. I will have to see how i will solve this issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92321?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2017 11:41:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf587b03-8e49-4e45-8090-2445a08fbe22</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Inside &lt;code&gt;ble_advertising_start()&lt;/code&gt; there is a call to &lt;code&gt;m_evt_handler(m_adv_evt):588&lt;/code&gt;. In &lt;code&gt;advertising_init()&lt;/code&gt;, &lt;code&gt;ble_advertising_init()&lt;/code&gt; is called with the parameter &lt;code&gt;static_on_adv_evt&lt;/code&gt;, which you have implemented as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void BLEWrapper::static_on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
  /* static implementation of on_adv_evt for use with sdk callback function */
  BLEWrapper::getInstance()-&amp;gt;on_adv_evt(ble_adv_evt);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since your call to &lt;code&gt;BLEWrapper::getInstance()&lt;/code&gt; from &lt;em&gt;main.cpp&lt;/em&gt; have not completed, &lt;code&gt;_pInstance&lt;/code&gt; have not yet been set, and the check in &lt;code&gt;getInstance()&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if(_pInstance == NULL)
{
  _pInstance = new BLEWrapper();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will evaluate to true. This will create an infinite loop of new BLEWrapper-instances, and softdevice initialization will fail with error code 8, since it is allready initialized.&lt;/p&gt;
&lt;p&gt;You need to refactor your code to start advertising after init, or use another method of getting the instance.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92320?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2017 09:53:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01c07f57-4076-4431-9d41-5ec5bb631c5d</guid><dc:creator>schef</dc:creator><description>&lt;p&gt;in &lt;code&gt;main.cpp:40&lt;/code&gt; is a &lt;code&gt;BLEWrapper::getInstance();&lt;/code&gt; which should call the constructor. And constructor is in &lt;code&gt;ble_wrapper.cpp:30&lt;/code&gt; which calls &lt;code&gt;init:609&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE C++ Wrapper</title><link>https://devzone.nordicsemi.com/thread/92319?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2017 09:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e3213d9-a16c-4c4a-b4d9-110294d1a8b9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Is the error in &lt;code&gt;SOFTDEVICE_HANDLER_INIT&lt;/code&gt;, or from the call to &lt;code&gt;ble_advertising_start&lt;/code&gt;? If the error is in &lt;code&gt;SOFTDEVICE_HANDLER_INIT&lt;/code&gt; this error means that the stack is allready initialized, you should check that you are not calling this function multiple times. It does not make sense that you get the error in this function, but not if you comment out the proceeding call to &lt;code&gt;ble_advertising_start&lt;/code&gt;. If the error is from &lt;code&gt;ble_advertising_start&lt;/code&gt;, this means that the advertising module have not been successfully initialized. Where do you instantiate the class in you &lt;em&gt;main.cpp&lt;/em&gt; file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>