<?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_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39135/ble_cts_c_evt_current_time-invalid_time-events-never-thrown</link><description>Hi, 
 
 I am using SDK14.2, s132, with nRF Connect on Android. 
 
 I have used my own implementation of the CTS_C BLE service. The chip is able to detect, and request the current time, with nRF Connect showing that it sends the correct time over. 
 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Oct 2018 17:56:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39135/ble_cts_c_evt_current_time-invalid_time-events-never-thrown" /><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/153337?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 17:56:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80e64113-67e9-4858-b705-9bfe1f693cae</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;Absolutely correct! Thanks so much! I&amp;#39;ve found a solution that works well in the current code base,&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/153256?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 13:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:849714e5-6f38-44cc-accc-5b83fa1ba4b3</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The issue is that the&amp;nbsp;m_cts_c, which was defined in tnd_ble_cts_c.h is never updated in tnd_ble_cts_c.c, so it doesn&amp;#39;t get the updated pointer to the&amp;nbsp;p_cts-&amp;gt;evt_handler&amp;nbsp;in&amp;nbsp;current_time_read() in ble_cts_c.c.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The problem is that when you have this type variable in a header file, all the other files that include this header file and uses the variable will generate an own instance of the variable. The solution is to use declare this variable in a .c file, and use extern for all other files that need access to this parameter.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is easy when you have it in the main.c file, because you don&amp;#39;t need to pass this variable around. When you have it in a different file, you must use extern. Since it is a static, you can&amp;#39;t use extern as it, so you might have to change the macro (BLE_CTS_C_DEF()).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The easier solution is to move it to the main.c file, but if you want to separate it into a different file, you must work around this issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/152256?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 15:47:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7fb1017-27fa-42ac-b666-e75c7d0647ad</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;Thanks so much!&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/152141?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 06:43:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30df9fe8-d0ca-4fed-9a70-3b825cde8120</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have replicated your issue, but not found the cause yet. I will try to figure this out and get back to you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151781?ContentTypeID=1</link><pubDate>Fri, 05 Oct 2018 09:02:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfe6a8ad-ae28-4a88-804b-32c9b7541377</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;Of course! I&amp;#39;ll contact you privately&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151780?ContentTypeID=1</link><pubDate>Fri, 05 Oct 2018 09:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c86b12e6-024d-4ecc-8fa5-6282b696ef52</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Is it possible for me to reproduce this on an nRF52832 DK? If so, is it possible to send the project, so that I can take a look?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151705?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 14:58:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7038e5eb-23d7-4d9d-955a-59b89f50c39e</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;It does! The sigtrap fires in ble_cts_c.c, after assigning the evt_type as&amp;nbsp;BLE_CTS_C_EVT_CURRENT_TIME. I can even see in the evt params it has the correct time and date.&lt;/p&gt;
