All Projects → rhummelmose → Bluetoothkit

rhummelmose / Bluetoothkit

Licence: other
Easily communicate between iOS/OSX devices using BLE

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Bluetoothkit

Bluetonium
Bluetooth mapping in Swift
Stars: ✭ 159 (-92.16%)
Mutual labels:  bluetooth-low-energy, bluetooth, cocoapods, carthage
Multipeer
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
Stars: ✭ 170 (-91.61%)
Mutual labels:  bluetooth, cocoapods, carthage
Bluecap
iOS Bluetooth LE framework
Stars: ✭ 669 (-67%)
Mutual labels:  bluetooth-low-energy, cocoapods, carthage
Bluetoothlinux
Pure Swift Linux Bluetooth Stack
Stars: ✭ 149 (-92.65%)
Mutual labels:  bluetooth-low-energy, bluetooth
Forecastio
A Swift library for the Forecast.io Dark Sky API
Stars: ✭ 164 (-91.91%)
Mutual labels:  cocoapods, carthage
Auth0.swift
Swift toolkit for Auth0 API
Stars: ✭ 146 (-92.8%)
Mutual labels:  cocoapods, carthage
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-92.85%)
Mutual labels:  cocoapods, carthage
Zkudid
Generate and save permanent UDID with IDFV and keychain in iOS device.
Stars: ✭ 159 (-92.16%)
Mutual labels:  cocoapods, carthage
Heapinspector For Ios
Find memory issues & leaks in your iOS app without instruments
Stars: ✭ 1,819 (-10.26%)
Mutual labels:  cocoapods, carthage
Flutter reactive ble
Flutter library that handles BLE operations for multiple devices.
Stars: ✭ 155 (-92.35%)
Mutual labels:  bluetooth-low-energy, bluetooth
Apesuperhud
A simple way to display a HUD with a message or progress information in your application.
Stars: ✭ 156 (-92.3%)
Mutual labels:  cocoapods, carthage
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (-92.11%)
Mutual labels:  cocoapods, carthage
Eureka
Elegant iOS form builder in Swift
Stars: ✭ 11,345 (+459.69%)
Mutual labels:  cocoapods, carthage
Sdl ios
Get your app connected to the 🚙, make your users feel like a 🌟
Stars: ✭ 147 (-92.75%)
Mutual labels:  cocoapods, carthage
Sffocusviewlayout
UICollectionViewLayout with focused content
Stars: ✭ 1,760 (-13.17%)
Mutual labels:  cocoapods, carthage
Underlinetextfield
Simple UITextfield Subclass with state
Stars: ✭ 156 (-92.3%)
Mutual labels:  cocoapods, carthage
Airpodsbattery Monitor For Mac
Simple Widget to display your AirPods battery levels from the Mac Status bar
Stars: ✭ 165 (-91.86%)
Mutual labels:  bluetooth-low-energy, bluetooth
Node Ble
Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus
Stars: ✭ 159 (-92.16%)
Mutual labels:  bluetooth-low-energy, bluetooth
Pipkit
Picture in Picture for iOS
Stars: ✭ 140 (-93.09%)
Mutual labels:  cocoapods, carthage
Donut
Donut is a library for arranging views circularly like a donut.
Stars: ✭ 141 (-93.04%)
Mutual labels:  cocoapods, carthage

BluetoothKit

Easily communicate between iOS devices using BLE.

Build Status Cocoapods Compatible Carthage compatible

Background

Apple mostly did a great job with the CoreBluetooth API, but because it encapsulated the entire Bluetooth 4.0 LE specification, it can be a lot of work to achieve simple tasks like sending data back and forth between iOS devices, without having to worry about the specification and the inner workings of the CoreBluetooth stack.

BluetoothKit tries to address the challenges this may cause by providing a much simpler, modern, closure-based API all implemented in Swift.

Features

Common

  • More concise Bluetooth LE availability definition with enums.
  • Bluetooth LE availability observation allowing multiple observers at once.

Central

  • Scan for remote peripherals for a given time interval.
  • Continuously scan for remote peripherals for a give time interval, with an in-between delay until interrupted.
  • Connect to remote peripherals with a given time interval as time out.
  • Receive any size of data without having to worry about chunking.

