Latest 1.0.2
Homepage https://github.com/ish2028/MSeriesBle
License MIT
Platforms ios 9.0
Frameworks UIKit, CoreBluetooth
Authors

Getting Started

This library uses notification dispatch mechanism to receive data. Start by getting a shared instance of MSBluetooth.

let bluetooth = MSBluetooth.sharedInstance

Scanning starts automatically, so call this as soon as possible to start listening for bikes. MSBluetooth keeps track of discovered machines in a array of tuples (machineBroadcast: MSBLEMachineBroadcast, lastReceviedTime: Date). You can access this array using

bluetooth.discoveredBikes

The notification object is an instance of MSBluetooth so that you can access any public varaibles you need.

Discovering Machines

Notifies you when a new machine has been discovered.

NotificationCenter.default.addObserver(
            forName: NSNotification.Name(MSBluetooth.BluetoothConnectionNotifications.BluetoothConnectionDidDiscoverMachine ),
            object: bluetooth,
            queue: queue)
        { notification in
            self.discoveredMachine(notification: notification)
        }

Updates from discovered machines

Notifies you when a machine is no longer transmitting data.

NotificationCenter.default.addObserver(
            forName: NSNotification.Name(MSBluetooth.BluetoothConnectionNotifications.BluetoothConnectionUpdateDiscoveredMachines ),
            object: bluetooth,
            queue: queue)
        { notification in
            self.discoveredMachine(notification: notification)
        }

Listening to a specific bike

To listen to a specific bike simply set the focusedBikeId on MSBluetooth and register to receive notifications using

NotificationCenter.default.addObserver(
            forName: NSNotification.Name(MSBluetooth.BluetoothConnectionNotifications.BluetoothConnectionDidReceiveMachineBroadcast),
            object: bluetooth,
            queue: queue)
        { notification in
            self.updateData(notification: notification)
        }

notification.userInfo contains a broadcast key that is an instance of MSBLEMachineBroadcast. This object contains the parsed data from the bike.

Installation

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

pod 'MSeriesBle'

Author

[email protected]

License

MSeriesBle is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MSeriesBle",
    "version": "1.0.2",
    "summary": "Listens for Keiser's M Series Bike line.",
    "description": "Uses BLE to scan for M Series bikes and stores the machines so we can listen to specific machines.",
    "homepage": "https://github.com/ish2028/MSeriesBle",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ish2028/MSeriesBle.git",
        "tag": "1.0.2"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "MSeriesBle/Classes/**/*",
    "frameworks": [
        "UIKit",
        "CoreBluetooth"
    ],
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This