Latest 1.0.0
License MIT
Platforms tvos 10.0, ios 10.0
Frameworks CoreBluetooth, Foundation

CI Status


To run the example project, clone the repo, and run pod install from the Example directory first.



Activ5-Device is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'Activ5Device'

Use of framework

Basic funtionality

Framework initialisation

In order to initialize the framework you need to call the following function. The best please to call it is in AppDelegate or somewhere a bit before calling Bluetooth related functions.


You need also to set who is the delegate who will receive the callbacks from the frame work. This is mostly done in the ViewControllers responsible for Device connect/disconnect and the ones that are receiving data from the device. Do not forget to set that the class is implementing the A5DeviceDelegate protocol.

class ViewController: A5DeviceDelegate
    override func viewDidLoad() {
        A5DeviceManager.delegate = self

Search for devices

You need to search for devices in order to load the devices. Each time a new device has been found

A5DeviceManager.scanForDevices {
// Action when a device has been found

A delegate call is being called as well. You can choose which approach to use.

func deviceFound(device: A5Device) {
// Action when a device has been found

When the device search timeouts a delegate function is being called.

func searchCompleted() {
// Action when a device search has been completed (timed out)

Connect to a device

Connecting a device is easy. You just need to select the right one from the devices found and call connect

A5DeviceManager.connect(device: aDevice.device) // you need to call the CBDevice property of the A5Device. 

When a device has been connected the delegate function deviceConnected is going to be called.

func deviceConnected(device: A5Device) {
// Action to do when a device is connected. Probably show the user that connection is successful and then call 

Request Isometric Data from the A5 device

Isometric data start to be stream when startIsometric() is called.


The isometric data is going to be received in the delegate function didReceiveIsometric. The value received is in Newtons.

func didReceiveIsometric(device: A5Device, value: Int) {
// Action when isometric data is received

Stop receiving isometric data

In order to save device battery it is recomended to call stop() function. That way the device consumption drops to a minimum while still is being connected.


NB: After 7 minutes in stop mode the device will switch switch off
If you don’t want the device to timeout after 7 minutes you can switch on evergreen mode. This will keep the device awake.

device.evergreenMode = true

Disconnect device

Disconnecting the device happens with calling disconnect() function


After the device has been disconnected (it can happen also if the device is switched off by the user) the following delegate method is being called.

func deviceDisconnected(device: A5Device) {
// May show the user that the device has been disconnected or retry to connect if needed.

Extended documentation



var device: CBPeripheral
var name: String?
var writeCharacteristic: CBCharacteristic?
var readCharacteristic: CBCharacteristic?
var deviceDataState: A5DeviceDataState = .disconnected
var deviceVersion: String?
var evergreenMode: Bool = false



init(device: CBPeripheral, name: String? = nil, writeCharacteristic: CBCharacteristic? = nil, readCharacteristic: CBCharacteristic? = nil)

Device Communication

func sendCommand(_ command: A5Command)
func sendMessage(message: String)
func startIsometric()
func stop()
func disconnect()

Available Device States

public enum A5DeviceDataState {
case handshake
case isometric
case heartRate // Depricated
case stop
case disconnected



static let instance: A5DeviceManager
static var delegate: A5DeviceDelegate?
static let bluetoothQueue: DispatchQueue
static var devices: [String: A5Device]
static var connectedDevices: [String: A5Device]
static var options: A5DeviceManagerOptions


class func scanForDevices(searchCompleted: @escaping () -> Void)
class func connect(device: CBPeripheral)
class func send(message: String, to device: A5Device)
class func device(for peripheral: CBPeripheral) -> (key: String, value:A5Device)?


public struct A5DeviceManagerOptions {
var services: [CBUUID] = [CBUUID(string: "0x5000")]
var autoHandshake: Bool = true
var searchTimeout = 30.0


func searchCompleted()
func deviceFound(device: A5Device)
func deviceConnected(device: A5Device)
func deviceDisconnected(device: A5Device)
func didReceiveMessage(device: A5Device, message: String, type: MessageType)
func didReceiveIsometric(device: A5Device, value: Int)
func didFailToConnect(device: A5Device, error: Error?)
func didChangeBluetoothState(_ state: CBManagerState)
func bluetoothIsSwitchedOff()

Default implementations

func didFailToConnect(device: CBPeripheral, error: Error?) {}
func didReceiveMessage(device: A5Device, message: String, type: MessageType) {}
func didReceiveIsometric(device:A5Device, value: Int) {}
func didChangeBluetoothState(_ state: CBManagerState) {}
func bluetoothIsSwitchedOff() {}


martin-key, [email protected]


Activ5-Device is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "Activ5Device",
    "version": "1.0.0",
    "summary": "Framework used for connection with Activ5 Device",
    "swift_versions": "4.2",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "martinkey": "[email protected]"
    "platforms": {
        "tvos": "10.0",
        "ios": "10.0"
    "source": {
        "http": ""
    "source_files": "Activ5Device.framework/Headers/Activ5Device-Swift.h",
    "vendored_frameworks": "Activ5Device.framework",
    "frameworks": [

Pin It on Pinterest

Share This