You are here: Forum Home → ANT+ Forums → Miscellaneous → Thread
public void antDecodePage1(byte[] ANTRxMessage) {
int count = (ANTRxMessage[PAGE_OFFSET + 1] & 0xff);
int caps = (ANTRxMessage[PAGE_OFFSET + 3] & 0xff);
int off_4 = (ANTRxMessage[PAGE_OFFSET + 4] & 0xff);
int off_5 = (ANTRxMessage[PAGE_OFFSET + 5] & 0xff);
int off_6 = (ANTRxMessage[PAGE_OFFSET + 6] & 0xff);
int off_7 = (ANTRxMessage[PAGE_OFFSET + 7] & 0xff);
boolean light_error;
long time = SystemClock.elapsedRealtime();
if (mLogWriter != null) {
mLogWriter.format("MO_1,%s,%s,%s,%s", time, getRawString(ANTRxMessage), count, caps);
}
//Logger.trace("Muscle Oxygen Page 1 :{} ",getRawString(ANTRxMessage));
if (count != mCounter){
mCounter = count;
// caps
if (mCaps != caps){
mCaps = caps;
mAntFs = ((caps & 1) == 1);
switch ((caps >> 1) & 7){
default:
mUpdateRate = -1.0f;
break;
case 1:
mUpdateRate = 0.25f;
break;
case 2:
mUpdateRate = 0.5f;
break;
case 3:
mUpdateRate = 1.0f;
break;
case 4:
mUpdateRate = 2.0f;
break;
}
Logger.info("Muscle Oxygen Caps. AntFS :{} UpdateRate :{}", mAntFs, mUpdateRate);
if (mLogWriter != null) {
mLogWriter.format(",%s,%s", mAntFs, mUpdateRate);
}
}
mLastConcentration = off_4 | ((off_5 & 0xf) << 8);
mLastPercentage = ((off_6 & 0xc0)>>6) | ((off_7 & 0xff)<<2);
mPreviousPercentage = ((off_5 & 0xf0) >> 4) | ((off_6 & 0x3f) << 4);
light_error = false;
if (mLastC 0xfff){
light_error = true;
} else { mC * 0.01f;
}
if (mLastPercentage == 0x3ff){
light_error = true;
} else {
mPercentage = mLastPercentage * 0.1f;
}
if (light_error != mLightError){
mLightError = light_error;
Logger.info("Muscle Oxygen Ambient Light error changed to :{}", mLightError);
}
if (mLogWriter != null) {
mLogWriter.format(",%s,%s,%s,%s,%s,%s"
, mLastConcentration, mPreviousPercentage, mLastPercentage
, mConcentration, mPercentage, light_error);
}
Logger.trace("Muscle Oxygen Concentratio :{} Percentage :{} Error :{}"
, mConcentration, mPercentage, light_error);
// broadcast the data
Intent intent = new Intent(IpAntManApi.MUSCLE_OXYGEN_EVENT);
intent.putExtra(IpAntManApi.AMOUNT, mConcentration);
intent.putExtra(IpAntManApi.PERCENT, mPercentage);
intent.putExtra(IpAntManApi.ERROR, light_error);
intent.putExtra(IpAntManApi.DB_ID, mDbId);
mCtxt.sendBroadcast(intent);
}
if (mLogWriter != null){
mLogWriter.println();
}
}