Subversion Repositories Projects

Rev

Rev 81 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
81 ligi 1
/**********************************************************************************
2
 *                                                                    
3
 * Probe which type of UFO we talk to
4
 *                                                
5
 * Author:        Marcus -LiGi- Bueschleb          
6
 *
7
 * see README for further Infos
8
 *
9
 *
10
 **********************************************************************************/
11
 
12
import javax.microedition.io.*;
13
import java.io.*;
14
 
15
public class UFOProber
16
 
17
{
18
    public final static int PROBE_RESULT_NONE=0;
19
    public final static int PROBE_RESULT_MK=1;
20
    public final static int PROBE_RESULT_NG=2;
21
 
22
    public int probe_result=PROBE_RESULT_NONE;
23
    String reply="";
24
    public boolean probe_error=false;
25
 
26
    private javax.microedition.io.StreamConnection connection;
27
    private java.io.InputStream reader;    
28
    private java.io.OutputStream writer;    
29
 
30
    public void bluetooth_probe(String url)
31
    {
32
        try{
33
                connection = (StreamConnection) Connector.open(url);
34
                reader=connection.openInputStream();
35
                writer=connection.openOutputStream();
36
                String magic="\rmk-mode\r";
37
                writer.write(magic.getBytes());
38
                writer.flush();
39
                /*
40
                int input=0;
41
                // recieve data-set
42
 
43
                // the 1st line is the echo of the command when ng
44
                while ((input != 13) &&(input!=-1))
45
                       {
46
                           input = reader.read() ;
47
                           reply+=(char)input;
48
                       }
49
                reply="";
50
                input=0;
51
                while ((input != 13) &&(input!=-1))
52
                       if (input!=10){
53
                           input = reader.read() ;
54
                           reply+=(char)input;
55
                       }
56
 
57
                if (reply=="NG here\r")
58
                        probe_result=PROBE_RESULT_NG;
59
 
60
                probe_result=PROBE_RESULT_MK;
61
 
62
                */
63
                writer.close();
64
                reader.close();
65
                connection.close();
66
 
67
        }
68
        catch (Exception ex)
69
            {
70
                probe_error=true;
71
            }  
72
 
73
 
74
    }
75
 
76
}