&lt;p&gt;It fires specifically, every time, on&amp;nbsp;p_cts-&amp;gt;evt_handler(p_cts, &amp;amp;evt);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151704?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 14:51:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:483efbce-b111-4f96-9435-15fa0e304f67</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok. But does it ever return NRF_SUCCESS, in one of the retries?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151701?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 14:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b96df6f0-a753-4f1f-8c99-aa07e1a5f6ed</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;So having the retry function was due to that fact I thought there was an&amp;nbsp;&lt;span&gt;sd_ble_gattc_read occurring. Therefore, retry after a period.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The&amp;nbsp;ble_cts_c_current_time_read() is called on the&amp;nbsp;BLE_CTS_C_EVT_DISCOVERY_COMPLETE event, after&amp;nbsp;ble_cts_c_handles_assign is called, and successful.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will get NRF_ERROR_BUSY back from&amp;nbsp;ble_cts_c_current_time_read, unless I do the retry.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151696?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 14:22:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82747677-d37a-4382-a6ca-1e23ef6a0476</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;If this function is called before you are connected, or before the service is discovered, it should return NRF_ERROR_INVALID_STATE or BLE_ERROR_INVALID_CONN_HANDLE.&lt;/p&gt;
&lt;p&gt;But that being said, the fact that it returns NRF_ERROR_BUSY doesn&amp;#39;t &amp;quot;destroy&amp;quot; anything else, but I think it is only returned if you have another sd_ble_gattc_read procedure already in process.&lt;/p&gt;
&lt;p&gt;You can alternatively wait to call ble_cts_c_current_time_read() until you get the&amp;nbsp;BLE_CTS_C_EVT_DISCOVERY_COMPLETE event.&lt;/p&gt;
&lt;p&gt;Then you can check if ble_cts_c_current_time_read() returns NRF_SUCCESS. If it does, it is no point in calling it again until you get the&amp;nbsp;BLE_CTS_C_EVT_CURRENT_TIME event before you call it again.&lt;/p&gt;
&lt;p&gt;Does it return NRF_ERROR_BUSY before it returns NRF_SUCCESS if you try this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151686?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 13:36:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:428f4f58-be3b-4a8e-a6b6-194b744a0618</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So NRF_ERROR_BUSY occasionally occurs during the connection/bonding process, which is when we do the CTS_C read. As a result, if the err_code returns as NRF_ERROR_BUSY, I retry after a second, which allows the bonding process to complete. It will repeat until it works. Is there a better way to do this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151682?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 13:30:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f51793a-93c2-4cba-a6ec-044cc859a774</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;To be honest, I don&amp;#39;t know why it behaves like this. But why did you have to avoid the&amp;nbsp;NRF_ERROR_BUSY? did it return that all the time? I tried the ble_app_cts_c example, and I see that it returns this if I press button 1 two times in a row. That is, one more time before I get the response which is printed in the log. Do you get NRF_ERROR_BUSY if you only call it once?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151520?ContentTypeID=1</link><pubDate>Wed, 03 Oct 2018 15:09:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b254adb7-dcd4-4d51-b64d-b8b295ddcf54</guid><dc:creator>aTended</dc:creator><description>&lt;p&gt;You were correct - I was adding the CTS_C service to the&amp;nbsp;uuids_complete, not uuids_solicited. I&amp;nbsp;created an app_timer based retry of the&amp;nbsp;ble_cts_c_current_time_read function, in order to avoid the&amp;nbsp;NRF_ERROR_BUSY error. It does work, and I now read the date correctly. However, I am now getting a sigtrap thrown in newlib-nano, specifically in locale.c.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;313: #ifndef _MB_CAPABLE
   314:   if (locale)
0x00000000 00 04                lsls r0, r0, #16 
   312: {
0x00000002 00 20                movs r0, #0 
   315:     { 
   316:       if (strcmp (locale, &amp;quot;POSIX&amp;quot;) &amp;amp;&amp;amp; strcmp (locale, &amp;quot;C&amp;quot;)
0x00000004 E9 08                lsrs r1, r5, #3 
0x00000006 00 00                movs r0, r0 
0x00000008 7D 05                lsls r5, r7, #21 
0x0000000a 00 00                movs r0, r0 
0x0000000c C9 08                lsrs r1, r1, #3 
0x0000000e 00 00                movs r0, r0 
   317: 	  &amp;amp;&amp;amp; strcmp (locale, &amp;quot;&amp;quot;))
   318:         return NULL;
   319:     }
   320:   return &amp;quot;C&amp;quot;;
0x00000010 87 05                lsls r7, r0, #22&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Are these issues connected?&lt;/p&gt;
&lt;p&gt;This sigtrap reliably occurs after the CTS_C read.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT: The point at which it enters the sigtrap is from line 277 in current_time_read, in ble_cts_c.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;273:                 // Valid time reveiced.
   274:                 evt.evt_type = BLE_CTS_C_EVT_CURRENT_TIME;
0x0002bc88 03 23                movs r3, #3 
0x0002bc8a 3B 72                strb r3, [r7, #8] 
   275:             }
   276:         }
   277:         p_cts-&amp;gt;evt_handler(p_cts, &amp;amp;evt);
0x0002bc8c 7B 68                ldr r3, [r7, #4] 
0x0002bc8e 1B 68                ldr r3, [r3, #0] 
0x0002bc90 07 F1 08 02          add.w r2, r7, #8 
0x0002bc94 11 46                mov r1, r2 
0x0002bc96 78 68                ldr r0, [r7, #4] 
0x0002bc98 98 47                blx r3 
0x0002bc9a 00 E0                b.n 0x2bc9e &amp;lt;current_time_read+120&amp;gt; 
   247:         return;
0x0002bc9c 00 BF                nop  
   248:     }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown</title><link>https://devzone.nordicsemi.com/thread/151487?ContentTypeID=1</link><pubDate>Wed, 03 Oct 2018 13:48:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d41c7300-07df-472b-a012-0b3c2260f4ff</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;You are probably missing some handling behind the CTS_C service. Can you see if there is any difference between your implementation of CTS_C service and the implementation in the example?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>