<?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>How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99127/how-to-establish-notifications-without-a-subscription</link><description>My task looks like Case ID: 115570, but now running nRF SDK 2.1.3 on nRF52840-DK. 
 My GATT server (Peripheral) has to send a special msg (see log) right after CONNECT_IND using a notification service to the Central. The Central itself cannot be changed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 31 May 2023 09:22:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99127/how-to-establish-notifications-without-a-subscription" /><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/428373?ContentTypeID=1</link><pubDate>Wed, 31 May 2023 09:22:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7433f42-4d2f-4f40-ada7-1013a2edfa09</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Hello Edvin,&lt;/p&gt;
&lt;p&gt;finally I&amp;#39;ve found a solution.&amp;nbsp;Add this line to &amp;#39;&lt;code&gt;prj.conf&lt;/code&gt;&amp;#39;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n          # n: allow sending notification messages without having notifications enabled&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;disables the check (in &lt;code&gt;gatt.c&lt;/code&gt;) and one can send notifications independent from beeing enabled before.&lt;/p&gt;
&lt;p&gt;Best regards - Matthias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/423452?ContentTypeID=1</link><pubDate>Wed, 03 May 2023 07:44:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83334927-5a85-463a-8d9e-b66c4aeaf27d</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Hello Edvin,&lt;/p&gt;
&lt;p&gt;I in fact now can connect to the black-box-central, but need good luck for it - connection procedure isn&amp;#39;t deterministic as expected. In only a few cases the central opens notification - and all works fine this case. I can send my cookie without notifictation enabled as well, but there is only a short time for it - the window opens for about 500ms after end of GATT enumeration.&lt;br /&gt;On any earlier or later attempts the connection is dismissed by the central. And how long GATT enumeration takes depends on BT traffic.&lt;br /&gt;The idea - if I can (re)start a timer (say 300ms) whenever GATT enumeration takes place I would get a really good chance to hit the timing window when this timer expires.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Reconnection&lt;br /&gt;This box of bunches&amp;nbsp;I havn&amp;#39;t opened yet... coming soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/423408?ContentTypeID=1</link><pubDate>Tue, 02 May 2023 22:19:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef016e6d-4373-40e8-afed-3d5f1f4f73b9</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;Not sure if this is helpful, but if you bond the devices, then a subscribed notification is persisted across reconnections. You can therefore send a notification immediately after the connection has been established in that case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/423400?ContentTypeID=1</link><pubDate>Tue, 02 May 2023 21:35:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71955b39-8ced-4fd8-a33f-b8c61cd28517</guid><dc:creator>Edvin</dc:creator><description>[quote user="m.foerster@imm-electronics.de"]the central opens a short timing window after it has discovered the peripheral GATT profile - this small window I have to hit with my cookie.&lt;br /&gt;[/quote]
&lt;p&gt;What exactly do you mean by this?&lt;/p&gt;
&lt;p&gt;I am not aware of any events generated on the peripheral when the central has finished it&amp;#39;s service discovery, if that is what you mean? What do you need to do at this point in time? Is it something that you see from the sniffer trace of the two original devices?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/423031?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 15:04:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d01d327-54a8-41d9-b632-c11f73ccdefa</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Hello Edwin,&lt;br /&gt;&lt;br /&gt;finally I&amp;#39;ve managed to fake nearly all of them - advertising packet, scan response, device address, GATT profile 0x180A (DIS) and 0x1000 the customer functions, where the secret cookies should be exchanged.&lt;br /&gt;For GATT inspection I did use the GATT Browser from Renesas (very useful because displayed data do not disappear when device is disconnected - but don&amp;#39;t forget to switch to light theme on iOS, otherwise the font vanishes...).&lt;br /&gt;Some entries in 0x180A (DIS) are missing, and I couldn&amp;#39;t figure out how to add a user description to each GATT function.&lt;br /&gt;The black-box central tries to connect to my nordic implementation, and after a few attemps it works sometimes. But it seems to me to be a timing problem - the central opens a short timing window after it has discovered the peripheral GATT profile - this small window I have to hit with my cookie.&lt;br /&gt;But when thsi window opens depends on how much traffic is on the air.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;So it would be greate to have an event when GATT profiling is in progress or finished - is there a possibility to get a user callback function involved?&lt;/p&gt;
&lt;p&gt;Thanks in advance - Matthias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422978?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 12:19:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d1fa473-5f68-46f2-b6a1-3e84132bf020</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Matthias,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The reason the central &amp;quot;forgets&amp;quot; to send an enable notifications message can be caused by anything. We don&amp;#39;t know what code is running on it. For all we know the central application logic could be something like:&lt;/p&gt;
&lt;p&gt;Only enable notifications if the BLE address belongs to a specific company (since I can see from your screenshot that the device uses a vendor specific BLE address (many call them MAC address). That is why you can see &amp;quot;company name&amp;quot; followed by 3 bytes in the address field, instead of just 6 bytes in the address field.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Nonetheless, if you have the peripheral blackbox as well, did you try to connect to it using nRF Connect for Desktop -&amp;gt; Bluetooth Low Energy, and look at all the services and characteristics that it has? Do you have all those characteristics in your peripheral application?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422928?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 09:58:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c734847-9609-4297-917a-9d448f6266dc</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Yes, indeed I have both - the black-box central as well as the black-box peripheral (the one I&amp;#39;m going to substitute now).&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;After CONNECT_IND (central) and exploring the GATT profile, the peripheral has to send a special value (probably in a short opened time window). After receiving this cookie the central sends another special value, so the peripheral knows the central fits. Only this way both sides keep the connection, otherwise it will be dropped.&lt;br /&gt;&lt;br /&gt;Unfortunately my central &amp;quot;forgets&amp;quot; to enable notification - the channel, where the cookie from the peripheral is expected. &lt;br /&gt;&lt;br /&gt;The image taken from wireshark shows, how to connect successfully - both black-boxes (central and pheripheral)&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1682675845200v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;The &amp;quot;aa5501aa&amp;quot; is the cookie sent from peripheral to central. The central answers 2x with &amp;quot;aa5501bb&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422899?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 08:03:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cfab544-41cd-4617-aa37-7ca72976c880</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Matthias,&lt;/p&gt;
&lt;p&gt;I understand. Unfortunately, a black box central is more difficult than a black box peripheral.&lt;/p&gt;
&lt;p&gt;Do you have access to a black box peripheral that goes with this black box central?&lt;/p&gt;
&lt;p&gt;It sounds like you are able to connect to your central. This means that the central decides to connect to your peripheral (it is always the central that initiates the connection). How did you know what you needed in order for the central to connect?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am just trying to catch up with what you already know, and perhaps we can figure out a way to understand what your central is looking for.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422890?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 07:30:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:405a86f2-299b-4ac3-8d25-2ce365fe6501</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Hello Edvin,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;it&amp;#39;s not at all confusing, the matter is clear. Thanks for your explanations.&lt;br /&gt;Nevertheless I have to solve the problem, i.e. overcome the problems&amp;nbsp;of a buggy BLE firmware of a black-box device I cannot change.&lt;/p&gt;
&lt;p&gt;After a closer look it seems to be a time critical problem as well. Now I&amp;#39;m looking for a solution to get an event on my Pheripheral when GATT profile enumeration is initiated or is done.&lt;br /&gt;Any suggestions?&lt;/p&gt;
&lt;p&gt;Thanks - Matthias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422881?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 06:51:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:035e2c32-8d41-46a5-b37f-c2f622325640</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;gatt_req_send() is just a layer below bt_gatt_write() and all those. Just a common way to prepare and send the actual packet on over the air.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am sorry, but the issue is that in the fundamentals of Bluetooth LE, there is no way to send custom payload data without having a characteristic inside a service to attach it to.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Although BLE is a common language that many devices use, not all BLE devices work together, especially if they don&amp;#39;t know what to expect from the connected device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let us say that you somehow managed to connect a BLE mouse to a BLE keyboard. The keyboard wouldn&amp;#39;t have any place to send its&amp;#39;s keyboard data, because the mouse isn&amp;#39;t interested in it. And even if there was a way to trick the BLE stack into thinking the mouse enabled notifications on the keyboard&amp;#39;s key service, so that the keyboard started sending notifications, the mouse wouldn&amp;#39;t know what to do with that information.&lt;/p&gt;
&lt;p&gt;A computer, however, would recognize both the mouse and the keyboard, and it would enable notifications, and it would know what to do with the incoming data.&lt;/p&gt;
&lt;p&gt;I hope that made some sense, and wasn&amp;#39;t only confusing.&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422784?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2023 14:04:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5049bf7d-58c7-4ee9-b164-2a35c5fda7ad</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Would be&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;gatt_req_send()&lt;/span&gt; an opportunity?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422783?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2023 14:02:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fc3bb2a-e913-4d03-872d-b02005c66a8f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;bt_gatt_write() or bt_gatt_write_without_response() only works if there is a service/characteristic present on the central that you can write to. If it doesn&amp;#39;t have any characteristics (most centrals don&amp;#39;t have services/characteristics), then there is nowhere to address these writes.&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: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422777?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2023 13:55:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48ca8633-6306-4b33-921b-940ad55b715b</guid><dc:creator>m.foerster@imm-electronics.de</dc:creator><description>&lt;p&gt;Hello Edvin,&lt;br /&gt; &lt;br /&gt; so my guess was right - no one&amp;nbsp;wants to&amp;nbsp;receive messages if not signed in for it...&lt;br /&gt; But unfortunately this strange behavior is used to decide on connect, if both sides fit together.&lt;/p&gt;
&lt;p&gt;Since bt_gatt_notify() did not work at this place, I&amp;rsquo;ve tried&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;bt_gatt_write()&lt;/span&gt; and &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;bt_gatt_write_without_response()&lt;/span&gt; with some success. I can send my magic cookie, but with Opcode &amp;quot;Write Request&amp;quot; (0x12) and &amp;quot;Write Command&amp;quot; (0x52) when Opcode &amp;quot;Handle Value Notification&amp;quot; (0x1b) is expected.&lt;/p&gt;
&lt;p&gt;As you can see - this project made me become very familiar with your BLE Sniffer on Wireshark - this tool saved my&amp;nbsp;hole work, thanks a lot to Nordic! Next I will scrutinize all the possibilities of my black-box central device.&lt;/p&gt;
&lt;p&gt;Best regards - Matthias&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to establish notifications without a subscription?</title><link>https://devzone.nordicsemi.com/thread/422514?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2023 12:26:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8bcb3ae-125e-4f69-89b2-abc2ea736146</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;It is not possible for the peripheral to enable notifications without the central actually requesting it, as it is against the BLE specification.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am not sure why you would want to do so, as the central wouldn&amp;#39;t know what to do with, or how to handle, the incoming data either way. So even if it was possible to trick the BLE stack into believing that the central already enabled notifications, I doubt it would work&amp;nbsp;the way you expect it to work.&lt;/p&gt;
&lt;p&gt;If the case is that you have a central that you don&amp;#39;t have the source code to, it probably enables notifications if there is a certain service/characteristic present on the peripheral. You need to figure out what that peripheral service characteristic is, and then set up that very service/characteristic.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The easiest way to figure that out is if you have the peripheral that the central works with, and try to connect with that peripheral using nRF Connect for Desktop -&amp;gt; Bluetooth Low Energy, and see what services and characteristics that are present on that device.&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>