Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

smartLAB walk+ with Android

Avatar
Rank

Total Posts: 6

Joined 0

PM

Hey,

I'm developing an App that gets the data from an smartLAB walk+. But i can't get a connection to the device. The wildcard search works, but doesn't find the walk+. Do I need the an other ANT+ Network key as the default?      
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

Hi,

The network keys are pre-assigned to network numbers. i.e. The public network key is assigned to network 0, and the ANT+ network key is assigned to network 1. In order to use the respective network key, you will have to assign your channel to the network's corresponding network number, in this case network number 1. Please refer to the documentation accompanying the API for more information.      
Avatar
Rank

Total Posts: 6

Joined 0

PM

Thats not the problem. The Channel is assign with network 1.
The smartLAB walk+ is an ANT+ Device so the should be no problem to connect to it.
But even with a wildcard I cant find the device. The walk+ acts as an master an sends a beacon with 4Hz.
I should get the beacon with the app with wildcard configuration, but it cant find anything.      
Avatar
RankRankRankRank

Total Posts: 296

Joined 0

PM

psyckodelig wrote:
Thats not the problem. The Channel is assign with network 1.
The smartLAB walk+ is an ANT+ Device so the should be no problem to connect to it.
But even with a wildcard I cant find the device. The walk+ acts as an master an sends a beacon with 4Hz.
I should get the beacon with the app with wildcard configuration, but it cant find anything.

I tried to "talk" to a smartLAB+ blood pressure monitor a few months ago and couldn't make it work. I contacted the manufacturer and learned that there were some tiny bugs in the ANTFS implementation of the device firmware that caused my problems. The manufacturer was quite helpful.
So if you don't manage to find a solution for your problems, contacting the manufacturer might help.
Before doing so, you could use the tools provided by Dynastream to see if the device complies with the ANT+ standards (mainly: ANT+ Display Simulator and ANTFS Host).      
Rank

Total Posts: 6

Joined 2010-11-25

PM

I've got a SmartLab walk+ here (received in May 2012) which is not an ANT+ device and doesn't claim to be one, either. It has only an ANT Logo, but neither an ANT+ icon nor any ANT+ profile icons.

It transmits on frequency 66, in a custom format.

As old_man_biking already said, it's probably best to contact the manufacturer for further information.      
Avatar
Rank

Total Posts: 6

Joined 0

PM

If got the datasheet from smartLAB for the walk+.
The configuration for the slave is mentioned. But even with ANTware II I get no connection. So it seems to be a problem with the walk+.      
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

Are you certain that all of your channel parameters are correct? If it's not using an ANT+ device profile, it will most likely be transmitting on the public network.      
RankRankRankRank

Total Posts: 523

Joined 2012-11-15

PM

Network: 1 (Yes, it is ANT+)
device type: 0
device number: 0
transmisson type: 0 (slave)
rf: 57

With this i should get all ANT+ devices nearby, right? I tried with a second Sony Ericsson Arc an it work. Both Arc can communicat to each other.
The Datasheet of the walk+ says:

device type: 200 for pairing (...200 is not possible)
device type: 100 for data
device number: 0 for pairing
trans. type: 0
rf: 57
network: ANT+ Managend Network Key      
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

The most significant bit of the device type byte is the pairing bit, so the device type can in fact be 200.

If the walk+ is indeed an ant+ device, then you will have to set the pairing bit in order to pair with it successfully. You can do that by selecting the 'Pairing' checkbox in ANTware II before setting the channel ID.      
Avatar
Rank

Total Posts: 6

Joined 0

PM

Even with pairing bit it doesnt work. Here is my code for the app.

