<?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>Bug in Heart Rate example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39910/bug-in-heart-rate-example</link><description>Hi, 
 there seems to be a bug in the Heart Rate Monitor (HRM) example or in the iOS app (nRF connect) -- when the simulated heart rate exceeds 8 bits (256) in the example, the corresponding iOS app starts showing incorrect values (259 instead of 260,</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Nov 2018 15:02:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39910/bug-in-heart-rate-example" /><item><title>RE: Bug in Heart Rate example</title><link>https://devzone.nordicsemi.com/thread/156195?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 15:02:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be476999-04f1-44a8-868b-9ea57302d9d9</guid><dc:creator>Audience</dc:creator><description>&lt;p&gt;Alright, I found the bug. It&amp;#39;s in the iOS app which incorrectly converts the 2 bytes from the heart rate. My code in Swift 4.2 is now -- I&amp;#39;ll leave it to the maintainer of nRF connect to fix it in their example which uses Objective-C:&lt;/p&gt;
&lt;pre class="language-swift hljs" lang="swift"&gt;private func heartRate(from characteristic: CBCharacteristic) -&amp;gt; Int {&lt;br /&gt; guard let characteristicData = characteristic.value else { return -1 }&lt;br /&gt; let array = characteristicData.toArray(type: UInt8.self)&lt;br /&gt; var bpmValue : Int = 0;&lt;br /&gt; if ((array[0] &amp;amp; 0x01) == 0) {&lt;br /&gt; // Stored in one byte&lt;br /&gt; bpmValue = Int(array[1])&lt;br /&gt; } else {&lt;br /&gt; //Stored in two bytes&lt;br /&gt; bpmValue = (Int(array[2]) &amp;lt;&amp;lt; 8) + Int(array[1])&lt;br /&gt; }&lt;br /&gt; return bpmValue&lt;br /&gt; }&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in Heart Rate example</title><link>https://devzone.nordicsemi.com/thread/156115?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 10:37:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79e3288f-34f0-44b5-825c-fa4026c90741</guid><dc:creator>Audience</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;both compiled the HRM example from scratch using Segger as well as just installed the pre-compiled hex file that is supplied on the webpage (&lt;a href="https://www.nordicsemi.com/eng/Media/Files/Getting-Started-with-the-nRF52-DK/nRF52-DK-heartrate-monitor-demo"&gt;https://www.nordicsemi.com/eng/Media/Files/Getting-Started-with-the-nRF52-DK/nRF52-DK-heartrate-monitor-demo&lt;/a&gt;). I also used different BLE apps on my iPhone 7 that support reading the heart rate, and all of them show the same issue. I know that the heart rate is increased in increments of 10 from the code, and given the fact that the heart rate is displayed correctly below 8 bits again indicates that it&amp;#39;s probably an encoding issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in Heart Rate example</title><link>https://devzone.nordicsemi.com/thread/154823?ContentTypeID=1</link><pubDate>Mon, 29 Oct 2018 10:02:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:637d733d-57a9-49d7-b2e0-17ea394cfe3a</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Do you have some details on how we can reproduce your issue? Like, how do you know the simulated hart rate is one less than what is reported in the nRF Connect app?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>