<?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>Crash when writing &amp;gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19123/crash-when-writing-20-bytes-from-android</link><description>Hi, 
 I&amp;#39;m trying to write more than 20 bytes to a custom characteristic, from Android (Cordova BLE Central), but this completely crashes my App 
 APP_ERROR:ERROR:Fatal 
 I&amp;#39;m using SDK 12.1 App Template, plus the LED &amp;amp; Button example service LBS 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Feb 2017 09:46:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19123/crash-when-writing-20-bytes-from-android" /><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73997?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 09:46:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97225212-71bd-49a3-a23c-b609732a8e2a</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;Not had time to look at this today.&lt;/p&gt;
&lt;p&gt;I will try to take a look in the next couple of days&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73996?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 09:29:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b07c8991-9541-484b-af25-ec09a00950ff</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Yes, you won&amp;#39;t get a hard error in this case as the applications resets the mcu. Did you find out where the app error comes from?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73995?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 10:07:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:372c7fac-d58c-45d8-af45-f5d6852d3079</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;OK. I&amp;#39;ll look in the app_error_fault_handler&lt;/p&gt;
&lt;p&gt;I had tried running it in the debugger under the evaluation copy of Keil (I&amp;#39;m normally using GCC command line), but it didnt stop the debugger anywhere useful&lt;/p&gt;
&lt;p&gt;I have used GDB on other processors and if there is a hard exception, GDB stops and I can get a back track (stack trace) but I guess as its in the app_error_fault_hander that reboots, its never getting a hard error that GDB etc would catch&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73994?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 09:57:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab828837-8296-4e80-b737-c644a2ef67f6</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Your code probably ends up in the fault handler which will reset the device by default (app_error_fault_handler). Try to add a DEBUG define to avoid this and you should be able to see where the error happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73993?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2017 20:06:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:481fe648-c641-483d-b4d5-3120221640c3</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;The code seems to reboot when it gets this error, and I dont know where the error actually occurs.&lt;/p&gt;
&lt;p&gt;It only seems to happen with my custom service in my ble_app_template code.&lt;/p&gt;
&lt;p&gt;I tried writing too many bytes to the Link Loss service write characteristic example and it was fine.&lt;/p&gt;
&lt;p&gt;So my next step is to use the LLS in my code instead of my custom service,  and determine if this is an issue with my main code or my custom service.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73992?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2017 16:25:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b3b92f8-ae8e-47cd-a4c1-88944708cf80</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Which error code do you get from sd_ble_user_mem_reply in the failing case&lt;br /&gt;
case BLE_EVT_USER_MEM_REQUEST:&lt;br /&gt;
err_code = sd_ble_user_mem_reply(p_ble_evt-&amp;gt;evt.gattc_evt.conn_handle, NULL);&lt;br /&gt;
APP_ERROR_CHECK(err_code);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73991?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 22:11:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b988d29-8fd4-4160-8ba1-39278efb931d</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;Just to update on my continued testing.&lt;/p&gt;
&lt;p&gt;I tried using the proximity example, and I&amp;#39;m writing 21 bytes to the Link Loss service (even though its length is listed as 2 bytes)&lt;/p&gt;
&lt;p&gt;But it doesn&amp;#39;t crash like the LBS example code does.&lt;/p&gt;
&lt;p&gt;So I&amp;#39;ll need to find what the difference is between these two firmwares is.
Because the issue may be in the error handing or lack of it in main, rather than the LBS service its self&lt;/p&gt;
&lt;p&gt;One thing I have noticed however, is that the examples don&amp;#39;t seem to have an inactivity timeout.&lt;/p&gt;
&lt;p&gt;IMHO all devices with services should implement in inactivity timeout, otherwise a DOS style attack could be mounted against BLE devices by writing an Android application, which connects but does not disconnect, thus locking the BLE device to further communications and flattening its battery.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73990?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 19:43:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ba7abad-1fe4-4e8f-9a4f-6e2a8f9a8842</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;@run_ar&lt;/p&gt;
&lt;p&gt;Sorry I should have made it clear that the firmware on the nRf51 crashes and starts.&lt;/p&gt;
&lt;p&gt;Cordova is working Ok.&lt;/p&gt;
&lt;p&gt;I referred to the firmware as the application as I have gone back to using the official Application Template in SDK 12.1.0, plus the example LED Button custom service.&lt;/p&gt;
&lt;p&gt;I will try building the Heart Rate example ( or one of the others) and modify my Codova App to try writing 21 bytes to one of Nordics examples and see if it still crashes, and report back.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73989?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 15:16:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6d70628-23b5-422e-ae09-0f6aa4c0c5a7</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;You may need to handle BLE_EVT_USER_MEM_REQUEST and BLE_EVT_USER_MEM_RELEASE like here &lt;a href="https://github.com/NordicSemiconductor/ble_app_hrs---LongWrite"&gt;github.com/.../ble_app_hrs---LongWrite&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73988?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 11:46:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e393308-2e38-44a6-bf28-a8408c08155e</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry, I might have misunderstood your question. I thought you meant that the cordova ble central crashed. But I guess you are saying that the app on the nRF51 crashes when you try to do a long write from cordova? What happens if you set the init length = max length?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73987?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 10:14:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00e5ea27-7578-4c2e-b65a-f1373abe97f2</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;Thanks guys&lt;/p&gt;
&lt;p&gt;I know that the max data transfer size is 20 byes, but I didnt expect the Application to have a fatal error if someone attempts to send more than 20 bytes.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d expect the SD to just reject the write, or truncate the data.&lt;/p&gt;
&lt;p&gt;Crashing is a problem for me, as I keep some history data in RAM and it will be lost if the application cashes.
(Writing data to Flash is not really an option as it would wear the flash out as it has limited write cycles&lt;/p&gt;
&lt;p&gt;Perhaps this is a bug in the S130 SD V2,0&lt;/p&gt;
&lt;p&gt;However its a bit of a pain to have to rebuild the same app for S130 SD V1.0 (even though its just an app for testing the connection to Android (Cordova)&lt;/p&gt;
&lt;p&gt;Edit
I guess I need to retest this on a non-custom service, that has a Write characteristic&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73986?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 08:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca5430d5-8d80-482e-b05a-8057825ff893</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;If you are using the default ATT MTU size, maybe you should take a brief look at &lt;a href="https://devzone.nordicsemi.com/question/34572/ble-long-write/"&gt;this&lt;/a&gt; thread and maybe also &lt;a href="http://stackoverflow.com/questions/24135682/android-sending-data-20-bytes-by-ble"&gt;this&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash when writing &gt; 20 bytes (from Android)</title><link>https://devzone.nordicsemi.com/thread/73985?ContentTypeID=1</link><pubDate>Fri, 20 Jan 2017 05:41:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b5cefe1-321e-4649-bb54-ccf2ff4c39fb</guid><dc:creator>SRA</dc:creator><description>&lt;p&gt;You know the MTU on your device may be limited to 20 bytes right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>