Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 180 → Rev 181

/branches/ligi_j2me/src/MKCommunicator.java
32,8 → 32,7
 
public String mk_url=""; // buffer the url which is given in the constuctor for reconnectin purposes
 
// version Info from Flight Control
public int version_major=-1;
public int version_minor=-1;
40,6 → 39,7
public int version_compatible=-1;
 
public long connection_start_time=-1;
 
/****************** Section: private Attributes **********************************************/
52,13 → 52,15
String p_msg="--";
public String msg="BT_INIT";
 
int data_count=0;
public int data_count=0;
 
 
/****************** Section: public Methods ************************************************/
public MKCommunicator(String url) // Constructor with URL string e.g. "btspp://XXXXXXXXXXXX:1" - the X-Part is the MAC-Adress of the Bluetooth-Device connected to the Fligth-Control
{
debug_data=new MKDebugData();
mk_url=url; // remember URL for connecting / reconnecting later
 
new Thread( this ).start(); // fire up main Thread
}
 
70,7 → 72,10
connection = (StreamConnection) Connector.open(mk_url, Connector.READ_WRITE);
reader=connection.openInputStream();
writer=connection.openOutputStream();
connection_start_time=System.currentTimeMillis();
connected=true; // if we get here everything seems to be OK
get_version();
}
catch (Exception ex)
{
77,8 → 82,9
// TODO difference fatal errors from those which will lead to reconnection
msg="Problem connecting" + "\n" + ex;
}
get_version();
 
 
 
}
 
152,6 → 158,7
{
int[] decoded_data;
 
switch((char)data[2])
{
184,6 → 191,9
}
 
 
 
 
// Thread to recieve data from Connection
public void run()
{
194,9 → 204,12
while(true)
{
if (!connected)
connect();
{
connect();
}
else
try{
pos=0;
input=0;
// recieve data-set