From 2011f3fd526c786a21e1248b37aa404e81414ede Mon Sep 17 00:00:00 2001 From: Yuuki Nishiyama Date: Wed, 21 Nov 2018 17:37:08 +0200 Subject: [PATCH] Supports Swift 4.2 --- .gitignore | 6 +- .travis.yml | 8 +- .../project.pbxproj | 143 ------------------ ...k.ios.sensor.magnetometer-Example.xcscheme | 4 +- .../contents.xcworkspacedata | 10 ++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../ViewController.swift | 3 +- README.md | 64 +++++++- ...eframework.ios.sensor.magnetometer.podspec | 11 +- .../Classes/MagnetometerSensor.swift | 10 +- 10 files changed, 100 insertions(+), 167 deletions(-) create mode 100644 Example/com.awareframework.ios.sensor.magnetometer.xcworkspace/contents.xcworkspacedata create mode 100644 Example/com.awareframework.ios.sensor.magnetometer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.gitignore b/.gitignore index 182890d..27d6f4b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,7 @@ Carthage/Build # Note: if you ignore the Pods directory, make sure to uncomment # `pod install` in .travis.yml # +Example/Pods +Example/Podfile.lock Pods/ -Podfile.lock -Pods/ -com.awareframework.ios.sensor.magnetometer.xcworkspace/ +# com.awareframework.ios.sensor.magnetometer.xcworkspace/ diff --git a/.travis.yml b/.travis.yml index 900d3eb..fdf7945 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,13 @@ # * https://www.objc.io/issues/6-build-tools/travis-ci/ # * https://github.com/supermarin/xcpretty#usage -osx_image: xcode7.3 +osx_image: xcode10.1 language: objective-c # cache: cocoapods -# podfile: Example/Podfile +podfile: Example/Podfile # before_install: # - gem install cocoapods # Since Travis is not always on latest version # - pod install --project-directory=Example script: -- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/com.awareframework.ios.sensor.magnetometer.xcworkspace -scheme com.awareframework.ios.sensor.magnetometer-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty -- pod lib lint +- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/com.awareframework.ios.sensor.magnetometer.xcworkspace -scheme com.awareframework.ios.sensor.magnetometer-Example -sdk iphonesimulator10.0 ONLY_ACTIVE_ARCH=NO | xcpretty +- pod lib lint --allow-warnings diff --git a/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/project.pbxproj b/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/project.pbxproj index 54d5867..ec82d3e 100644 --- a/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/project.pbxproj +++ b/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/project.pbxproj @@ -13,20 +13,8 @@ 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; - EC9A302C2C3B43D61E6B5BC7 /* Pods_com_awareframework_ios_sensor_magnetometer_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB709AD932E4A928BCB2DF6E /* Pods_com_awareframework_ios_sensor_magnetometer_Tests.framework */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 607FACC81AFB9204008FA782 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 607FACCF1AFB9204008FA782; - remoteInfo = com.awareframework.ios.sensor.magnetometer; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ 2C681EC0B5C4CDAB17028DA2 /* Pods-com.awareframework.ios.sensor.magnetometer_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-com.awareframework.ios.sensor.magnetometer_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-com.awareframework.ios.sensor.magnetometer_Example/Pods-com.awareframework.ios.sensor.magnetometer_Example.debug.xcconfig"; sourceTree = ""; }; 573841A55D19959ECE4D61CF /* Pods-com.awareframework.ios.sensor.magnetometer_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-com.awareframework.ios.sensor.magnetometer_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-com.awareframework.ios.sensor.magnetometer_Tests/Pods-com.awareframework.ios.sensor.magnetometer_Tests.debug.xcconfig"; sourceTree = ""; }; @@ -37,13 +25,11 @@ 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - 607FACE51AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = com.awareframework.ios.sensor.magnetometer_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 7BCE819A2BB2741BBEF600BF /* Pods-com.awareframework.ios.sensor.magnetometer_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-com.awareframework.ios.sensor.magnetometer_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-com.awareframework.ios.sensor.magnetometer_Example/Pods-com.awareframework.ios.sensor.magnetometer_Example.release.xcconfig"; sourceTree = ""; }; 8133371A7168CAA5F8EEB9B1 /* Pods_com_awareframework_ios_sensor_magnetometer_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_com_awareframework_ios_sensor_magnetometer_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BDC90A7A9793C44838ED7DA2 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; - DB709AD932E4A928BCB2DF6E /* Pods_com_awareframework_ios_sensor_magnetometer_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_com_awareframework_ios_sensor_magnetometer_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E18E8290A0994804BC467432 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; F3FD70760ABD87C95B1DD33C /* com.awareframework.ios.sensor.magnetometer.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = com.awareframework.ios.sensor.magnetometer.podspec; path = ../com.awareframework.ios.sensor.magnetometer.podspec; sourceTree = ""; }; FF9714D43A4F9A99E9E8B4BF /* Pods-com.awareframework.ios.sensor.magnetometer_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-com.awareframework.ios.sensor.magnetometer_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-com.awareframework.ios.sensor.magnetometer_Tests/Pods-com.awareframework.ios.sensor.magnetometer_Tests.release.xcconfig"; sourceTree = ""; }; @@ -58,14 +44,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 607FACE21AFB9204008FA782 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - EC9A302C2C3B43D61E6B5BC7 /* Pods_com_awareframework_ios_sensor_magnetometer_Tests.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -84,7 +62,6 @@ isa = PBXGroup; children = ( 8133371A7168CAA5F8EEB9B1 /* Pods_com_awareframework_ios_sensor_magnetometer_Example.framework */, - DB709AD932E4A928BCB2DF6E /* Pods_com_awareframework_ios_sensor_magnetometer_Tests.framework */, ); name = Frameworks; sourceTree = ""; @@ -105,7 +82,6 @@ isa = PBXGroup; children = ( 607FACD01AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Example.app */, - 607FACE51AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Tests.xctest */, ); name = Products; sourceTree = ""; @@ -181,25 +157,6 @@ productReference = 607FACD01AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Example.app */; productType = "com.apple.product-type.application"; }; - 607FACE41AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "com.awareframework.ios.sensor.magnetometer_Tests" */; - buildPhases = ( - A50EE5426899D5AAF748DB85 /* [CP] Check Pods Manifest.lock */, - 607FACE11AFB9204008FA782 /* Sources */, - 607FACE21AFB9204008FA782 /* Frameworks */, - 607FACE31AFB9204008FA782 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 607FACE71AFB9204008FA782 /* PBXTargetDependency */, - ); - name = com.awareframework.ios.sensor.magnetometer_Tests; - productName = Tests; - productReference = 607FACE51AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Tests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -215,11 +172,6 @@ DevelopmentTeam = FH352PYMNC; LastSwiftMigration = 0900; }; - 607FACE41AFB9204008FA782 = { - CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0900; - TestTargetID = 607FACCF1AFB9204008FA782; - }; }; }; buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "com.awareframework.ios.sensor.magnetometer" */; @@ -236,7 +188,6 @@ projectRoot = ""; targets = ( 607FACCF1AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Example */, - 607FACE41AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Tests */, ); }; /* End PBXProject section */ @@ -252,38 +203,9 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 607FACE31AFB9204008FA782 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - A50EE5426899D5AAF748DB85 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-com.awareframework.ios.sensor.magnetometer_Tests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; E309A54DD9271BB65959C2CC /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -352,24 +274,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 607FACE11AFB9204008FA782 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 607FACCF1AFB9204008FA782 /* com.awareframework.ios.sensor.magnetometer_Example */; - targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ 607FACD91AFB9204008FA782 /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -523,46 +429,6 @@ }; name = Release; }; - 607FACF31AFB9204008FA782 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 573841A55D19959ECE4D61CF /* Pods-com.awareframework.ios.sensor.magnetometer_Tests.debug.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = Tests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/com.awareframework.ios.sensor.magnetometer_Example.app/com.awareframework.ios.sensor.magnetometer_Example"; - }; - name = Debug; - }; - 607FACF41AFB9204008FA782 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = FF9714D43A4F9A99E9E8B4BF /* Pods-com.awareframework.ios.sensor.magnetometer_Tests.release.xcconfig */; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - INFOPLIST_FILE = Tests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/com.awareframework.ios.sensor.magnetometer_Example.app/com.awareframework.ios.sensor.magnetometer_Example"; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -584,15 +450,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "com.awareframework.ios.sensor.magnetometer_Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 607FACF31AFB9204008FA782 /* Debug */, - 607FACF41AFB9204008FA782 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 607FACC81AFB9204008FA782 /* Project object */; diff --git a/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/xcshareddata/xcschemes/com.awareframework.ios.sensor.magnetometer-Example.xcscheme b/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/xcshareddata/xcschemes/com.awareframework.ios.sensor.magnetometer-Example.xcscheme index b1180f7..dc0bd31 100644 --- a/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/xcshareddata/xcschemes/com.awareframework.ios.sensor.magnetometer-Example.xcscheme +++ b/Example/com.awareframework.ios.sensor.magnetometer.xcodeproj/xcshareddata/xcschemes/com.awareframework.ios.sensor.magnetometer-Example.xcscheme @@ -1,6 +1,6 @@ + + + + + + diff --git a/Example/com.awareframework.ios.sensor.magnetometer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/com.awareframework.ios.sensor.magnetometer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/com.awareframework.ios.sensor.magnetometer.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/com.awareframework.ios.sensor.magnetometer/ViewController.swift b/Example/com.awareframework.ios.sensor.magnetometer/ViewController.swift index 3896197..24d38c6 100644 --- a/Example/com.awareframework.ios.sensor.magnetometer/ViewController.swift +++ b/Example/com.awareframework.ios.sensor.magnetometer/ViewController.swift @@ -24,7 +24,8 @@ class ViewController: UIViewController { } class Observer:MagnetometerObserver { - func onChanged(data: MagnetometerData) { + + func onDataChanged(data: MagnetometerData) { print(data) } } diff --git a/README.md b/README.md index 795f926..389864e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# com.aware.ios.sensor.magnetometer +# Aware Magnetometer -[![CI Status](https://img.shields.io/travis/tetujin/com.aware.ios.sensor.magnetometer.svg?style=flat)](https://travis-ci.org/tetujin/com.aware.ios.sensor.magnetometer) +[![CI Status](https://img.shields.io/travis/awareframework/com.aware.ios.sensor.magnetometer.svg?style=flat)](https://travis-ci.org/awareframework/com.aware.ios.sensor.magnetometer) [![Version](https://img.shields.io/cocoapods/v/com.aware.ios.sensor.magnetometer.svg?style=flat)](https://cocoapods.org/pods/com.aware.ios.sensor.magnetometer) [![License](https://img.shields.io/cocoapods/l/com.aware.ios.sensor.magnetometer.svg?style=flat)](https://cocoapods.org/pods/com.aware.ios.sensor.magnetometer) [![Platform](https://img.shields.io/cocoapods/p/com.aware.ios.sensor.magnetometer.svg?style=flat)](https://cocoapods.org/pods/com.aware.ios.sensor.magnetometer) @@ -10,6 +10,7 @@ To run the example project, clone the repo, and run `pod install` from the Example directory first. ## Requirements +iOS 10 or later ## Installation @@ -25,6 +26,63 @@ pod 'com.aware.ios.sensor.magnetometer' import com_aware_ios_sensor_magnetometer ``` +## Public functions +### MagnetometerSensor + ++ `init(config:MagnetometerSensor.Config?)` : Initializes the magnetometer sensor with the optional configuration. ++ `start()`: Starts the gyroscope sensor with the optional configuration. ++ `stop()`: Stops the service. + +### MagnetometerSensor.Config + +Class to hold the configuration of the sensor. + +#### Fields ++ `sensorObserver: MagnetometerObserver`: 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: Boolean` Sensor is enabled or not. (default = `false`) ++ `debug: Boolean` enable/disable logging to Xcode console. (default = `false`) ++ `label: String` Label for the data. (default = "") ++ `deviceId: String` Id of the device that will be associated with the events and the sensor. (default = "") ++ `dbEncryptionKey` Encryption key for the database. (default = `null`) ++ `dbType: Engine` Which db engine to use for saving data. (default = `Engine.DatabaseType.NONE`) ++ `dbPath: String` Path of the database. (default = "aware_gyroscope") ++ `dbHost: String` Host for syncing the database. (default = `null`) + +## Broadcasts + +### Fired Broadcasts + ++ `MagnetometerSensor.ACTION_AWARE_GYROSCOPE` fired when gyroscope saved data to db after the period ends. + +### Received Broadcasts + ++ `MagnetometerSensor.ACTION_AWARE_MAGNETOMETER_START`: received broadcast to start the sensor. ++ `MagnetometerSensor.ACTION_AWARE_MAGNETOMETER_STOP`: received broadcast to stop the sensor. ++ `MagnetometerSensor.ACTION_AWARE_MAGNETOMETER_SYNC`: received broadcast to send sync attempt to the host. ++ `MagnetometerSensor.ACTION_AWARE_MAGNETOMETER_SET_LABEL`: received broadcast to set the data label. Label is expected in the `MagnetometerSensor.EXTRA_LABEL` field of the intent extras. + +## Data Representations + +### Magnetometer Data + +Contains the raw sensor data. + +| Field | Type | Description | +| --------- | ------ | --------------------------------------------------------------- | +| x | Double | value of X axis | +| y | Double | value of Y axis | +| z | Double | value of Z axis | +| 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 | Raw timezone offset of the device | +| os | String | Operating system of the device (ex. ios) | + + ## Example usage ```swift var magnetometer = MagnetometerSensor.init( MagnetometerSensor.Config().apply{ config in @@ -36,7 +94,7 @@ magnetometer?.start() ```swift class Observer:MagnetometerObserver { - func onChanged(data:MagnetometerData){ + func onDataChanged(data:MagnetometerData){ // Your code here.. } } diff --git a/com.awareframework.ios.sensor.magnetometer.podspec b/com.awareframework.ios.sensor.magnetometer.podspec index 64fb8dd..3e245df 100644 --- a/com.awareframework.ios.sensor.magnetometer.podspec +++ b/com.awareframework.ios.sensor.magnetometer.podspec @@ -8,8 +8,8 @@ Pod::Spec.new do |s| s.name = 'com.awareframework.ios.sensor.magnetometer' - s.version = '0.1.0' - s.summary = 'A short description of com.awareframework.ios.sensor.magnetometer.' + s.version = '0.1.1' + s.summary = 'com.awareframework.ios.sensor.magnetometer (Magnetometer) is a sensor module for Aware Framework.' # This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? @@ -17,7 +17,8 @@ Pod::Spec.new do |s| # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! - s.description = <<-DESC +com.awareframework.ios.sensor.magnetometer (Magnetometer) is a sensor module for Aware Framework. This module provides calibrated magnetic fields. This data is provided by Core Motion’s sensor fusion algorithms. https://developer.apple.com/documentation/coremotion/cmmotionmanager + TODO: Add long description of the pod here. DESC @@ -30,7 +31,7 @@ TODO: Add long description of the pod here. s.ios.deployment_target = '10.0' - s.swift_version = '4.0' + s.swift_version = '4.2' s.source_files = 'com.awareframework.ios.sensor.magnetometer/Classes/**/*' @@ -39,7 +40,7 @@ TODO: Add long description of the pod here. # } # s.public_header_files = 'Pod/Classes/**/*.h' - s.frameworks = 'CoreMotion' #'UIKit', 'MapKit' + s.frameworks = 'CoreMotion' # s.dependency 'AFNetworking', '~> 2.3' s.dependency 'com.awareframework.ios.sensor.core' diff --git a/com.awareframework.ios.sensor.magnetometer/Classes/MagnetometerSensor.swift b/com.awareframework.ios.sensor.magnetometer/Classes/MagnetometerSensor.swift index bbb90ed..ea452d6 100644 --- a/com.awareframework.ios.sensor.magnetometer/Classes/MagnetometerSensor.swift +++ b/com.awareframework.ios.sensor.magnetometer/Classes/MagnetometerSensor.swift @@ -19,7 +19,7 @@ extension Notification.Name{ } public protocol MagnetometerObserver{ - func onChanged(data:MagnetometerData) + func onDataChanged(data:MagnetometerData) } extension MagnetometerSensor{ @@ -51,14 +51,14 @@ public class MagnetometerSensor: AwareSensor { public var sensorObserver: MagnetometerObserver? = nil /** - * Magnetometer interval in hertz per second: e.g. + * Magnetometer frequency in hertz per second: e.g. * * 0 - fastest * 1 - sample per second * 5 - sample per second * 20 - sample per second */ - public var interval: Int = 5 + public var frequency: Int = 5 /** * Period to save data in minutes. (optional) @@ -96,7 +96,7 @@ public class MagnetometerSensor: AwareSensor { public override func start() { if self.motion.isMagnetometerAvailable && !self.motion.isMagnetometerActive{ - self.motion.magnetometerUpdateInterval = 1.0/Double(CONFIG.interval) + self.motion.magnetometerUpdateInterval = 1.0/Double(CONFIG.frequency) self.motion.startMagnetometerUpdates(to: .main) { (magnetometerData, error) in if let magData = magnetometerData { let x = magData.magneticField.x @@ -123,7 +123,7 @@ public class MagnetometerSensor: AwareSensor { data.eventTimestamp = Int64(magData.timestamp*1000) if let observer = self.CONFIG.sensorObserver { - observer.onChanged(data: data) + observer.onDataChanged(data: data) } self.dataBuffer.append(data)