<?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 tell which service is connected from the BLE event parameters of nRF51 peripheral</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11526/how-to-tell-which-service-is-connected-from-the-ble-event-parameters-of-nrf51-peripheral</link><description>I have several services on a nRF51 peripheral, and would like to have different initialization based on which service is being connected to. The related code is below: 
 static void on_ble_evt(ble_evt_t * p_ble_evt)
{
 switch (p_ble_evt-&amp;gt;header.evt_id</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Jan 2016 14:06:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11526/how-to-tell-which-service-is-connected-from-the-ble-event-parameters-of-nrf51-peripheral" /><item><title>RE: How to tell which service is connected from the BLE event parameters of nRF51 peripheral</title><link>https://devzone.nordicsemi.com/thread/43577?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2016 14:06:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9ac2d1f-629c-487e-8262-36026efa1b31</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I assume that you want to turn off unneeded hardware and services, so that your device is not wasting resources and powering hardware it does not need. If this is not the case, or if you have more details on what you are doing and what is your goal, feel free to extend your question or explain further in the comments.&lt;/p&gt;
&lt;p&gt;As already answered by Wojtek, you can not know at the time of connection what services is of interest to the central. There is no mechanism in BLE for knowing this on initial connection.&lt;/p&gt;
&lt;p&gt;What you can do, is to wait for the central to read a characteristic (thereby knowing the service containing that characteristic is of interest). You can also set up your characteristics with notification, and rely on the central to enable notifications on the characteristics of services that it wants to use.&lt;/p&gt;
&lt;p&gt;Depending on your application you may also consider to make a service designed to select what other services should be updated, or to include with your services a characteristic to enable/disable the service. Do note that these last options would not work with standard services and/or generic centrals, so if used they should be reserved for your own custom services only.&lt;/p&gt;
&lt;p&gt;Regards, Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to tell which service is connected from the BLE event parameters of nRF51 peripheral</title><link>https://devzone.nordicsemi.com/thread/43576?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2016 20:33:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0879424-0f11-4dfe-bc9a-10c385920020</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;You don&amp;#39;t connect to a service - you connect to device.&lt;/p&gt;
&lt;p&gt;You can make some initialization ex. after enabling notifications on characteristics or something similar.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>