Latest 0.1.1
Homepage https://github.com/olavblj/SwiftyRFDuino
License MIT
Platforms ios 11.0
Authors

version
swift-version
license
platform

Installation

Cocoapods

SwiftyRFDuino is installed through Cocoapods.

To integrate SwiftyRFDuino add pod 'SwiftyRFDuino' to your Podfile.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'SwiftyRFDuino'
end

Then run pod install from your project directory.

Usage

WARNING: The code in the current Example directory will not necessarily work with the current version of the Pod. It is recommended to not rely too heavily on it.

Basic Setup

import SwiftyRFDuino

class MyViewController: UIViewController {

    // Always use the shared instance of RFDuinoManager
    var manager = RFDuinoManager.shared

    override func viewDidLoad() {
        super.viewDidLoad()

        self.manager.delegate = self
        self.manager.startScanningForRFDuinos()
        self.manager.logLevel = .all

    }
}

RFDuinoManagerDelegate methods

extension MyViewController: RFDuinoManagerDelegate {
    func didDiscover(_ rfduino: RFDuino, manager: RFDuinoManager) {
        // Handle this (or ignore it)
    }

    func didConnect(to rfduino: RFDuino, manager: RFDuinoManager) {
        // Handle this (or ignore it)
    }

    func showAlert(title: String, message: String){
        // Notify the user of an event (example below)
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }
}

RFDuinoDelegate methods

extension MyViewController: RFDuinoDelegate {
  func didTimeout(_ rfduino: RFDuino) {
      // Handle this (or ignore it)
  }

  func didDisconnect(_ rfduino: RFDuino) {
      // Handle this (or ignore it)
  }

  func didDiscover(_ rfduino: RFDuino) {
      // Handle this (or ignore it)
  }

  func didDiscoverServices(_ rfduino: RFDuino) {
      // Handle this (or ignore it)
  }

  func didDiscoverCharacteristics(_ rfduino: RFDuino) {
      // Handle this (or ignore it)
  }

  func didSendData(_ rfduino: RFDuino, forCharacteristic: CBCharacteristic, error: Error?) {
      // Handle this (or ignore it)
  }

  func didReceiveData(_ rfduino: RFDuino, data: Data?) {
      // Handle this (or ignore it)
  }
}

Interface

RFDuinoManager methods

func startScanningForRFDuinos()

func stopScanningForRFDuinos()

func connect(to rfduino: RFDuino)

func disconnect(from rfduino: RFDuino)

RFDuino methods

func discoverServices()

func send(data: Data)

Latest podspec

{
    "name": "SwiftyRFDuino",
    "version": "0.1.1",
    "summary": "An iOS library that allows easy communication with RFDuinos",
    "description": "Contains a RFDuinoManager class and a RFDuino class as a nice abstraction for dealing with connecting and communicating with RFDuinos over Bluetooth.",
    "homepage": "https://github.com/olavblj/SwiftyRFDuino",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Olav Ljosland": "[email protected]"
    },
    "source": {
        "git": "https://github.com/olavblj/SwiftyRFDuino.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source_files": "Source/*.swift",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This