com.awareframework.ios.sensor.significantmotion 0.5.0

com.awareframework.ios.sensor.significantmotion 0.5.0

tetujinyuuki.nishiyama 维护。



  • Yuuki Nishiyama

AWARE: Significant Motion

CI Status Version License Platform

此传感器用于跟踪设备的重大运动。如果可用,当设备静止时,还由 AWARE 内部使用以节省电量。SignificantMotionSensor.Observer 允许程序员在检测到重大运动时采取行动。

基于: sensorplatforms/open-sensor-platform/significantmotiondetector.c

要求

iOS 10 或更高版本

安装

com.awareframework.ios.sensor.significantmotion 通过 CocoaPods 提供。

  1. 要安装它,只需将以下行添加到 Podfile 中
pod 'com.awareframework.ios.sensor.significantmotion'
  1. 将 com.awareframework.ios.sensor.barometer 库导入到您的源代码中。
import com_awareframework_ios_sensor_significantmotion

公共函数

显著的动传感器

  • init(config:SignificantMotioneSensor.Config?) : 使用可选配置初始化显著的动传感器。
  • start(): 使用可选配置启动显著的动传感器。
  • stop(): 停止服务。

SignificantMotioneSensor.Config

用于保存传感器配置的类。

字段

  • sensorObserver: SignificantMotionObserver: 用于实时数据更新的回调。
  • enabled: Boolean 传感器是否启用。 (默认 = false)
  • debug: Boolean 启用/禁用记录到 Logcat。 (默认 = false)
  • label: String 数据的标签。 (默认 = "")
  • deviceId: String 将与事件和传感器相关联的设备的ID。 (默认 = "")
  • dbEncryptionKey 数据库的加密密钥。 (默认 = null)
  • dbType: Engine 保存数据时使用哪个数据库引擎。 (默认 = Engine.DatabaseType.NONE)
  • dbPath: String 数据库路径。 (默认 = "aware_significantmotion")
  • dbHost: String 同步数据库的宿主。 (默认 = null)

广播

已发射的广播

  • SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_STARTED 当有显著的动时触发。
  • SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_ENDED 当显著的动结束时触发。

接收广播

  • SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_START:接收启动传感器的广播。
  • SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_STOP:接收停止传感器的广播。
  • SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_SYNC:接收发送同步尝试到主机的广播。
  • SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_SET_LABEL:接收设置数据标签的广播。标签期望在intent extras的SignificantMotionSensor.EXTRA_LABEL字段中。

数据表示

显著运动数据

包含运动变化。

字段 类型 描述
moving 布尔型 指示是否检测到显著运动。
label 字符串 可自定义的标签。对于数据校准或可追溯性很有用。
deviceId 字符串 AWARE 设备 UUID
label 字符串 可自定义的标签。对于数据校准或可追溯性很有用。
timestamp 长整型 自1970年以来的unix时间毫秒数
timezone 整型 设备的时区
os 字符串 设备的操作系统 (例如:android)

示例使用

    let sensor = SignificantMotionSensor.init(SignificantMotionSensor.Config().apply{config in
        config.sensorObserver = Observer()
        config.debug  = true
        config.dbType = .REALM
    })
    sensor.start()
    sensor.stop()
}
class Observer:SignificantMotionObserver{
    func onSignificantMotionStart() {
        // Your code here...
    }

    func onSignificantMotionEnd() {
        // Your code here...
    }
}

作者

Yuuki Nishiyama,[email protected]

许可协议

版权所有(C)2021 AWARE移动上下文仪器中间件/框架 (http://www.awareframework.com)

遵循Apache License 2.0协议(“许可协议”);除非符合许可协议,否则不得使用此文件。您可以在以下地址获取许可协议的副本:

https://apache.ac.cn/licenses/LICENSE-2.0 除非适用法律要求或书面同意,否则根据本许可协议发布的软件均按“现况”基础提供,不提供任何保证或条件,无论是明示的还是暗示的。请参阅许可协议了解具体权利和限制。