<?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>Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56859/trying-to-integrate-bonding-into-uart-example-but-peer-manager-event-handler-never-being-called</link><description>I developed a functioning application that advertises with Nordic UART Service, connects to a smartphone application, then reads various sensor data using the SAADC and transmits data to a smartphone. I now want to integrate bonding into the application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 25 Jan 2020 08:13:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56859/trying-to-integrate-bonding-into-uart-example-but-peer-manager-event-handler-never-being-called" /><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230967?ContentTypeID=1</link><pubDate>Sat, 25 Jan 2020 08:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88188943-c741-47c9-927e-352512edce59</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;Your suggestion to set security parameters to SEC_JUST_WORKS did the trick! Now I am able to bond and pair with my device very reliably, thank you so much for all the help&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230774?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2020 06:53:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f025db9b-3126-477f-96f6-24d7dac3dc07</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="nhill03"] then experience the behavior of peer manager never being called.[/quote]
&lt;p&gt;I see. But are you sure the phone attempts to pair bond? Please either check with a sniffer or just use nRF Connect or an Android phone and explicitly try to pair or bond. Alternatively, replace&amp;nbsp;SEC_OPEN where you find it in ble_nus.c. with&amp;nbsp;SEC_JUST_WORKS, so that the iPhone will initiate bonding automatically when it attempts to use the NUS service. An important point here is tha tiOS will not pair or bond automatically unless it needs to (which is when it gets access denied to read or write to a characteristic due to a too low security level).&lt;/p&gt;
[quote user="nhill03"]Do I need to include Bond Manager Service in addition to Nordic UART Service?[/quote]
&lt;p&gt;No.&lt;/p&gt;
[quote user="nhill03"]Or does adding the peer manager code shown above now require bonding to read/write to UART characteristics?[/quote]
&lt;p&gt;No. But by doing the modifications I suggested earlier in this post in ble_nus.c, bonding or pairing will be required.&lt;/p&gt;
[quote user="nhill03"]Because my application still functions, with the code included in the original post my application advertises, connects, and sends UART data as if the peer manager functions are not even there. It has not impacted my application at all.[/quote]
&lt;p&gt;It will not have any effect unless the pairing procedure is initiated. Which it probably is not&amp;nbsp;in your test setup.&lt;/p&gt;
[quote user="nhill03"] I will try on the nRF Connect android and desktop applications, that is a good idea[/quote]
&lt;p&gt;Yes it is &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt; (since android has API&amp;#39;s for the application to specifically pair or bond, which is then possible through the nRF Connect app on Android).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230757?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2020 03:17:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d03d1bdd-3207-486c-80ac-1b7dae36a306</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;Yes you are correct, however I already know how to handle error 4102. I already knew that this is caused by deleting bonds on the nRF52 DK and not the phone. Is the correct way to delete bonds on an iPhone to select &amp;quot;forget this device&amp;quot; from within my iOS bluetooth settings menu? If so, I already tried that before making this post. After selecting &amp;quot;forget this device&amp;quot; from within my iphone, I then experience the behavior of peer manager never being called.&lt;/p&gt;
&lt;p&gt;Do I need to include Bond Manager Service in addition to Nordic UART Service? Or does adding the peer manager code shown above now require bonding to read/write to UART characteristics? Because my application still functions, with the code included in the original post my application advertises, connects, and sends UART data as if the peer manager functions are not even there. It has not impacted my application at all. I will try on the nRF Connect android and desktop applications, that is a good idea&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230572?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 11:37:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd9df922-f8a4-4e8d-b366-70878bff0e43</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You have described two distinctly different issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The issue where you deleted bonding information on one side and got error 4102, is caused by only deleting bonding information on the phone, and not the device, as explained in my last two posts.&lt;/li&gt;
&lt;li&gt;Regarding the issue with no peer manger events:
&lt;ul&gt;
&lt;li&gt;There is no need to pass the event to the peer manager from your application like it was done in older SDK versions. This is because in 15.2, this is handled by the peer manager itself. (Specifically, you can see that peer_manager.c uses the&amp;nbsp;NRF_SDH_BLE_OBSERVER to register it&amp;#39;s event handler so that the SoftDevice Handler library forwards the events directly.)&lt;/li&gt;
&lt;li&gt;I suspect that the phone simply never attempts to pair or bond? Have you double-checked that? iOS will only pair/bond when needed because it attempts to access a characteristic that requires that. Therefore, I suggest you test with Android or nRF Connect for Dekstop first (if you have an additional nRF52 DK or dongle) to see if it works, since there you can manually trigger pairing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230530?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 09:55:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4563f60b-6862-42f7-91db-1e49a5db1b34</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;I tried fully erasing the DK using nrfjprog -e, and I also explicitly allowed pairing with the example code you provided. I also added another case into pm_evt_handler for &amp;quot;PM_EVT_SEC_SUCCEEDED&amp;quot; in which I simply output text using NRF_LOG_INFO(). However, the behavior still persists and the pm_evt_handler function is never called or entered at all. I even deleted all the peer manager related functions, and re-integrated them from the ble_app_template example. I also checked through the heart rate sensor example and verified I&amp;#39;m using the same function calls/configurations/etc, the heart rate sensor example is almost the same as the ble_app_template with regards to bonding. Also did this for ble_app_bps example.&lt;/p&gt;
&lt;p&gt;When should events be passed to the Peer Manager, and how are they passed? The peer manager is not referenced or mentioned in any other functions. Variable &amp;quot;ble_gap_sec_params_t sec_param&amp;quot; is set inside peer_manager_init(), but how does this function relate to the rest of the program? I know that in older SDK versions, a function called &amp;quot;ble_evt_dispatch&amp;quot; would dispatch events to the peer manager. This is even discussed in a comment within main.c of ble_app_bps example, line 215-217. The comment reads:&lt;/p&gt;
&lt;p&gt;&amp;quot;NOTE: For this to work, make sure ble_bps_on_ble_evt() is called before ble_bondmngr_on_ble_evt() in ble_evt_dispatch()&amp;quot;&lt;/p&gt;
&lt;p&gt;However there are no such functions in any examples within SDK version 15.2.0.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230518?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 09:24:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e39ee838-75db-4175-8b87-84b057d6eb4f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="nhill03"]I have tried erasing the DK through Segger Embedded Studios and reflashing[/quote]
&lt;p&gt;How did you do it? SES normally just does a sector erase, and in that case, the FDS pages holding the bonding information is left untouched. This is then still valid after you program the application again. So to fix this, either completely erase the chip using &amp;quot;nrfjprog -e&amp;quot; or explicitly allow repairing as I explained in my previous post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230459?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 01:46:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d68a4c95-8484-4ed5-8c78-b31967f98d93</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1157.screen.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;This is what I see in my debug terminal now, whereas previously I would see logs I put in the peer manager handler as well as logs from the default pm_evt_handler_log function logs (where the error/success would be written)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230454?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 01:06:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd505fed-85df-4587-9093-358df7a58548</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;I began experiencing this issue after I deleted bonding information from my iOS device. Now I don&amp;#39;t get any debug logs from any peer manager functions. I have tried erasing the DK through Segger Embedded Studios and reflashing, but this does not seem to make a difference. I have also tried with three different phones which were never previously bonded, and tried with two new DKs that I had never flashed this code onto. I don&amp;#39;t see the error anymore, or any logs involved to peer manager anymore.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230432?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 17:28:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b3b3559-426a-4ff2-a0b3-3743862fe86c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not see anything wrong with how you are using the peer manager. It seems copy-pasted from other SDK examples, with the only modification that you have added some logging in your pm_evt_handler(). There is nothing missing in your main.c or sdk_config.h related to the peer manger as far as I can see.&lt;/p&gt;
&lt;p&gt;You write that the behavior changed without you modifying the code at all. Obviously &lt;em&gt;something&lt;/em&gt; has changed. Are you sure this is the code you are testing, or could there be a mixup of some sort? Do you still have problems if you do a&amp;nbsp;full erase of the nRF device&amp;nbsp;(nrfjprog -e) before you program it and delete the bond on the iOS device and try again? I ask because the error you get 4102 = 0x1006 = PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING to indicate to me that you have lost bonding information on just one side.&lt;/p&gt;
&lt;p&gt;Note that you can allow repairing if you don&amp;#39;t want this to happen again, and are OK with the security implications of it. If so, just add handling of the PM_EVT_CONN_SEC_CONFIG_REQ event to you peer manager event handler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        case PM_EVT_CONN_SEC_CONFIG_REQ:
        {
            // Allow pairing request from an already bonded peer.
            pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
            pm_conn_sec_config_reply(p_evt-&amp;gt;conn_handle, &amp;amp;conn_sec_config);
        } break;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to integrate bonding into uart example, but peer manager event handler never being called</title><link>https://devzone.nordicsemi.com/thread/230310?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 11:19:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c847ade-f0d2-4b98-892e-c5283c2112f6</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;Update: I am using SDK 15.2.0 for development, and Segger Embedded Studios&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>