<?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>Heartbeat with response to understand both mobile device is connected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66369/heartbeat-with-response-to-understand-both-mobile-device-is-connected</link><description>Hi, 
 I have a setup where mobile device(central) connect to nrf51dk (peripheral) and exchange data for a time. I want to detect unplanned disconnection of mobile device in 2-3 seconds. I tried to do this with supervision timeout but android forces its</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Oct 2020 10:47:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66369/heartbeat-with-response-to-understand-both-mobile-device-is-connected" /><item><title>RE: Heartbeat with response to understand both mobile device is connected</title><link>https://devzone.nordicsemi.com/thread/272480?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 10:47:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:067a14f5-11aa-4f2d-80bb-4fce0167bf23</guid><dc:creator>Serhan</dc:creator><description>&lt;p&gt;Hello, I have implemented it the exact same way you described. It works as I wanted. But currently I refresh the timer only when heartbeat response received. How can i refresh the timer for any packet received?&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Best Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heartbeat with response to understand both mobile device is connected</title><link>https://devzone.nordicsemi.com/thread/272308?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 12:35:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7bb0699-a9c1-463b-9d77-06440dc4e1ad</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for my late reply.&lt;/p&gt;
[quote user="Serhan"]thanks for your answer.[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="Serhan"]By unplanned disconnection I meant power off of mobile phone or disconnection because of distance. I want to detect this disconnection in 2-3 seconds and go back to advertising. Supervision timeout takes too long to go back to advertising state.[/quote]
&lt;p&gt;I understand what you mean, thank you for clarifying.&lt;br /&gt;This is usually what the supervision timeout feature is used for, but I understand your issue with the Android central dictating a too long supervision timeout.&lt;/p&gt;
[quote user="Serhan"]What came to my mind is, sending heartbeat every 2-3 seconds from peripheral and on the mobile phone side, during the handling of this heartbeat notification, writing to a write characteristic provided by peripheral. And in peripheral side check if this write characteristic is triggered every 2-3 secs. If not go back to advertising state.&amp;nbsp;[/quote]
&lt;p&gt;You could use &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s112.api.v7.2.0/group___b_l_e___g_a_p___c_o_n_n___m_s_c.html"&gt;the sd_ble_gap_disconnect function for this, as illustrated in this sequence diagram&lt;/a&gt;. You could have this function called following a timer timeout, and then refresh the timer with every received packet, or after a certain transfer has occurred. What do you think about this solution, could it work for your application?&lt;br /&gt;The disconnect is usually handled by going back to advertising, so this will require only small changes to your existing code - namely the addition of&amp;nbsp;such a timer.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heartbeat with response to understand both mobile device is connected</title><link>https://devzone.nordicsemi.com/thread/271559?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 14:05:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:139dd41f-c286-47c2-a2e3-e2b85a0fafc3</guid><dc:creator>Serhan</dc:creator><description>&lt;p&gt;Hello, thanks for your answer. By unplanned disconnection I meant power off of mobile phone or disconnection because of distance. I want to detect this disconnection in 2-3 seconds and go back to advertising. Supervision timeout takes too long to go back to advertising state.&lt;/p&gt;
&lt;p&gt;What came to my mind is, sending heartbeat every 2-3 seconds from peripheral and on the mobile phone side, during the handling of this heartbeat notification, writing to a write characteristic provided by peripheral. And in peripheral side check if this write characteristic is triggered every 2-3 secs. If not go back to advertising state.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Heartbeat with response to understand both mobile device is connected</title><link>https://devzone.nordicsemi.com/thread/271558?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 13:57:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d084e2a-de3b-4b49-ac89-4575de808bec</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]I want to detect unplanned disconnection of mobile device in 2-3 seconds.[/quote]
&lt;p&gt;By this, do you mean a termination of the link from either side, or that a device stops responding - such as if it is out of reach?&lt;/p&gt;
[quote user=""]I tried to do this with supervision timeout but android forces its 20s supervision timeout.[/quote]
&lt;p&gt;This is correct, it is the central that determines the supervision timeout.&lt;/p&gt;
[quote user=""]I am planning to implement a heartbeat that nrf51 sends and mobile phone receives, but i want to include give a response from the mobile phone to the heartbeat received from nrf51dk.[/quote]
&lt;p&gt;Well, strictly speaking, every connection event will be such a heartbeat - because a connection event starts with the central sending a packet, followed by the slave&amp;#39;s response, acknowledging the masters initial packet.&lt;/p&gt;
[quote user=""]How can i do this? is there any notify with response gatt type? or any other suggestions?[/quote]
&lt;p&gt;Every packet sent over BLE needs to be acknowledged by the other device. If a packet is not acknowledged, then it will be re-transmitted until it is acknowledged or the timeout supervision is up, and the link is terminated.&lt;br /&gt;I am not entirely sure what you would like to achieve here.&lt;br /&gt;I suppose you could implement a timer that keeps track of how long time has passed since the last received packet - but this would come in addition to the existing timeout supervision timer. &lt;s&gt;Additionally, if you then were to send a link termination packet, it will not be acknowledged either, so the link will time out instead.&lt;/s&gt;&lt;br /&gt;Could you tell me more about what you intend for the peripheral to do, if it does not receive anything from the central for 2-3 seconds?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>