Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

You are here: Forum Home → ANT+ Forums → Miscellaneous → Thread

   

Muscle Oxygen Profile

Rank

Total Posts: 5

Joined 2015-04-14

PM

I'm interested in Ant+ Muscle Oxygen Profile. The specification "D00001555_ANT+_Device_Profile_-_Muscle_Oxygen_Rev_1.0.pdf" is very useful but I would like to know if there is any (at least basic) Android implementation available. I would really appreciate any code sample to be able start with simple MO2 display on Android device.      
RankRankRankRank

Total Posts: 122

Joined 2010-10-25

PM

The basic data page decoding is simple stuff. Here is the relevant fragment of code from IpSensorMan as used by IpBike. If you get some code for a more standard sensor it should be easy to adapt.
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"timegetRawString(ANTRxMessage), countcaps);
    
}

    
//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 :{}"mAntFsmUpdateRate);
         if (
mLogWriter != null{
             mLogWriter
.format(",%s,%s"mAntFsmUpdateRate);
         
}
     }
     
        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"
              
mLastConcentrationmPreviousPercentagemLastPercentage
              
mConcentrationmPercentagelight_error);
        
}

     Logger
.trace("Muscle Oxygen Concentratio :{} Percentage :{} Error :{}"
       
mConcentrationmPercentagelight_error);

        
// broadcast the data
        
Intent intent = new Intent(IpAntManApi.MUSCLE_OXYGEN_EVENT);
        
intent.putExtra(IpAntManApi.AMOUNTmConcentration);
        
intent.putExtra(IpAntManApi.PERCENTmPercentage);
        
intent.putExtra(IpAntManApi.ERRORlight_error);
        
intent.putExtra(IpAntManApi.DB_IDmDbId);
        
mCtxt.sendBroadcast(intent);
    
}
    
    
if (mLogWriter != null){
      mLogWriter
.println();
    
}
  } 
     
Rank

Total Posts: 5

Joined 2015-04-14

PM

I went through most of the ant/ant+ docs and I feel quite comfortable with the level of details. Just to make sure I have undestood last reply correctly here are my assumptions:
- Currently it is not possible to utilitize Ant+ Muscle Oxygen Profile in Android applications as SDK does not include the implementation and Android ANT+ Plugins will not handle it. May be there is way how to utilize (hack) other existing Ant+ profile but it is probably not meaningful as it could not be certified. Please, are there any time estimations when included in Android SDK?
- According to raw Payload decoding example above it should be able to connect with Moxy via pure Ant Android SDK. With great support of Ant documentation it was easy to setup Android Emulator with Radio Services, AntEmulatorConfig and deploy Sample_BackgroundScan application. However it seems I have some beginner's issue with acquiring channel. The bridge is running:

USB to Socket:
[0B][3E][41][4A][4B][31][2E][30][34][52][41][46][00]
[01][6F][20]
[0B][3E][41][4A][4B][31][2E][30][34][52][41][46][00]
[06][54][08][03][00][BA][36][00]
[03][40][00][76][28]
[01][6F][20]

Socket to USB:
[02][4D][00][3E]
[01][4A][00]
[02][4D][00][3E]
[02][4D][00][54]
[11][76][00][DB][B6][5C][7D][F1][1D][52][37][91][27][D9][C7][DC][43][E2][28]
[09][46][00][E8][E4][21][3B][55][7A][67][C1]
[01][4A][00]

The application log output is:
05-04 18:45:44.810: I/ChannelService(3524): Number of channels with background scanning capabilities: 8

So I have added logging of acquire exception:
05-04 18:45:47.510: I/ChannelService(3524): com.dsi.ant.channel.ChannelNotAvailableException: Could not acquire channel. Reason = NETWORK_NOT_AVAILABLE.

I have to admit the Javadoc for "NETWORK_NOT_AVAILABLE" is not clear for me:
"There are too many simultaneous networks in use, found a channel but could not use the selected network."

Could you point me where is my failure and whether it should be possible to use Sample_BackgroundScan for basic payload decoding as described above with Moxy?

Thank you very much for your time!
     
Rank

Total Posts: 5

Joined 2015-04-14

PM

First point is confirmed grin
Second point was wrong direction. One should stick with Ant+.