Subversion Repositories Projects

Rev

Rev 4 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 59
Line 22... Line 22...
22
    public boolean searching=true;
22
    public boolean searching=true;
23
    public boolean error=false;
23
    public boolean error=false;
24
    public String  err_log="none";
24
    public String  err_log="none";
Line -... Line 25...
-
 
25
 
-
 
26
 
-
 
27
    public void log(String err_str)
-
 
28
    {
-
 
29
 
-
 
30
        err_log+=err_str;
-
 
31
        System.out.println(err_str);
25
 
32
    }
Line 26... Line 33...
26
 
33
 
27
    public final int MAX_DEVICES=10;
34
    public final int MAX_DEVICES=10;
28
 
35
 
Line 56... Line 63...
56
                m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this);
63
                m_DscrAgent.startInquiry(DiscoveryAgent.GIAC,this);
57
            }
64
            }
58
        catch (BluetoothStateException ex)
65
        catch (BluetoothStateException ex)
59
            {
66
            {
60
                error=true;
67
                error=true;
61
                err_log+="Problem in searching the blue tooth devices\n" + ex;
68
                log("Problem in searching the blue tooth devices\n" + ex);
Line 62... Line 69...
62
               
69
               
Line 63... Line 70...
63
            }
70
            }
Line 64... Line 71...
64
 
71
 
Line 65... Line 72...
65
    }
72
    }
-
 
73
 
66
 
74
    public void inquiryCompleted(int transID) {
67
    public void inquiryCompleted(int transID) {
75
 
68
 
76
        try {
69
        try {
77
            log("search complete with " + remote_device_count + " devices");
Line -... Line 78...
-
 
78
            for(int i=0;i<remote_device_count;i++)
-
 
79
                {
-
 
80
                    log("#" + i + " -> addr: " + remote_devices[i].getBluetoothAddress());
-
 
81
                    remote_device_mac[i]=remote_devices[i].getBluetoothAddress();
-
 
82
 
-
 
83
                    remote_device_name[i]=remote_devices[i].getBluetoothAddress();
-
 
84
                    try {
-
 
85
                        log("#" + i + "name:" + remote_devices[i].getFriendlyName(true));
-
 
86
                        remote_device_name[i]=remote_devices[i].getFriendlyName(true);
-
 
87
                    }
-
 
88
                    catch (Exception e)
70
            for(int i=0;i<remote_device_count;i++)
89
                        {
71
                {
90
                            log("Problem getting name of BT-Device( -> taking mac as name): " + e);
72
                    remote_device_name[i]=remote_devices[i].getFriendlyName(true);
91
                        }      
73
                    remote_device_mac[i]=remote_devices[i].getBluetoothAddress();
92
 
74
 
93
 
75
                }
94
                }
76
        }
95
        }
77
        catch (Exception e)
96
        catch (Exception e)
Line 87... Line 106...
87
    }
106
    }
Line 88... Line 107...
88
 
107
 
89
    //Called when device is found during inquiry 
108
    //Called when device is found during inquiry 
90
    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
109
    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
-
 
110
    {
91
    {
111
        log("found device ");  
92
        try
112
        try
93
            {
113
            {
94
                if (remote_device_count!=(MAX_DEVICES-1))
114
                if (remote_device_count!=(MAX_DEVICES-1))
95
                    {
115
                    {
96
                        remote_devices[remote_device_count]=btDevice;
116
                        remote_devices[remote_device_count]=btDevice;
97
                        remote_device_count++;
117
                        remote_device_count++;
98
                    }
118
                    }
99
            }
119
            }
100
        catch (Exception e)
120
        catch (Exception e)
101
            {
121
            {
102
                err_log+=("Device Discovered Error: " + e);    
122
                log("Device Discovered Error: " + e);  
Line 103... Line 123...
103
            }
123
            }