BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-31-2008, 01:56 AM   #1
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default read com-port

Please Login to Remove!

hi,
i would like to read incomming data from the com port (Bluetooth) of my BlackBerry (8707).
how many com ports are there?
i've tried this example here:
Code:
 private class InputThread extends Thread {
        public void run() {
            try {
                BluetoothSerialPortInfo[] info = BluetoothSerialPort.getSerialPortInfo();
                if (info == null /*|| info.length == 0*/) {
                    invokeAndWait( new Runnable() {
                        public void run() {
                            Dialog.alert("Kein Bluetooth Port für die Verbindung verfügbar!");
                            closePort();
                            System.exit(1);
                        }
                    });
                }
                System.out.println("Infostring: "+info[0].toString());
                _bluetoothConnection = (StreamConnection)Connector.open(info[0].toString(),Connector.READ_WRITE);
                _din = _bluetoothConnection.openDataInputStream();
                _dout = _bluetoothConnection.openDataOutputStream();
            } catch(IOException e) {
                invokeAndWait(new Runnable() {
                    public void run() {
                        Dialog.alert("Serieller Port konnte nicht geöffnet werden!");
                        closePort();
                        System.exit(1);
                    }
                });
            } catch (Exception e) {
                System.out.println("Keine Bluetooth unterstützung: "+e);
                invokeAndWait(new Runnable() {
                    public void run() {
                        Dialog.alert("Dieses BlackBerry Gerät unterstützt kein Bluetooth! ");
                        closePort();
                        System.exit(1);
                    }
                });
            }
            
            try {
                int type, offset, count;
                String value;
                for(;;) {
                    type = _din.readInt();
                    if (type == CONTENTS) {
                        String contents = _din.readUTF();
                        synchronized(Application.getEventLock()) {
                            myLabel.setText(contents);
                        }
                    } else if(type == NO_CONTENTS) {
                    } else {
                        throw new RuntimeException();
                    }
                }
            } catch(IOException ioe) {
                invokeLater(new Runnable() {
                    public void run() {
                        Dialog.alert("Probleme beim lesen vom Seriellen Port!");
                        closePort();
                        System.exit(1);
                    }
                });
            }
        }
    }
but this don't works, i always get the message
Quote:
Dialog.alert("Dieses BlackBerry Gerät unterstützt kein Bluetooth! ");
so is there a good way to read the data?

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 03-31-2008, 03:05 AM   #2
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

as you can see in your code the alert pops up because an exception was thrown. for a start you could try to locate it and put some more output into your application.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 03-31-2008, 03:28 AM   #3
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default

the exception is thrown becuase the variable info is null... but why is is null? i have some Bluetooth devices connected to my BlackBerry...

are there any settings which allow me to configurate the Bluetooth com ports, security,...or someting like that?

hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Siemens 6ES7214-1HG40-0XB0 Compact Processor picture

Siemens 6ES7214-1HG40-0XB0 Compact Processor

$225.00



NEW SEALED AB 1747-L541 /C SLC 500 SLC 5/04 CPU PROCESSOR UNIT MODULE US picture

NEW SEALED AB 1747-L541 /C SLC 500 SLC 5/04 CPU PROCESSOR UNIT MODULE US

$310.93



Raspberry Pi Pico Microcontroller Development Board RP2040 dual-core processor picture

Raspberry Pi Pico Microcontroller Development Board RP2040 dual-core processor

$5.99



AlphaSmart 3000 Portable Desktop Word Processor With Cable & Batteries picture

AlphaSmart 3000 Portable Desktop Word Processor With Cable & Batteries

$59.99



Schneider Electric Andover Continuum ACX Series ACX-5740 picture

Schneider Electric Andover Continuum ACX Series ACX-5740

$375.00



AB 1747-L542 /B SLC 500 5/04 CPU PROCESSOR UNIT New Factory Sealed AB 1747L542 picture

AB 1747-L542 /B SLC 500 5/04 CPU PROCESSOR UNIT New Factory Sealed AB 1747L542

$334.57







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.