|
12 | 12 | ## Summary
|
13 | 13 | This is a [SwiftyGPIO](https://github.com/uraimo/SwiftyGPIO) based library for communicating with XBee radios in **API mode**, with support for Series 2 **only**.
|
14 | 14 |
|
15 |
| -This is a **work in progress**. I started coding the library for a project I am currently working on, so, as of now, it only supports RX/TX and Transmit Status API Frames. If you want to contribute to this noble cause, please submit a PR and I will be more than happy to review it and merge it :smile:. |
| 15 | +This is a **work in progress**. I started coding the library for a project I am currently working on, so, as of now, it only supports ATCommand, ATCommandResponse, Tx, Rx, and Transmit Status API Frames. If you want to contribute to this noble cause, please submit a PR and I will be more than happy to review it and merge it :smile:. |
16 | 16 |
|
17 | 17 | For more information regarding the RF module, you can consult its [datasheet](https://www.digi.com/resources/documentation/digidocs/pdfs/90002002.pdf).
|
18 | 18 |
|
@@ -44,14 +44,14 @@ The UART pins on the RaspberryPi (pin 14 TXD, pin 15 RXD) need to be enabled via
|
44 | 44 | ## Supported Boards
|
45 | 45 | Every board supported by [SwiftyGPIO](https://github.com/uraimo/SwiftyGPIO): RaspberryPis, BeagleBones, C.H.I.P., etc...
|
46 | 46 |
|
47 |
| -To use this library, you'll need a Linux ARM board running [Swift 4.x](https://github.com/uraimo/buildSwiftOnARM) 🚗. |
| 47 | +To use this library, you'll need a Linux ARM board running [Swift 5.x](https://github.com/uraimo/buildSwiftOnARM) 🚗. |
48 | 48 |
|
49 |
| -The example below will use a Raspberry Pi 3B+ board, but you can easily modify the example to use one of the other supported boards. A full working demo project for the RaspberryPi3B+ is available in the **Example** directory. |
| 49 | +The examples below will use a Raspberry Pi 3B+ board, but you can easily modify the examples to use one of the other supported boards. Full working demo projects for the RaspberryPi3B+ are available under the **Examples** directory. |
50 | 50 |
|
51 | 51 | ## Installation
|
52 |
| -First of all, makes sure your board is running **Swift 4.x** ⚠️! |
| 52 | +First of all, makes sure your board is running **Swift 5.x** ⚠️! |
53 | 53 |
|
54 |
| -Since Swift 4.x supports Swift Package Manager, you only need to add SwiftXBee as a dependency in your project's `Package.swift` file: |
| 54 | +Since Swift 5.x supports Swift Package Manager, you only need to add SwiftXBee as a dependency in your project's `Package.swift` file: |
55 | 55 |
|
56 | 56 | ```swift
|
57 | 57 | let package = Package(
|
@@ -86,6 +86,30 @@ let xbee = SwiftyXBee()
|
86 | 86 | ```
|
87 | 87 | This initializer defaults to `.RaspberryPi3` as the selected board and serial connection with `speed: .S9600`, `bitsPerChar: .Eight`, `stopBits: .One`, and `parity: .None)`.
|
88 | 88 |
|
| 89 | +### AT Command Packet |
| 90 | +AT-type commands can be sent via API frames to configure your local radio. They can query the settings on the local radio or set parameters. These are all the same commands you typed in transparent/command mode. |
| 91 | + |
| 92 | +For this example, the local radio's *Node Identifier* parameter is been set and read. |
| 93 | + |
| 94 | +Setting AT Command parameter: |
| 95 | +``` swift |
| 96 | +// The new Node Identifier |
| 97 | +let nodeIdentifier = "XBee Test" |
| 98 | + |
| 99 | +xbee.sendATCommand(.addressing(.ni(.write(nodeIdentifier))), frameId: .sendNoACK) |
| 100 | +``` |
| 101 | +Reading AT Command parameter: |
| 102 | +```swift |
| 103 | +xbee.sendATCommand(.addressing(.ni(.read))) |
| 104 | + |
| 105 | +do { |
| 106 | + let atCommandResponse = try xbee.readATCommandResponse() |
| 107 | + print("AT Command Response received: \(atCommandResponse.frameData.commandData) = \(atCommandResponse.frameData.commandData.string)") |
| 108 | +} catch let error { |
| 109 | + print("Error receiving packet: \(error)") |
| 110 | +} |
| 111 | +``` |
| 112 | + |
89 | 113 | ### Transmit Packets
|
90 | 114 | There a several different types of transmit (TX) packets available. But as mentioned above, as of now, the library only allows **Transmit Request** packets to be sent. A list of all TX packets can be found in the API [documentation](https://www.digi.com/resources/documentation/digidocs/pdfs/90002002.pdf). All classes that end in "Request" are TX packets.
|
91 | 115 | ```swift
|
|
0 commit comments