Blame |
Last modification |
View Log
| RSS feed
/**********************************************************************************
*
* Probe which type of UFO we talk to
*
* Author: Marcus -LiGi- Bueschleb
*
* see README for further Infos
*
*
**********************************************************************************/
import javax.microedition.io.*;
import java.io.*;
public class UFOProber
{
public final static int PROBE_RESULT_NONE=
0;
public final static int PROBE_RESULT_MK=
1;
public final static int PROBE_RESULT_NG=
2;
public int probe_result=PROBE_RESULT_NONE
;
String reply=
"";
public boolean probe_error=
false;
private javax.
microedition.
io.
StreamConnection connection
;
private java.
io.
InputStream reader
;
private java.
io.
OutputStream writer
;
public void bluetooth_probe
(String url
)
{
try{
connection =
(StreamConnection
) Connector.
open(url
);
reader=connection.
openInputStream();
writer=connection.
openOutputStream();
String magic=
"\rmk-mode\r";
writer.
write(magic.
getBytes());
writer.
flush();
/*
int input=0;
// recieve data-set
// the 1st line is the echo of the command when ng
while ((input != 13) &&(input!=-1))
{
input = reader.read() ;
reply+=(char)input;
}
reply="";
input=0;
while ((input != 13) &&(input!=-1))
if (input!=10){
input = reader.read() ;
reply+=(char)input;
}
if (reply=="NG here\r")
probe_result=PROBE_RESULT_NG;
probe_result=PROBE_RESULT_MK;
*/
writer.
close();
reader.
close();
connection.
close();
}
catch (Exception ex
)
{
probe_error=
true;
}
}
}