Remote sensing services overview

Remote sensing service is built on the Internet (uniconnect) and sensor (smartsense) above services across the remote service of the machine.The service links of end devices can be read sensor information to the local, currently only support mobile end read watch end sensor information.

Summary of the sensor

Based on the Android devices have built-in sensors for measuring movement, direction, and various environmental conditions.These sensors can provide the raw data and ensure its accuracy and high accuracy.For example, a weather application may use the equipment of temperature sensor and humidity sensor to calculate and report environmental status.Also, a healthy application will pass step gauge sensor and the heart rate sensor consume more calories and heart rate of the current values.

The IWOP platform support remote sensor is divided into three categories:

 
Motion sensor:
 
The sensors used to measure the current body or arm movement.This kind of sensor including a motion sensor, signal sensor and step gauge sensor.
 
 
These sensors used to measure the health of the body, currently only supports the heart rate sensor.
 
Environmental sensors:
 
The sensors used to measure various environmental parameters, such as air temperature, pressure and humidity, illumination.This category includes barometer, hygrometer, thermometer.

You can visit the end equipment on all supported sensor, using the IWOP remote service to obtain the original data sensor.Sensor service provides classes and interfaces, help you to perform a variety of sensors related tasks.For example, you can use the sensor service does the following:

  • Sure there is some sensors in the remote device.
  • The change of the sensor monitor remote devices.

Remote sensor is introduced

The remote sensor support list

IWOP remote sensing services currently supports the following sensors:

 
TYPE_HEART_RATE:
 
Heart rate sensor, measuring the heart rate.
 
TYPE_GESTURE:
 
Signal sensor, measure the current state of the hand (hand/wave, etc.).
 
TYPE_MOTION:
 
Motion sensors, measuring the body motion (run/ride, etc.).
 
TYPE_STEP_COUNTER:
 
Step gauge sensor, the measuring steps.
 
TYPE_RELATIVE_HUMIDITY:
 
Environmental humidity sensor, humidity measurement environment.
 
TYPE_AMBIENT_TEMPERATURE:
 
Ambient temperature sensor, temperature measurement.
 
TYPE_PRESSURE:
 
Air pressure sensor, measurement environment atmosphere.

Remote sensing services framework

More than you can visit the sensor by IWOP remote sensing services framework, service in com. Ingenic. Iwds. Smartsense package, which contains the following classes and interfaces:

 
RemoteSensorServiceManager:
 
You can use this class to obtain the remote device instance of different kinds of sensors.This class provides access to remote sensor, the method of registration and cancellation of the remote sensor event listeners.This class also provides the gestures and constant motion sensors, remote sensors is used to compare the corresponding report data.
 
RemoteSensorListener:
 
To end sensor listener service, service users to monitor the end equipment sensor is available, the result is directly decided the local can access the remote sensors information.
 
Sensor:
 
Sensor as an example, this class provides methods can be used to determine the sensor information.
 
SensorEvent:
 
Service use this class to create a sensor event object, which provides a sensor data, type, and the accuracy of the data.
 
SensorEventListener:
 
Sensor event listener, two events can be monitored, sensors precision numerical change and change.

Access to the equipment sensors

IWOP remote sensor service framework allows you to easily get at run time to end equipment sensor and the sensor list.

In order to access to the equipment, first need to connect to a remote service sensor.You need to instantiate ServiceClient and pass SERVICE_REMOTE_SENSOR as parameters.Such as:


private ServiceClient mClient = new ServiceClient(this,ServiceManagerContext.SREVICE_REMOTE_SENSOR); 
...
mClient.connect();

Then, after the service connection must be registered remote sensing equipment service listener and wait for the remote service is available, then you can get the remote equipment sensors and sensor list:


private RemoteSensorServiceManager mService;
...
public void onConnected() {
    mService = (RemoteSensorServiceManager) mClient.getServiceManagerContext();
    mService.registerRemoteListener(mRemoteListener);
}

private RemoteSensorListener mRemoteListener = new RemoteSensorListener(){
    @Override
    public void onSensorAvailable(ArrayList<Sensor> sensorList) {
        if (sesorList != null) {
            // Remote sensor available
            // Here you can get default sensor
            mSensor = mService.getDefaultSensor(Sensor.TYPE_HEART_RATE);
            if (mSensor != null) {
                // Success! There's a heart rate sensor.
            } else {
                // Failure! No heart rate sensor.
            }
        } else {
            // Remote sensor unavailable
        }
    }
};

Monitoring sensor events

Sensor data in order to monitor the remote equipment you need SersorEventListener listener events in two callback methods: onSensorChanged () and onAccuracyChanged ().Sensor service will be back this two methods when:

 
The sensor precision changes:
 
This case will be called onAccuracyChanged () method, now only supports the heart rate sensor processing precision of the change.
 
At present there are two kinds of report of the heart rate sensor precision values, ACCURACY_HEART_RATE_UNAVALIABLE and ACCURACY_HEART_RATE_AVALIABLE respectively. The two described the working state of the heart rate sensor, respectively.
 
When reporting accuracy for ACCURACY_HEART_RATE_UNAVALIABLE, said the heart rate sensor working status is not normal, it is possible that the heart rate is not normal human body skin contact, or discomfort to measure heart rate watch worn timeout.When reporting accuracy for ACCURACY_HEART_RATE_AVALIABLE, said the heart rate sensor working state is normal, watch to wear is good, the heart rate measurement data is reported (usually within 1 ~ 5 s report heart rate data).
 
The sensor data changes:
 
This case will call the onSensorChanged () method, incoming SensorEvent as parameters, the SensorEvent contains a new sensor data and the timestamp event occurs.

The following is a typical usage:


public class RemoteSensorActivity implements ConnectionCallbacks,
        SensorEventListener {
    private RemoteSensorServiceManager mService;
    private ServiceClient mClient;
    private Sensor mSensor;

    @Override
    public final void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mClient = new ServiceClient(this,
                ServiceManagerContext.SERVICE_REMOTE_SENSOR, this);
    }

    @Override
    public void onConnected() {
        mService = (RemoteSensorServiceManager) mClient.getServiceManagerContext();
        mService.registerRemoteListener(mRemoteListener);
    }

    @Override
    public void onDisconnected(boolean unexpected) {
        mService.unregisterRemoteListener(mRemoteListener);
        mService.unregisterListener(mListener, mSensor);
    }

    private RemoteSensorListener mRemoteListener = new RemoteSensorListener() {
        @Override
        public void onSensorAvailable(ArrayList sensorList) {
            if (sesorList != null) {
                // Remote sensor available
                mSensor = mService.getDefaultSensor(Sensor.TYPE_HEART_RATE);
                mService.registerListener(this, mSensor,
                        RemoteSensorServiceManager.SENSOR_DELAY_NORMAL);
            } else {
                // Remote sensor unavailable
            }
        }
    };

    @Override
    public final void onAccuracyChanged(Sensor sensor, int accuracy) {
        // Do something here if sensor accuracy changes.
    }

    @Override
    public final void onSensorChanged(SensorEvent event) {
        float heartRate = event.values[0];
        // Do something with this sensor value.
    }

    @Override
    protected void onResume() {
        super.onResume();
        mClient.connect();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mClient.disconnect();
    }
}

The above example using RemoteSensorServiceManager. SENSOR_DELAY_NORMAL registration as parameters to sensor event listeners, but current sensing delay specified service does not support the event.Example in onResume () and onPause connect/disconnect sensing service, so you don't need to use the remote sensor equipment timely cancellation of the listener closed sensors can cut that amount in the remote device。