Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
206 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
package org.ligi.ufo;
13
 
14
//#ifdef j2me
15
//# import javax.microedition.io.*;
16
//#endif
17
 
18
 
19
import java.io.*;
20
 
21
public class UFOProber
22
 
23
{
24
    public final static int PROBE_RESULT_NONE          =0;
25
    public final static int PROBE_RESULT_INCOMPATIBLE  =1;
26
    public final static int PROBE_RESULT_MK            =2;
27
    public final static int PROBE_RESULT_NG            =3;
28
    public final static int PROBE_RESULT_NAVCTRL       =4;
29
    public final static int PROBE_RESULT_MK3MAG        =5;
30
 
31
 
32
 
33
 
34
    public boolean change_notify=false;
35
 
36
    public String[] extended_names= { "No Device" , "Inkompatible Device","MK-Connection" , "NG-Connection" , "NavCtrl-Connection","MK3Mag Connection" };
37
 
38
    public int probe_result=PROBE_RESULT_NONE;
39
 
40
 
41
    public void set_to(int _probe_result)
42
    {
43
        if (_probe_result!=probe_result)
44
            {
45
                probe_result=_probe_result;
46
                change_notify=true;
47
            }
48
    }
49
    public void set_to_navi()
50
    {  
51
        set_to(PROBE_RESULT_NAVCTRL);
52
    }
53
 
54
    public void set_to_mk3mag()
55
    {  
56
        set_to(PROBE_RESULT_MK3MAG);
57
    }
58
 
59
    public void set_to_mk()
60
    {
61
        set_to(PROBE_RESULT_MK);
62
    }
63
 
64
 
65
    public void set_to_none()
66
    {  
67
        set_to(PROBE_RESULT_NONE);
68
    }
69
 
70
    public void set_to_incompatible()
71
    {  
72
        set_to(PROBE_RESULT_INCOMPATIBLE);    
73
    }
74
 
75
    public boolean is_navi()
76
    {
77
        return (probe_result==PROBE_RESULT_NAVCTRL);
78
    }
79
 
80
    public boolean is_mk()
81
    {
82
        return (probe_result==PROBE_RESULT_MK);
83
    }
84
 
85
    public boolean is_mk3mag()
86
    {
87
        return (probe_result==PROBE_RESULT_MK3MAG);
88
    }
89
 
90
    public boolean is_incompatible()
91
    {
92
        return (probe_result==PROBE_RESULT_INCOMPATIBLE);
93
    }
94
 
95
 
96
    public String extended_name()
97
    {
98
        return extended_names[probe_result];
99
    }
100
 
101
    String reply="";
102
    public boolean probe_error=false;
103
 
104
    // j2me
105
    //    private javax.microedition.io.StreamConnection connection;
106
    // ej2me
107
 
108
 
109
    //    private java.io.InputStream   reader;    
110
    //private java.io.OutputStream writer;    
111
 
112
    public void bluetooth_probe(String url)
113
    {
114
        try{
115
            /*
116
              connection = (StreamConnection) Connector.open(url);
117
                reader=connection.openInputStream();
118
                writer=connection.openOutputStream();
119
                String magic="\rmk-mode\r";
120
                writer.write(magic.getBytes());
121
                writer.flush();
122
*/
123
 
124
                /*
125
                int input=0;
126
                // recieve data-set
127
 
128
                // the 1st line is the echo of the command when ng
129
                while ((input != 13) &&(input!=-1))
130
                       {
131
                           input = reader.read() ;
132
                           reply+=(char)input;
133
                       }
134
                reply="";
135
                input=0;
136
                while ((input != 13) &&(input!=-1))
137
                       if (input!=10){
138
                           input = reader.read() ;
139
                           reply+=(char)input;
140
                       }
141
 
142
                if (reply=="NG here\r")
143
                        probe_result=PROBE_RESULT_NG;
144
 
145
                probe_result=PROBE_RESULT_MK;
146
 
147
                */
148
            //          writer.close();
149
            //          reader.close();
150
            //          connection.close();
151
 
152
        }
153
        catch (Exception ex)
154
            {
155
                probe_error=true;
156
            }  
157
 
158
 
159
    }
160
 
161
}