AWARE: Barometer
This sensor module allows us to manage air-pressure data provided by iOS CMAltimeter.
Requirements
iOS 10 or later
Installation
com.awareframework.ios.sensor.barometer is available through CocoaPods.
- To install it, simply add the following line to your Podfile:
pod 'com.awareframework.ios.sensor.barometer'- Import com.awareframework.ios.sensor.barometer library into your source code.
import com_awareframework_ios_sensor_barometerPublic functions
BarometerSensor
init(config:BarometerSensor.Config): Initializes the baromter sensor with the optional configuration.start(): Starts the barometer sensor with the optional configuration.stop(): Stops the service.
BarometerSensor.Config
Class to hold the configuration of the sensor.
Fields
sensorObserver: BarometerObserver: Callback for live data updates.frequency: Int: Data samples to collect per second (Hz). (default = 5)period: Double: Period to save data in minutes. (default = 1)threshold: Double: If set, do not record consecutive points if change in value is less than the set value.enabled: BooleanSensor is enabled or not. (default =false)debug: Booleanenable/disable logging toLogcat. (default =false)label: StringLabel for the data. (default = "")deviceId: StringId of the device that will be associated with the events and the sensor. (default = "")dbEncryptionKeyEncryption key for the database. (default =null)dbType: EngineWhich db engine to use for saving data. (default =Engine.DatabaseType.NONE)dbPath: StringPath of the database. (default = "aware_barometer")dbHost: StringHost for syncing the database. (default =null)
Data Representations
Barometer Sensor
Contains the raw sensor data.
| Field | Type | Description |
|---|---|---|
| pressure | Double | The recorded pressure, in kilopascals (kPs). |
| label | String | Customizable label. Useful for data calibration or traceability |
| deviceId | String | AWARE device UUID |
| label | String | Customizable label. Useful for data calibration or traceability |
| timestamp | Int64 | Unixtime milliseconds since 1970 |
| timezone | Int | Timezone of the device |
| os | String | Operating system of the device (ex. android) |
Example usage
var barometerSensor = BarometerSensor.init(BarometerSensor.Config().apply{config in
config.sensorObserver = Observer()
config.debug = true
config.dbType = .REALM
})
barometerSensor?.start()
barometerSensor?.stop()class Observer:BarometerObserver{
func onDataChanged(data: BarometerData) {
// Your code here..
}
}Author
Yuuki Nishiyama, [email protected]
Related Links
Apple | CMAltimeter Apple | CMAltitudeData Apple | Core Motion
License
Copyright (c) 2018 AWARE Mobile Context Instrumentation Middleware/Framework (http://www.awareframework.com)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.