<?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>Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105683/integrating-bt-uart-from-peripheral_uart-sample-into-application-bt_nus_send-returns--128</link><description>Hello, 
 nrf52840 with ncs 2.4.2. 
 I have tried to integrate nus into my app, but when I run and connect to nrf connect for mobile, bt_nus_send() returns -128 which is ENOTCONN. The connected() function is successfully called on every connection attempt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Dec 2023 06:24:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105683/integrating-bt-uart-from-peripheral_uart-sample-into-application-bt_nus_send-returns--128" /><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/458434?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 06:24:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bad7c527-da71-4242-8101-9f689e122e73</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Created an internal JIRA ticket (NCO-284)&amp;nbsp; to inform the team about this issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/458433?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 06:15:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebf7e2e1-1504-4e3b-952a-cbeb4cf4abdc</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi mrd,&lt;/p&gt;
&lt;p&gt;One of our smartest FAE have asked me to test this on the latest nRF Connect for mobile app and I can see the same issue as yours now. This is an issue with the app on phone and not yours. I anyways recommend you to send notification only after connection unlike the unconditional send you are doing in the main while loop.&lt;/p&gt;
&lt;p&gt;I will create an internal JIRA ticket for the mobile apps team and inform them about this behavior. Will update you when I hear something from them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/458328?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 14:03:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:841dccfa-82a1-4983-8e45-f678a861f79f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I used nRF Connect for Mobile (iOS) app to test this and it worked quite fine after the connection is established and notification enabled. No more error -22 anymore..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/458191?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 20:37:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61f1e300-b9f6-4153-95ad-c1e3bd7c87c4</guid><dc:creator>mrd</dc:creator><description>&lt;p&gt;Interesting.&amp;nbsp;So you able to run my code and enable notifications in the app?&lt;/p&gt;
&lt;p&gt;Because I can&amp;#39;t do that. My version of the app will not allow me to enable notifications when connected to my app (works fine for peripheral_uart). I press the 3 arrows button but nothing happens. Am I just experiencing a bug in the nrf app that doesn&amp;#39;t let me enable notifications?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/458006?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 08:51:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35544158-b1d2-41bc-836f-e01dabf97f3c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;There are two things that you are doing wrong.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Calling &lt;span&gt;bt_nus_send before the connection is established.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Calling it before the notifications are enabled by your peer.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span&gt;When I connect to your device and enable notifications, then I do not see any errors. You need to make sure to add logic in your code to call&amp;nbsp;bt_nus_send&amp;nbsp;after connection and notifications are enabled.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/457681?ContentTypeID=1</link><pubDate>Mon, 27 Nov 2023 18:39:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2113cca-e27f-4778-aa53-79cecb49f63f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks for attaching the project mrd, I will do a quick test of this tomorrow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/457395?ContentTypeID=1</link><pubDate>Fri, 24 Nov 2023 22:40:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce8c2eeb-2773-40f8-b2f4-0051ebf85620</guid><dc:creator>mrd</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8780.app.zip"&gt;devzone.nordicsemi.com/.../8780.app.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/457329?ContentTypeID=1</link><pubDate>Fri, 24 Nov 2023 13:22:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe598d4f-d4cd-44d9-b74f-20afd4ed4786</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It seems like the connection is not complete as you said but it is&amp;nbsp; not very obvious as you said what went wrong.&lt;/p&gt;
&lt;p&gt;The sniffer log would have helped but I think it is best if you attach your whole project so that I can quickly do this test on my desk and reproduce it. I will then avoid asking you a lot of questions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/457027?ContentTypeID=1</link><pubDate>Wed, 22 Nov 2023 19:53:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee33cedf-2b6d-4c27-89cc-b2e37037a63c</guid><dc:creator>mrd</dc:creator><description>&lt;p&gt;This is with the connect for mobile app.&lt;/p&gt;
&lt;p&gt;While I appreciate that it should be easy (I expected it to be easy myself), I am finding it to be quite so obvious.&lt;/p&gt;
&lt;p&gt;I was hoping you could take a look at the method I described for&amp;nbsp;my port (perhaps even the c file) and suggest what I am missing! Does it work when you try it?&lt;/p&gt;
&lt;p&gt;Were&amp;nbsp;you able to learn anything from the log I posted?&lt;/p&gt;
&lt;p&gt;Any other information I could provide that would be helpful?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/456952?ContentTypeID=1</link><pubDate>Wed, 22 Nov 2023 14:07:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18bd1142-0c01-4387-a857-b9a3c29e7339</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;This is still with the nRF Connect for Mobile app, or do you have a mobile app of your own?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We do not have an example of the Nordic UART service that does not forward the data to the UART peripheral I&amp;#39;m afraid, if that&amp;#39;s what you&amp;#39;re trying to do, but it shouldn&amp;#39;t be a lot of work to just remove the fact that data is forwarded to the UART peripheral, and it seems strange to me that it would result in the notifications not being possible to enable.&lt;/p&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><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/456798?ContentTypeID=1</link><pubDate>Wed, 22 Nov 2023 00:26:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a59a69e-c6e2-479d-9e08-a01feafa578b</guid><dc:creator>mrd</dc:creator><description>&lt;p&gt;Is this just a bug in the app that&amp;#39;s not allowing me to subscribe to notifications? I am a little suspicious of the app right now - I can see my services discovered, but only after I rotate my phone sideways to force the screen to re-display...&lt;/p&gt;
&lt;p&gt;I can connect and bond to my phone, and send HID codes (the other part of the BT connection). But I cannot subscribe to NUS notifications.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/456780?ContentTypeID=1</link><pubDate>Tue, 21 Nov 2023 19:21:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a3d9db2-9036-4d39-9ad5-2aa90757bb65</guid><dc:creator>mrd</dc:creator><description>&lt;p&gt;Hello Simon, thanks for taking a look at this.&lt;/p&gt;
&lt;p&gt;After instrumenting&amp;nbsp;bt_gatt_is_subscribed() inside of bt_nus_send(),&amp;nbsp;it turns out the connection is simply not subscribed. In retrospect this is obvious, as I can&amp;#39;t subscribe to notifications in the app.&lt;/p&gt;
&lt;p&gt;Clearly my NUS port is insufficient, because I can subscribe just fine to the peripheral_uart example.&lt;/p&gt;
&lt;p&gt;Do you have any examples of only NUS without hardware uart?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My port consisted of:&lt;/p&gt;
&lt;p&gt;-define&amp;nbsp;bt_receive_cb, include&amp;nbsp;&lt;span&gt;&lt;span&gt;BT_NUS_SECURITY_ENABLED,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;BT_NUS_UART_ASYNC_ADAPTER in Kconfig&lt;/p&gt;
&lt;p&gt;-Add to prj.conf&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_NUS&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UART_ASYNC_API&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BT_NUS_UART_ASYNC_ADAPTER&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_UART_INTERRUPT_DRIVEN&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;-call bt_nus_init and (once connected) bt_nus_send&lt;/p&gt;
&lt;p&gt;You can see my c file (mostly boilerplate example bt code) and prj.conf in my original post. What am I missing?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is the log you requested.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nRF Connect, 2023-11-16&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Joystick (51:72:95:D8:64:33)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;V 15:23:56.551 Connecting to 51:72:95:D8:64:33...&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:56.551 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.571 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;I 15:23:59.571 Connected to 51:72:95:D8:64:33&lt;/span&gt;&lt;br /&gt;&lt;span&gt;V 15:23:59.580 Discovering services...&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.580 gatt.discoverServices()&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.591 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.694 [Callback] Services discovered with status: 0&lt;/span&gt;&lt;br /&gt;&lt;span&gt;I 15:23:59.695 Services discovered&lt;/span&gt;&lt;br /&gt;&lt;span&gt;V 15:23:59.699 Generic Attribute (0x1801)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Service Changed [I] (0x2A05)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Client Supported Features [R W] (0x2B29)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Database Hash [R] (0x2B2A)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Generic Access (0x1800)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Device Name [R] (0x2A00)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Appearance [R] (0x2A01)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Peripheral Preferred Connection Parameters [R] (0x2A04)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Battery Service (0x180F)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Battery Level [N R] (0x2A19)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Device Information (0x180A)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Model Number String [R] (0x2A24)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Manufacturer Name String [R] (0x2A29)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- PnP ID [R] (0x2A50)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Nordic UART Service (6e400001-b5a3-f393-e0a9-e50e24dcca9e)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- TX Characteristic [N] (6e400003-b5a3-f393-e0a9-e50e24dcca9e)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- RX Characteristic [W WNR] (6e400002-b5a3-f393-e0a9-e50e24dcca9e)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Human Interface Device (0x1812)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Protocol Mode [R WNR] (0x2A4E)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Report [N R] (0x2A4D)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Report Reference (0x2908)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Report [N R] (0x2A4D)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Report Reference (0x2908)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Report [N R] (0x2A4D)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Report Reference (0x2908)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Report [N R] (0x2A4D)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Client Characteristic Configuration (0x2902)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Report Reference (0x2908)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- Report Map [R] (0x2A4B)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- HID Information [R] (0x2A4A)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;- HID Control Point [WNR] (0x2A4C)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.700 gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.701 gatt.setCharacteristicNotification(00002a19-0000-1000-8000-00805f9b34fb, true)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.702 gatt.setCharacteristicNotification(6e400003-b5a3-f393-e0a9-e50e24dcca9e, true)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;D 15:23:59.703 gatt.setCharacteristicNotification(00002a4d-0000-1000-8000-00805f9b34fb, true)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;I 15:24:00.097 PHY updated (TX: LE 2M, RX: LE 2M)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;I 15:24:02.168 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Integrating bt uart from peripheral_uart sample into application: bt_nus_send returns -128</title><link>https://devzone.nordicsemi.com/thread/455877?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2023 07:34:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f653bc2-9ed3-4a95-b462-80ba463be7d3</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What exactly do you set the &amp;quot;conn&amp;quot; connection object to when trying to set a specific connection object, you must be entering an invalid value here for EINVAL to return.&lt;/p&gt;
&lt;p&gt;Regarding error -128 it could be because of the security.&amp;nbsp;Can you upload the log from your nRF Connect for Mobile when connecting and running into this issue on your device? I would assume that log tells you that the connection isn&amp;#39;t completed, either due to some security (pairing for example) not being completed or because service discovery is still ongoing.&lt;/p&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>