| mason.hardware.platform.ECGSensorManager |
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ECGSensorManager.Command | All posible commands for ECG | ||||||||||
| ECGSensorManager.SensorType | TODO: SensorType should not be tied to specific ecg platform | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Parsing and dispatch to the specific callback previously registered with
registerEventListener(ECGEventListener)
depending on the event type.
| |||||||||||
Send a specific command for execution.
| |||||||||||
Send a specific command that requires aditional input parameters
for execution.
| |||||||||||
Register callbacks for all available events from ECG.
| |||||||||||
Parsing and dispatch to the specific callback previously registered with
registerEventListener(ECGEventListener)
depending on the event type.
Send a specific command for execution. Used for commands that do not required aditional input parameters. On success, the result information would be sent through onSensorChanged() of SensorEventListener registered by ECG_USER_CONTROL sensor
| Parameters | |
|---|---|
command |
int: command to be executed, ECGSensorManager.Command |
| Returns | |
|---|---|
int |
return the seqid on success or -1 on failure. |
Send a specific command that requires aditional input parameters for execution. On success, the result information would be sent through onSensorChanged() of SensorEventListener registered by ECG_USER_CONTROL sensor
| Parameters | |
|---|---|
command |
int: command to be executed, ECGSensorManager.Command |
data |
CommandParameter: additional data to be added to the execution,
see CommandParameter |
| Returns | |
|---|---|
int |
return the seqid on success or -1 on failure. |
Register callbacks for all available events from ECG. By register this listener the dispatch and parsing for different events is simplified for the user. This is the recomended way of using the Mason Hardware framework:
ECGEventListener in order to process all data
comming from the ECG sensor
dispatch(SensorEvent)
in order to obtain the parsed data.
ECGEventListener mSensorEventListener = new ECGEventListener () {
...
@Override
public void HandleHeartRate(ECGHeartRate ecgHeartRate) {
// Process ECGHeartRate data here
}
@Override
public void HandleUserPresence(ECGUserPresence ecgUserPresence) {
// Process ECGUserPresence data here
}
@Override
public void HandleGetVersion(ECGFwVersion ecgFwVersion) {
// Process ECGFwVersion data here
}
...
};
...
private SensorEventListener mECGSensorDataEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
ecgManager.dispatch(event);
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
};
...
SensorManager mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
Sensor sensorData = mSensorManager.getDefaultSensor(ecgManager.getSensorType(ECGSensorManager.GenericSensorType.ECG_SENSORS_DATA));
mSensorManager.registerListener(mECGSensorDataEventListener, sensorData, SensorManager.SENSOR_DELAY_NORMAL);
ECGSensorManager ecgManager = MasonHardwareFramework.get(getContext(), ECGSensorManager.class);
ecgManager.registerEventListener(mSensorEventListener);
...
| Parameters | |
|---|---|
listener |
ECGEventListener: The object containing callbacks to process all ECG data
events when available
|