<?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>Swift 3 - CBPeripheral.services nil problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19477/swift-3---cbperipheral-services-nil-problem</link><description>Hi, I was trying to create an NUS (Nordic UART Service) application for iOS 10 devices using Swift 3. 
 I was testing with my 
 
 
 iPhone 6 Plus 64GB (iOS 10.2.1) 
 
 
 PCA10040 v1.1 that has NUS peripheral example from SDK 12.1 + S132 v3.0 </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Feb 2017 08:08:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19477/swift-3---cbperipheral-services-nil-problem" /><item><title>RE: Swift 3 - CBPeripheral.services nil problem</title><link>https://devzone.nordicsemi.com/thread/75655?ContentTypeID=1</link><pubDate>Mon, 20 Feb 2017 08:08:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbead217-38b6-4c67-8c4c-e61699b8b9eb</guid><dc:creator>Mostafa Berg</dc:creator><description>&lt;p&gt;No, those are the characteristics, you should scan only for the service first, using that UUID:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;`6E400001-B5A3-F393-E0A9-E50E24DCCA9E` //UART Service
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After that service is discovered, you should discover characteristics for this service, you may use a &lt;code&gt;nil&lt;/code&gt; filter to discover all, or specify only the RX/TX characteristic UUIDs like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;`6E400002-B5A3-F393-E0A9-E50E24DCCA9E` //RX Characteristic
`6E400003-B5A3-F393-E0A9-E50E24DCCA9E` //TX Characteristic
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;after those are discovered, you may proceed to write/read form those characteristics.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Swift 3 - CBPeripheral.services nil problem</title><link>https://devzone.nordicsemi.com/thread/75654?ContentTypeID=1</link><pubDate>Sun, 19 Feb 2017 14:00:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13c3f6e6-bb4b-4beb-a5cf-a408ef74fadc</guid><dc:creator>MANGO</dc:creator><description>&lt;p&gt;Hi, Mostafa. Thanks for your guidance.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;You should specify the services you&amp;#39;re interested in discovering
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Does this mean I have to specify the UUID of NUS TX and RX, which are&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;6e400002-b5a3-f393-e0a9-e50e24dcca9e // RX UUID
6e400003-b5a3-f393-e0a9-e50e24dcca9e // TX UUID
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Swift 3 - CBPeripheral.services nil problem</title><link>https://devzone.nordicsemi.com/thread/75653?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 13:24:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4924ad89-7e16-49ab-983c-42d8b3306fd9</guid><dc:creator>Mostafa Berg</dc:creator><description>&lt;p&gt;You are  on the right track, but you are still missing the service and characteristic discovery steps.&lt;/p&gt;
&lt;p&gt;When you connect to a peripheral, you should call &lt;code&gt;discoverServices&lt;/code&gt;, and when you get the callback to &lt;code&gt;didDiscoverServices&lt;/code&gt;, the &lt;code&gt;services&lt;/code&gt; property of your &lt;code&gt;CBPeripheral&lt;/code&gt; will be populated.&lt;/p&gt;
&lt;p&gt;Afterwards, you should discover characteristics for each service using the &lt;code&gt;discoverCharacteristics&lt;/code&gt; method, you will then get a callback to &lt;code&gt;didDiscoverCharacteristics&lt;/code&gt;, at this point, your &lt;code&gt;CBPeriphreal&lt;/code&gt; will include all the Services/Characteristics. without those steps, it&amp;#39;ll all remain &lt;code&gt;Nil&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Tips: You should specify the services you&amp;#39;re interested in discovering, leaving this filter &lt;code&gt;Nil&lt;/code&gt; will work, but is discouraged by Apple.&lt;/p&gt;
&lt;p&gt;And &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/blob/2d14b2f850a64238e09d7add0356d850479afbe8/nRF%20Toolbox/BluetoothManager/NORBluetoothManager.swift#L265"&gt;here is the code&lt;/a&gt; that can walk you through how the &lt;code&gt;nRFToolbox&lt;/code&gt; app does it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Swift 3 - CBPeripheral.services nil problem</title><link>https://devzone.nordicsemi.com/thread/75651?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 12:20:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebf71955-138b-411f-b295-b25d2890075e</guid><dc:creator>MANGO</dc:creator><description>&lt;p&gt;Hi, Bjørn.&lt;/p&gt;
&lt;p&gt;It seems that the &lt;code&gt;centralManagerDidSelectPeripheral&lt;/code&gt; calls &lt;code&gt;connectPeripheral&lt;/code&gt; in &lt;code&gt;NORBluetoothManager.swift&lt;/code&gt; while connecting with the peripheral.&lt;/p&gt;
&lt;p&gt;Where can I find the code about UART service discovery and read/write?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Swift 3 - CBPeripheral.services nil problem</title><link>https://devzone.nordicsemi.com/thread/75652?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 09:46:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5ffc1f1-84ea-441c-956d-4d4a61099d5c</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I recommend that you take a look at the nRF Toolbox app source code, found &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox"&gt;here&lt;/a&gt; on our GitHub page. You can find the code for the UART module &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/tree/master/nRF%20Toolbox/UART"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>