Giter Club home page Giter Club logo

awsense's Introduction

AWSense

This library provides basic sensing functionality for the Apple Watch.

At the moment, it allows easy access to the following sensors from within a Watchkit App:

  • Heart rate
  • Raw Accelerometer
  • Device Motion:
    • Gyroscope
    • Linear Accelerometer
    • Gravity
    • Attitude

AWSense is separated in two parts:

  • AWSense Core: The Core is a standalone library for the Apple Watch which can be incorperated in Apple Watch apps for eased access to sensing data. It does not provice functionalities to transfer the sensing data to the phone.
  • AWSense Connect: This framework builds on top of the AWSence Core and provides communication functionalities for session management and data transmission.

This schematic highlights the architecture of the AWSense framework:

schematics of architecture

AWSense Core

The AWSense Core provides functionality to ease the sensor access on the Apple Watch.

WatchKit App and Phone App Requirements

Your WatchKit App needs the following requirements:

  • HealthKit entitlement and Heart Rate has to be enabled as a HealthKit source
  • If the sensing should continue in the background, your app needs to allow workout processing as background mode
  • The WatchKit App has to link the AWSenseShared and AWSenseWatch targets

Although, the sensing takes place and the watch and not data is transmitted to the phone, the Phone App needs the following requirements:

  • HealthKit entitlement and Heart Rate has to be enabled as a HealthKit source
  • The Motion Usage Description has to be added to the app's Info.plist to allow access of motion sensors on the watch

(Have a look in our Wiki on how to setup your app for those things)

Subscribing to Sensor Events in the Watch App

Withing your WatchKit app, the class handeling sensor events has to be conform to the AWSSensorEventHandler protocol.

This event handler is subscribed to the sensors via the AWSSensorManager singleton:

let manager = AWSSensorManager.sharedInstance
        
if(sensors![.heart_rate]! && manager.isSensorAvailable(sensor: .heart_rate)){
  manager.register(eventhandler: self, with: .heart_rate)
  manager.startSensing(with: .heart_rate)
}

AWSense Connect

AWSense Connect builds on top of the AWSense Core and provides functionality to ease wearable sensing sessions managed by the phone.

WatchKit App and Phone App Requirements

Your WatchKit App needs the following requirements:

  • HealthKit entitlement and Heart Rate has to be enabled as a HealthKit source
  • For continuous sensing and data transmission, your app needs to allow workout processing as background mode
  • The WatchKit App has to link the AWSenseShared, AWSenseWatch and AWSenseConnectWatch targets

Your Phone App needs the following requirements:

  • HealthKit entitlement and Heart Rate has to be enabled as a HealthKit source
  • The Motion Usage Description has to be added to the app's Info.plist to allow access of motion sensors on the watch
  • The Phone App has to link the AWSenseShared and AWSenseConnectPhone targets

(Have a look in our Wiki on how to setup your app for those things)

Watch App

Withing your WatchKit app, the class handeling the sensing session events has to be conform to the SensingEventHandler protocol.

This event handler is subscribed to the sensors via the SensingSessionManager singleton:

SensingSessionManager.instance.subscribe(handler: self)

Even though you do ignore those events in your WatchKit App, this step is nessecary to internally initialise the required fuctionalities.

Phone App

Withing your Phone app, the class handeling sensor events has to be conform to the RemoteSensingEventHandler protocol.

This event handler is subscribed to the sensors via the SessionManager singleton:

let manager = SessionManager.sharedInstance
        
do {
    try sessionManager.startSensingSession(withName: "test_session", 
                                           configuration: [.heart_rate, .accelerometer], 
                                           sensorSettings: [RawAccelerometerSensorSettings(withIntervall_Hz: 1.0)])
            
}catch let error as Error{
    print(error)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.