public interface

ECGSensorManager

mason.hardware.platform.ECGSensorManager

Summary

Nested Classes
class ECGSensorManager.Command All posible commands for ECG  
class ECGSensorManager.SensorType TODO: SensorType should not be tied to specific ecg platform  
Public Methods
abstract void dispatch(SensorEvent event)
Parsing and dispatch to the specific callback previously registered with registerEventListener(ECGEventListener) depending on the event type.
abstract int execute(int command)
Send a specific command for execution.
abstract int executeWithParameter(int command, CommandParameter data)
Send a specific command that requires aditional input parameters for execution.
abstract void registerEventListener(ECGEventListener listener)
Register callbacks for all available events from ECG.

Public Methods

public abstract void dispatch (SensorEvent event)

Parsing and dispatch to the specific callback previously registered with registerEventListener(ECGEventListener) depending on the event type.

public abstract int execute (int command)

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.

public abstract int executeWithParameter (int command, CommandParameter data)

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.

public abstract void registerEventListener (ECGEventListener listener)

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:

  • Create and register with the ECGSensorManager an ECGEventListener in order to process all data comming from the ECG sensor
  • On the specific OnSensorChanged event call the 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