Skip to content
An iOS library for eSense (Earable Computing Platform)
Swift Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ESense Add a sample application for data visualization Aug 21, 2019
Example
.gitignore Initial commit Aug 15, 2019
.swift-version Fix minor issues regarding .podspec and Travis Aug 17, 2019
.travis.yml
ESense.podspec Fix a disconnect error and add a sample application for data visualiz… Aug 20, 2019
LICENSE First commit (Version 0.1.0) Aug 17, 2019
README.md
_Pods.xcodeproj Initial commit Aug 15, 2019

README.md

eSense iOS Library

CI Status Version License Platform

This library allows us to use eSense (earable computing platform) on iOS easily. This library is inspired by eSense library for Android which is developed by Pervasive Systems team at Nokia Bell Labs Cambridge.

Example

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

Requirements

iOS 10 or later

Installation

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

pod 'ESense'

Use eSense Library

  1. Import the library in your iOS project
import ESense
  1. Implement ESenseconnectionListener on your class
extension YOUR_CLASS:ESenseconnectionListener{
    func onDeviceFound(_ manager: ESenseManager) {
        // YOUR CODE HERE
    }

    func onDeviceNotFound(_ manager: ESenseManager) {
        // YOUR CODE HERE
    }

    func onConnected(_ manager: ESenseManager) {
        manager.setDeviceReadyHandler { device in
            manager.removeDeviceReadyHandler()
            // YOUR CODE HERE
        }
    }

    func onDisconnected(_ manager: ESenseManager) {
        // YOUR CODE HERE
    }
}
  1. Create the ESenseManager instance

Prepare a variable for ESenseManager as a class or static variable.

var manager:ESenseManager? = nil

Initialize an ESenseManager class using a target device name and a class which is implemented the ESenseconnectionListener.

manager = ESenseManager(deviceName: "YOUR_ESENSE_NAME", listener: YOUR_CLASS)
  1. Scan and connect an eSense device

For scanning an eSense device, you can use scan(timeout) method. If ESenseManager finds an eSense device, onDeviceFind(manager) method on ESenseconnectionListener is called.

manager.scan(timeout: SECOND)
  1. Handling sensor update events

After connecting the device, you can listen the sensor change events via ESenseSensrListener. Please implement ESenseSensorListener in your class just like below.

extension YOUR_CLASS:ESenseSensorListener{
    func onSensorChanged(_ evt: ESenseEvent) {
        // YOUR CODE HERE
    }
}

Finally, you can set the ESenseSensorListener into your ESenseManager with a sampling late (hz).

manager.registerSensorListener(YOUR_CLASS, hz: 10)
  1. Handling eSense device events

In addition, you can handle eSense other events (battery, button, and config related events) using ESenseEventListener. Please implement ESenseEventListener on your class.

extension YOUR_CLASS:ESenseEventListener{
    func onBatteryRead(_ voltage: Double) {
        // YOUR CODE HERE
    }

    func onButtonEventChanged(_ pressed: Bool) {
        // YOUR CODE HERE
    }

    func onAdvertisementAndConnectionIntervalRead(_ minAdvertisementInterval: Int, _ maxAdvertisementInterval: Int, _ minConnectionInterval: Int, _ maxConnectionInterval: Int) {
        // YOUR CODE HERE
    }

    func onDeviceNameRead(_ deviceName: String) {
        // YOUR CODE HERE
    }

    func onSensorConfigRead(_ config: ESenseConfig) {
        // YOUR CODE HERE
    }

    func onAccelerometerOffsetRead(_ offsetX: Int, _ offsetY: Int, _ offsetZ: Int) {
        // YOUR CODE HERE
    }
}

Also, you can registe the implement listener by registerEventListener(ESenseEventListener) method on ESenseManager class.

manager.registerEventListener(self)

Executing read operations will trigger events on ESenseEventListener.

manager.getBatteryVoltage()
manager.getAccelerometerOffset()
manager.getDeviceName()
manager.getSensorConfig()
manager.getAdvertisementAndConnectionInterval()

Author

eSense Library for iOS is developed by Yuuki Nishiyama (The University of Tokyo, Japan) yuukin@iis.u-tokyo.ac.jp.

License

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

You can’t perform that action at this time.