Skip to content

Commit 500bbfb

Browse files
committed
Documentation update.
1 parent 5834f37 commit 500bbfb

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ nRF8001-Swift
33

44
**nRF8001-Swift** was written by **[Michael Teeuw](https://twitter.com/michmich)**
55

6-
## What is it?
6+
# What is it?
77
While working on one of my Arduino projects, I was in the need for a simple wrapper for communication with the [Adafruit Bluefruit LE nRF8001 Breakout](https://www.adafruit.com/products/1697).
88

99
Since I was unable to find one (especially one that was Swift-ready) I wrote a Swift-wrapper myself. It is based on a [Bluefruit LE Connect](https://github.com/adafruit/Bluefruit_LE_Connect).
1010

1111
It has all the basic needs for basic two way communication and is easy to implement.
1212

1313
![Bluefruit LE nRF8001 Breakout](https://www.adafruit.com/images/970x728/1697-04.jpg)
14-
*Image Courtesy of [Adafruit](https://www.adafruit.com/products/1697)*
14+
*Image Courtesy of [Adafruit](https://www.adafruit.com/products/1697).*
1515

16-
## How to use
16+
# How to use
1717
Add the [NRFManager.swift](https://github.com/MichMich/nRF8001-Swift/blob/master/nRF8001-Swift/NRFManager.swift) file to your project and use the following implementation:
1818

19+
##Initialization
20+
1921
Use the shared instance:
2022

2123
```Swift
@@ -68,6 +70,7 @@ let nrfClosureExample = NRFManager(
6870
)
6971
```
7072

73+
###Properties
7174
After initialization, it's possible to (re)set the following properties:
7275

7376
- `nrfManager.delegate` to set the delegate.
@@ -91,22 +94,43 @@ Additionally, the following properties are read-only:
9194
## Instance methods
9295
A NRFManager can receive the following method calls:
9396

94-
- `nrfManager.connect()` to start looking for a connection. Only necessary when `autoConnect` is set to `false`.
97+
```Swift
98+
nrfManager.connect()
99+
```
100+
Start looking for a connection. Only necessary when `autoConnect` is set to `false`.
95101

96-
- `nrfManager.disconnect()` to disconnect from the nRF8001 device. Note that when `autoConnect` is set to `true`, the NRFManager will be an annoying prick and start looking for an new connection instantly ...
102+
```Swift
103+
nrfManager.disconnect()
104+
```
105+
Disconnect from the nRF8001 device. Note that when `autoConnect` is set to `true`, the NRFManager will be an annoying prick and start looking for an new connection instantly ...
97106

98-
- `nrfManager.writeString(string:String) -> Bool` to send a String to the nRF8001 device. It will return a Bool to tell you if it was possible to send it. (If there is no current connection, this will return `false` in all other cases this will return `true`.)
107+
```Swift
108+
nrfManager.writeString(string:String) -> Bool
109+
```
110+
Send a String to the nRF8001 device. It will return a Bool to tell you if it was possible to send it. (If there is no current connection, this will return `false` in all other cases this will return `true`.)
99111

100-
- `nrfManager.writeData(data:NSData) -> Bool` to send raw data (NSData) to the nRF8001 device. It will return a Bool to tell you if it was possible to send it. (If there is no current connection, this will return `false` in all other cases this will return `true`.)
112+
```Swift
113+
nrfManager.writeData(data:NSData) -> Bool
114+
```
115+
Send raw data (NSData) to the nRF8001 device. It will return a Bool to tell you if it was possible to send it. (If there is no current connection, this will return `false` in all other cases this will return `true`.)
101116

102117
## Delegate methods
103118
The following methods are part of the NRFManagerDelegate protocol:
104119

105-
- `nrfDidConnect(nrfManager:NRFManager)` is called when the NRFManager connects to the nRF8001 module. The `nrfManager` variable will contain a reference to the NRFManager instance which connected.
120+
```Swift
121+
nrfDidConnect(nrfManager:NRFManager)
122+
```
123+
Called when the NRFManager connects to the nRF8001 module. The `nrfManager` variable will contain a reference to the NRFManager instance which connected.
106124

107-
- `nrfDidDisconnect(nrfManager:NRFManager)` is called when the NRFManager disconnect from the nRF8001 module. The `nrfManager` variable will contain a reference to the NRFManager instance which disconnected.
125+
```Swift
126+
nrfDidDisconnect(nrfManager:NRFManager)
127+
```
128+
Called when the NRFManager disconnect from the nRF8001 module. The `nrfManager` variable will contain a reference to the NRFManager instance which disconnected.
108129

109-
- `nrfReceivedData(nrfManager:NRFManager, data:NSData, string:String)` is called when the NRFManager receives data from the nRF8001 module. The `nrfManager` variable will contain a reference to the NRFManager instance which received data. `data` will contain the raw data, `string` will contain the string representation of the received data.
130+
```Swift
131+
nrfReceivedData(nrfManager:NRFManager, data:NSData, string:String)
132+
```
133+
Called when the NRFManager receives data from the nRF8001 module. The `nrfManager` variable will contain a reference to the NRFManager instance which received data. `data` will contain the raw data, `string` will contain the string representation of the received data.
110134

111135
## Delegates AND Closures?!
112136
The reason I implemented both is because I was unable to decide what the best approach is. Personally I tend to prefer the delegate route.
@@ -187,6 +211,8 @@ class ViewController: UIViewController, NRFManagerDelegate {
187211
}
188212
```
189213

214+
You can check out the example project to see how it works. It includes both the delegate and closure usage.
215+
190216
## Yeah, cool! But how do I connect my Bluefruit Breakout Board?
191217

192218
Check Adafruit's [awesome tutorial](https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout) on how to use the Bluefruit Breakout Board. You can use the echo example sketch to test out nRF8001-Swift.

0 commit comments

Comments
 (0)