<?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>iOS nRF Toolbox tx/rx characteristic?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27901/ios-nrf-toolbox-tx-rx-characteristic</link><description>Hi all,
I&amp;#39;m using the nRF iOS Toolbox as a reference to design an app.
Can someone please help me in terms of which swift code file I need to use to read and write data to the nrf51 ble devices?
I have modified the uuids to match my device and can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Dec 2017 05:55:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27901/ios-nrf-toolbox-tx-rx-characteristic" /><item><title>RE: iOS nRF Toolbox tx/rx characteristic?</title><link>https://devzone.nordicsemi.com/thread/110099?ContentTypeID=1</link><pubDate>Thu, 07 Dec 2017 05:55:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:006115ca-0545-46d8-8429-92a10527a0b6</guid><dc:creator>nar0909</dc:creator><description>&lt;p&gt;Thanks mate. Really detailed and clear.
Appreciate your response.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iOS nRF Toolbox tx/rx characteristic?</title><link>https://devzone.nordicsemi.com/thread/110098?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2017 09:24:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:382fe28b-f08e-4df2-92e9-82f54ae20ff5</guid><dc:creator>Mostafa Berg</dc:creator><description>&lt;p&gt;I&amp;#39;ll update my answer with that info as it&amp;#39;s too long for a comment!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iOS nRF Toolbox tx/rx characteristic?</title><link>https://devzone.nordicsemi.com/thread/110097?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2017 22:14:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f9658ee-7340-4e3d-beb2-3e974210378b</guid><dc:creator>nar0909</dc:creator><description>&lt;p&gt;Hi Mostafa,
Thanks for your response.
I was wondering which statement I should be using if I wanted to read and write to the nrf51822 BLE in each view controller scene?
Can you please advice if I use the same NORBluetoothManager in all my view controller scenes. Can I do that?
Thanks
nar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: iOS nRF Toolbox tx/rx characteristic?</title><link>https://devzone.nordicsemi.com/thread/110096?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2017 12:02:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc8bd43-c582-4ad2-9ce9-f6fef9b3152d</guid><dc:creator>Mostafa Berg</dc:creator><description>&lt;p&gt;Good evening nar0909 !&lt;/p&gt;
&lt;p&gt;If you head towards &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/blob/master/nRF%20Toolbox/BluetoothManager/NORBluetoothManager.swift#L128"&gt;this link&lt;/a&gt;, you&amp;#39;ll see the UART handling is done in the &lt;code&gt;BluetoothManager&lt;/code&gt; class&lt;/p&gt;
&lt;p&gt;if you have any more questions just ask :), hope this helps&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Added info to show actual usage for reading and writing&lt;/p&gt;
&lt;p&gt;To write, simply convert your string to bytes as &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/blob/master/nRF%20Toolbox/BluetoothManager/NORBluetoothManager.swift#L148"&gt;we do here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then use the method &lt;code&gt;writeValue(...)&lt;/code&gt; on the target &lt;code&gt;CBPeripheral&lt;/code&gt;, an example can be seen &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/blob/master/nRF%20Toolbox/BluetoothManager/NORBluetoothManager.swift#L202"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When it comes to reading, you&amp;#39;ll receive changes as notifications that will call the target &lt;code&gt;CBPeripheral&lt;/code&gt;&amp;#39;s &lt;code&gt;didUpdateValue(...)&lt;/code&gt;, this method can be found &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/blob/master/nRF%20Toolbox/BluetoothManager/NORBluetoothManager.swift#L389"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You will receive the data as bytes and you are responsible to convert them back to a String, you can see how we do that &lt;a href="https://github.com/NordicSemiconductor/IOS-nRF-Toolbox/blob/master/nRF%20Toolbox/BluetoothManager/NORBluetoothManager.swift#L397-L413"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You may use the &lt;code&gt;BluetoothManager&lt;/code&gt; class directly to do that, and access it from all the views that you require, but I would recommend to reimplement it by hand to get a really good understanding on how the whole service works. &lt;code&gt;BluetoothManager&lt;/code&gt; is there only as an example reference and might be a bit too much or over complicate things depending on the solution you&amp;#39;re working on. but feel free to use it as it is ofcourse.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>