Peripheral

  • Start broadcasting with only a single function call.
  • Send any size of data to connected remote centrals without having to worry about chunking.

Requirements

  • iOS 8.0+ / OSX 10.10+
  • Xcode 7.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.38.2 is required to build BluetoothKit. It adds support for Xcode 7, Swift 2.0 and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To integrate BluetoothKit into your Xcode project using CocoaPods, specify it in your Podfile:

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

pod 'BluetoothKit', '~> 0.2.0'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate BluetoothKit into your Xcode project using Carthage, specify it in your Cartfile:

github "rasmusth/BluetoothKit" ~> 0.4.0

Manual

Add the BluetoothKit project to your existing project and add BluetoothKit as an embedded binary of your target(s).

Usage

Below you find some examples of how the framework can be used. Accompanied in the repository you find an example project that demonstrates a usage of the framework in practice. The example project uses SnapKit and CryptoSwift both of which are great projects. They're bundled in the project and it should all build without further ado.

Common

Make sure to import the BluetoothKit framework in files that use it.

import BluetoothKit

Peripheral

Prepare and start a BKPeripheral object with a configuration holding UUIDs uniqueue to your app(s) and an optional local name that will be broadcasted. You can generate UUIDs in the OSX terminal using the command "uuidgen".

let peripheral = BKPeripheral()
peripheral.delegate = self
do {
	let serviceUUID = NSUUID(UUIDString: "6E6B5C64-FAF7-40AE-9C21-D4933AF45B23")!
	let characteristicUUID = NSUUID(UUIDString: "477A2967-1FAB-4DC5-920A-DEE5DE685A3D")!
	let localName = "My Cool Peripheral"
	let configuration = BKPeripheralConfiguration(dataServiceUUID: serviceUUID, dataServiceCharacteristicUUID: 	characteristicUUID, localName: localName)
	try peripheral.startWithConfiguration(configuration)
	// You are now ready for incoming connections
} catch let error {
	// Handle error.
}

Send data to a connected remote central.

let data = "Hello beloved central!".dataUsingEncoding(NSUTF8StringEncoding)
let remoteCentral = peripheral.connectedRemoteCentrals.first! // Don't do this in the real world :]
peripheral.sendData(data, toRemoteCentral: remoteCentral) { data, remoteCentral, error in
	// Handle error.
	// If no error, the data was all sent!
}

Central

Prepare and start a BKCentral object with a configuration holding the UUIDs you used to configure your BKPeripheral object.

let central = BKCentral()
central.delegate = self
central.addAvailabilityObserver(self)
do {
	let serviceUUID = NSUUID(UUIDString: "6E6B5C64-FAF7-40AE-9C21-D4933AF45B23")!
	let characteristicUUID = NSUUID(UUIDString: "477A2967-1FAB-4DC5-920A-DEE5DE685A3D")!
	let configuration = BKConfiguration(dataServiceUUID: serviceUUID, dataServiceCharacteristicUUID: characteristicUUID)
	try central.startWithConfiguration(configuration: configuration)
	// Once the availability observer has been positively notified, you're ready to discover and connect to peripherals.
} catch let error {
	// Handle error.
}

Scan for peripherals for 3 seconds.

central.scanWithDuration(3, progressHandler: { newDiscoveries in
	// Handle newDiscoveries, [BKDiscovery].
}, completionHandler: { result, error in
	// Handle error.
	// If no error, handle result, [BKDiscovery].
})

Scan continuously for 3 seconds at a time, with an in-between delay of 3 seconds.

central.scanContinuouslyWithChangeHandler({ changes, discoveries in
	// Handle changes to "availabile" discoveries, [BKDiscoveriesChange].
	// Handle current "available" discoveries, [BKDiscovery].
	// This is where you'd ie. update a table view.
}, stateHandler: { newState in
	// Handle newState, BKCentral.ContinuousScanState.
	// This is where you'd ie. start/stop an activity indicator.
}, duration: 3, inBetweenDelay: 3, errorHandler: { error in
	// Handle error.
})

Connect a peripheral with a connection attempt timeout of 3 seconds.

central.connect(remotePeripheral: peripherals[indexPath.row]) { remotePeripheral, error in
	// Handle error.
	// If no error, you're ready to receive data!
}

License

BluetoothKit is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].