import com.dsi.ant.AntDefine;
import com.dsi.ant.AntInterface;
import com.dsi.ant.AntInterfaceIntent;
import com.dsi.ant.AntMesg;
import com.dsi.ant.AntInterface.ServiceListener;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class 
ANTsmartlab extends Activity {
    
public static final String TAG "ANTsmartlab";
    
/** Called when the activity is first created. */
    
    
static final byte SLAVE AntDefine.PARAMETER_RX_NOT_TX;
    static final 
byte MASTER AntDefine.PARAMETER_TX_NOT_RX;
    static final 
byte BOTH AntDefine.PARAMETER_SHARED_CHANNEL;
    static final 
byte WILDCARD_CHANNEL AntDefine.PARAMETER_ALWAYS_RX_WILD_CARD_SEARCH_ID;
    
boolean ServConnected false;
    
    
/** Layout */
    
TextView sent_msg;
    
TextView rec_msg;
    
Button ant_send;
    
Button ant_open;
    
Button ant_close;
    
    
    
AntInterface antInterface;
    
/**Channel Configuration */
    
byte channel 0;
    
byte channel_type SLAVE// 0x10 master 0x00 slave
    
byte network = (byte0x01// 0 ANT, 1 ANT+, 2 ANT-FS
    
byte radioFrequency 57// Device Profil Pedo Meter 1.3
    
byte txType 0//
    
byte deviceType = (byte200// 100 for defined device, 200 for pairing
    
short device 0;
    
short period 8192// = 4 Hz = 8192 / 32768

    /*Pair to any device. */
    
static final short WILDCARD 0;
    
    
    @
Override
    
public void onCreate(Bundle savedInstanceState{
        super
.onCreate(savedInstanceState);
        
setContentView(R.layout.main);
        
        
ant_send = (ButtonfindViewById(R.id.ant_send);
        
ant_open = (ButtonfindViewById(R.id.ant_open);
        
ant_close = (ButtonfindViewById(R.id.ant_close);
        
sent_msg = (TextViewfindViewById(R.id.sent_msg);
        
rec_msg = (TextViewfindViewById(R.id.rec_msg);

        
Log.d(TAG"Layout done");
        
        
        
antInterface = new AntInterface();
        
Log.d(TAG"new Interface");    
        
        
antInterface.initService(getApplicationContext(), listener);
        
Log.d(TAG"initService");
        
        
        
this.getApplicationContext().registerReceiver(AntMsgReceiver,
                new 
IntentFilter(AntInterfaceIntent.ANT_RX_MESSAGE_ACTION));
        
        

    
}
    
    
/**BUtton Functions------------------------------------------------------------------*/
    
public void ant_send(View view{
        
if (ServConnected{
            
try {
                byte[] txBuffer 
(byte0x00, (byte0x11, (byte0x22,
                        (
byte0x33, (byte0x44, (byte0x55, (byte0x66,
                        (
byte0x77, (byte0x8A };
                
antInterface.ANTSendBroadcastData(channeltxBuffer);
                
antInterface.ANTTxMessage(txBuffer);
                
sent_msg.setText("Broadcast: " getHexString(txBuffer));
            
catch (Throwable e{
                error_message
(e.toString());
            
}
        } 
else {
            error_message
("Service not connected");
        
}
    }

    
public void ant_channel_open(View view{
        
try {
            Boolean state
;

            
state antInterface.hasClaimedInterface();
            if (!
state{
                state 
antInterface.claimInterface();
            
}
            
if (!state{
                antInterface
.requestForceClaimInterface("ANTsmartlab");
            
}

            
// Assign Channel
            
antInterface.ANTAssignChannel(channelchannel_typenetwork);
            
            
// Set Channel ID
            
antInterface.ANTSetChannelId(channeldevicedeviceTypetxType);

            
// Set RF Frequency
            
antInterface.ANTSetChannelRFFreq(channelradioFrequency);

            
// Set Channel Period
            
antInterface.ANTSetChannelPeriod(channelperiod);

            
// Open Channel
            
antInterface.ANTOpenChannel(channel);
            
    

        
catch (Throwable e{
            error_message
(e.toString());
        
}

        
return;
    
}

    
public void ant_channel_close(View view{
        
try {
            
// Close Channel

            
antInterface.ANTCloseChannel(channel);
        
catch (Throwable e{
            error_message
(e.toString());
        
}
        
return;
    
}
    
    
/** ANT-------------------------------------------------------------------*/
    
private ServiceListener listener = new ServiceListener() {
        
// @Override
        
public void onServiceConnected() {
            Log
.d(TAG"ServiceListener onServiceConnected()");
            
            try 
{
                Boolean temp
;

                
antInterface.enable();

                
temp antInterface.claimInterface();
                
// error_message(temp.toString());antInterface.toString();

                
if (temp{
                    
// allow tx and rx of messages
                    
ServConnected true;
                    
Log.d(TAG"ANT service connected");
                
else {
                    antInterface
.requestForceClaimInterface("ANTsmartlab");
                
}
            } 
catch (Throwable e{
                error_message
(e.toString());
            
}
        }

        
// @Override
        
public void onServiceDisconnected() {
            Log
.d(TAG"ServiceListener onServiceDisconnected()");

            
// do not allow tx and rx of messages
            
ServConnected false;
        
}
    }
;
    
    
    private 
BroadcastReceiver AntMsgReceiver = new BroadcastReceiver() {
        
        
@Override
        
public void onReceive(Context contextIntent intent{
            
// Context mContext = context;

            
String AntIntent intent.getAction();
            
byte[] ANTRxMessage intent
                    
.getByteArrayExtra(AntInterfaceIntent.ANT_MESSAGE);
            
Log.d(TAG"enter onReceive: " AntIntent);
            if (
AntIntent.equals(AntInterfaceIntent.ANT_RX_MESSAGE_ACTION)) {
                Log
.d(TAG"onReceive: ANT RX MESSAGE");

                
Log.d(TAG"Rx:" getHexString(ANTRxMessage));

                switch (
ANTRxMessage[AntMesg.MESG_ID_OFFSET]{
                
case AntMesg.MESG_STARTUP_MESG_ID:
                    
rec_msg.setText("Message Startup:"
                            
ANTRxMessage.toString());
                    break;
                case 
AntMesg.MESG_BROADCAST_DATA_ID:
                    
rec_msg.setText("Broadcast: " getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_ACKNOWLEDGED_DATA_ID:
                    
rec_msg.setText("Acknowledged: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_BURST_DATA_ID:
                    
rec_msg.setText("Burst: " getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_RESPONSE_EVENT_ID:
                    
rec_msg.setText("Msg Response Event: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_CHANNEL_STATUS_ID:
                    
rec_msg.setText("Channel Status: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_CHANNEL_ID_ID:
                    
rec_msg.setText("Mesg. Channel ID: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_VERSION_ID:
                    
rec_msg.setText("Msg Version ID: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_CAPABILITIES_ID:
                    
rec_msg.setText("Msg Capabilities: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_GET_SERIAL_NUM_ID:
                    
rec_msg.setText("Msg Serial Num: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_EXT_ACKNOWLEDGED_DATA_ID:
                    
rec_msg.setText("Msg Ext Acknowledged Data: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_EXT_BROADCAST_DATA_ID:
                    
rec_msg.setText("Msg Ext Broadcast Data: "
                            
getHexString(ANTRxMessage));
                    break;
                case 
AntMesg.MESG_EXT_BURST_DATA_ID:
                    
rec_msg.setText("Msg Ext Burst Data: "
                            
getHexString(ANTRxMessage));
                    break;
                default:
                    
rec_msg.setText("Dont Know:" getHexString(ANTRxMessage));
                    break;
                
}

            } 
else {
                Log
.w(TAGgetHexString(ANTRxMessage));

            
}

        }

    }
;
    
    private 
void error_message(String msg{
        
new AlertDialog.Builder(this).setTitle("Error").setMessage(msg)
                .
setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                    
public void onClick(DialogInterface dialogint which{
                        
// do nothing
                    
}
                }
).show();
    
}
    
    
public static String getHexString(byte[] data{
        
if (null == data{
            
return "";
        
}

        StringBuffer hexString 
= new StringBuffer();
        for (
int i 0data.lengthi++) {
            hexString
.append("[").append(String.format("%02X"data[i] 0xFF))
                    .
append("]");
        
}

        
return hexString.toString();
    
}
     
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

I strongly suggest that you try talking to the walk+ with ANTware II and confirming that you can actually see it showing up there, if you can't see it there, you will NOT see it on your Android app.

I am also curious where you got the value for the period from? I would be curious to see if you can see the beacon from the walk+ if a node in ANTware II is opened in continuous scanning mode, if you can, then your period is wrong. Please try this.

I would also like to point out that there is currently no ANT+ device profile that uses 100 as the device type. This leads me to believe that the information you have regarding the walk+ is wrong, and that it is not an ANT+ device, as Martin Simhofer said.

I suggest taking Martin Simhofer's advice and try looking for the device on the public network on frequency 66 (with your ANTware II node in continuous scan mode, not a specific period).

If you still cannot get the walk+ to transmit, contact the manufacturer, as we are do not know the specifics of the walk+, and will be unable to provide you with any device specific support.

Cheers