<?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>Timer implementation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55892/timer-implementation</link><description>Hi, 
 I was referring the timer example code for PCA10040. I wanted to include the timer code in my ble peripheral code which uses custom GATT service. Can you help me with this? What I was trying - Once I receive a message from the host, I start the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Jan 2020 13:18:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55892/timer-implementation" /><item><title>RE: Timer implementation</title><link>https://devzone.nordicsemi.com/thread/227241?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 13:18:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72d3e365-25f9-4c4a-a281-4e994fcfa2a7</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement a timer into your application
&lt;ul&gt;
&lt;li&gt;Check out the &lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/application-timer-tutorial"&gt;nRF5 SDK Application Timer Tutorial&lt;/a&gt;&amp;nbsp;for guidance on how to implement a timer, but create a single shot timer instead of a repeated timer&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Create a boolean variable &lt;em&gt;timer_expired&lt;/em&gt;&amp;nbsp;and set it to &lt;em&gt;true&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;When the first message is received, start the timer and set&amp;nbsp;&lt;em&gt;timer_expired&lt;/em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;to &lt;em&gt;false&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;When the timeout handler function is called set&amp;nbsp;&lt;em&gt;timer_expired&lt;/em&gt;&lt;span&gt;&amp;nbsp; to &lt;em&gt;true&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;When the second message is received, check the value of&amp;nbsp;&lt;em&gt;timer_expired&lt;/em&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&lt;/em&gt;and take appropriate action. E.g. if it is equal to &lt;em&gt;true&amp;nbsp;&lt;/em&gt;then you quit/delete bonds.
&lt;ul&gt;
&lt;li&gt;Maybe you could create a second boolean variable &lt;em&gt;timer_started &lt;/em&gt;in case you receive this message before the other message&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>