-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from GeoTecINIT/local-collection
Local collection example
- Loading branch information
Showing
8 changed files
with
246 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/src/main/java/es/uji/geotec/wearossensorsdemo/command/CollectionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package es.uji.geotec.wearossensorsdemo.command; | ||
|
||
import es.uji.geotec.wearossensors.sensor.WearSensor; | ||
|
||
public interface CollectionCommand { | ||
void executeStart(WearSensor sensor); | ||
void executeStop(WearSensor sensor); | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/es/uji/geotec/wearossensorsdemo/command/LocalCollectionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package es.uji.geotec.wearossensorsdemo.command; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import es.uji.geotec.backgroundsensors.collection.CollectionConfiguration; | ||
import es.uji.geotec.backgroundsensors.service.manager.ServiceManager; | ||
import es.uji.geotec.wearossensors.sensor.WearSensor; | ||
import es.uji.geotec.wearossensors.services.WearSensorRecordingService; | ||
|
||
public class LocalCollectionCommand implements CollectionCommand { | ||
|
||
private ServiceManager serviceManager; | ||
|
||
public LocalCollectionCommand(Context context) { | ||
this.serviceManager = new ServiceManager(context, WearSensorRecordingService.class); | ||
} | ||
@Override | ||
public void executeStart(WearSensor sensor) { | ||
CollectionConfiguration config = new CollectionConfiguration( | ||
sensor, | ||
android.hardware.SensorManager.SENSOR_DELAY_GAME, | ||
sensor == WearSensor.HEART_RATE || sensor == WearSensor.LOCATION ? 1 : 50 | ||
); | ||
this.serviceManager.startCollection(config, records -> { | ||
Log.d("LOCAL COLLECTION", sensor.toString()+ " records: " + records.toString()); | ||
}); | ||
} | ||
|
||
@Override | ||
public void executeStop(WearSensor sensor) { | ||
this.serviceManager.stopCollection(sensor); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/es/uji/geotec/wearossensorsdemo/command/RemoteCollectionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package es.uji.geotec.wearossensorsdemo.command; | ||
|
||
import android.content.Context; | ||
|
||
import es.uji.geotec.backgroundsensors.collection.CollectionConfiguration; | ||
import es.uji.geotec.wearossensors.command.CommandClient; | ||
import es.uji.geotec.wearossensors.sensor.WearSensor; | ||
|
||
public class RemoteCollectionCommand implements CollectionCommand { | ||
|
||
private CommandClient commandClient; | ||
|
||
public RemoteCollectionCommand(Context context) { | ||
this.commandClient = new CommandClient(context); | ||
} | ||
@Override | ||
public void executeStart(WearSensor sensor) { | ||
CollectionConfiguration config = new CollectionConfiguration( | ||
sensor, | ||
android.hardware.SensorManager.SENSOR_DELAY_GAME, | ||
sensor == WearSensor.HEART_RATE || sensor == WearSensor.LOCATION ? 1 : 50 | ||
); | ||
this.commandClient.sendStartCommand(config); | ||
} | ||
|
||
@Override | ||
public void executeStop(WearSensor sensor) { | ||
this.commandClient.sendStopCommand(sensor); | ||
} | ||
} |
Oops, something went wrong.