Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ftms ant+ garmin #2290 #2330

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
4 changes: 3 additions & 1 deletion src/android/src/Ant.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void doUnbindChannelService()
Log.v(TAG, "...doUnbindChannelService");
}

public void setCadenceSpeedPower(float speed, int power, int cadence)
public void setCadenceSpeedPower(float speed, int power, int cadence, float inclination, int resistance)
{
if(mChannelService == null)
return;
Expand All @@ -119,6 +119,8 @@ public void setCadenceSpeedPower(float speed, int power, int cadence)
mChannelService.setSpeed(speed);
mChannelService.setPower(power);
mChannelService.setCadence(cadence);
mChannelService.setResistance(resistance);
mChannelService.setInclination(inclination);
}

public int getHeart()
Expand Down
36 changes: 36 additions & 0 deletions src/android/src/ChannelService.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class ChannelService extends Service {
PowerChannelController powerChannelController = null;
SpeedChannelController speedChannelController = null;
SDMChannelController sdmChannelController = null;
RDChannelController rdChannelController = null;
FTMSChannelController ftmsChannelController = null;

private ServiceConnection mAntRadioServiceConnection = new ServiceConnection() {
@Override
Expand Down Expand Up @@ -115,6 +117,24 @@ void setSpeed(double speed) {
if (null != sdmChannelController) {
sdmChannelController.speed = speed;
}
if (null != rdChannelController) {
rdChannelController.speed = speed;
}
if (null != ftmsChannelController) {
ftmsChannelController.speed = speed;
}
}

void setResistance(int resistance) {
if (null != ftmsChannelController) {
ftmsChannelController.resistance = resistance;
}
}

void setInclination(float inclination) {
if (null != ftmsChannelController) {
ftmsChannelController.inclination = inclination;
}
}

void setPower(int power) {
Expand All @@ -133,6 +153,12 @@ void setCadence(int cadence) {
if (null != sdmChannelController) {
sdmChannelController.cadence = cadence;
}
if (null != rdChannelController) {
rdChannelController.cadence = cadence;
}
if (null != ftmsChannelController) {
ftmsChannelController.cadence = cadence;
}
}

int getHeart() {
Expand All @@ -158,6 +184,9 @@ public void openAllChannels() throws ChannelNotAvailableException {
if (Ant.speedRequest) {
if(Ant.treadmill && sdmChannelController == null) {
sdmChannelController = new SDMChannelController(acquireChannel());
//powerChannelController = new PowerChannelController(acquireChannel());
//rdChannelController = new RDChannelController(acquireChannel());
ftmsChannelController = new FTMSChannelController(acquireChannel());
} else if(powerChannelController == null) {
powerChannelController = new PowerChannelController(acquireChannel());
speedChannelController = new SpeedChannelController(acquireChannel());
Expand All @@ -174,10 +203,17 @@ private void closeAllChannels() {
speedChannelController.close();
if (sdmChannelController != null)
sdmChannelController.close();
if (rdChannelController != null)
rdChannelController.close();
if (ftmsChannelController != null)
ftmsChannelController.close();

heartChannelController = null;
powerChannelController = null;
speedChannelController = null;
sdmChannelController = null;
rdChannelController = null;
ftmsChannelController = null;
}

AntChannel acquireChannel() throws ChannelNotAvailableException {
Expand Down
Loading
Loading