Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
Posts: 3
Registered: ‎11-20-2008
My Device: 9530
Accepted Solution

USB Connection to the Desktop

Hi everyone,

 

I tried searching for a similar post but came up empty.  Here is the scenario.  There is an app on the Device and an app on the Desktop.  They communicate through USB which works fine for the most part.  I am using:

 

(StreamConnection)Connector.open("comm:USB;channel=" + name);

 

to register the channel from the Device so the Desktop can connect.  Once the two are connected, I can read and write from the streams.  The problem is in the time between opening the connection and the connection actually being established.  The Device app may not be up to be listening for connections so it might be a while before the connection is made.  I can't seem to be able to get notified of the connection being established.

 

Is there a listener that I can use, or call Connector.open in a way that would notify the device code that the connection has been established?

 

 

Thank you in advance,

 

 

Jakub

New Developer
Posts: 1
Registered: ‎03-16-2009
My Device: Not Specified

Re: USB Connection to the Desktop

Hi jakub

 

I have been searching for days, and I can't establish any connection, could you help me with some advises?

 

Sorry if I can't be helpful, maybe when I arrived where you are I would....

 

Thanks!

 

Matias

New Developer
Posts: 3
Registered: ‎11-20-2008
My Device: 9530

Re: USB Connection to the Desktop

Hi,

 

The only advice I would give is make sure that the BlackBerry has opened a Channel to the desktop first.  This should be a Connector created with a specific channel name.  Once this is created, then the desktop can open a Channel to the device with the same name.  The device has to register the Channel first before the desktop can open it.

 

Hope that helps,

 

 

BlackBerry Development Advisor
Posts: 15,264
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: USB Connection to the Desktop

I'm not sure what you are asking here... but have you looked at the USBPortListener interface?  It may provide what you are looking for.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 3
Registered: ‎02-18-2009
My Device: Not Specified

Re: USB Connection to the Desktop

Jakub,

 

Since you have worked on it, I can certainly use your expertise. Kindly suggest. 

 

My code has following in sequence,

 

/*

in try catch block, I register a channel. I guess I am assigning a name to the channel here.

xyz is the name of the channel.

*/

regCh = USBPort("xyz", 100, 100); // This gives me 4

 

/*Checking connection status, I don't know if this is required to do. */

status = USBPort.getConnectionState(); // This gives me 3 sometimes 12

 

/*I thought this should connect*/ 

String url = "comm:USB;baudrate=9600;bitsperchar=8;parity=none;stopbits=1;channel=xyz";

StreamConnection _conn = null;
_conn = (StreamConnection)Connector.open(url); //In try block, this throws an exception.

 

You have said about "opened a Channel ", I tried _port = new USBPort(n);// n is a number. 8 throws channel state error, 12 throws illegal channel. I guess I am stuck here.

 

I hope you find the time to help me out here.

 

Thanks

 

New Developer
Posts: 3
Registered: ‎11-20-2008
My Device: 9530

Re: USB Connection to the Desktop

All you should need is:

 

 

(StreamConnection)Connector.open("comm:USB;channel=XYZ");

 

 You don't need:

 

regCh = USBPort("xyz", 100, 100);

 

Since that is what the underlying code in the Connector class is doing.

 

 

New Developer
Posts: 3
Registered: ‎02-18-2009
My Device: Not Specified

Re: USB Connection to the Desktop

Thank you, appreciate it. It's compiled. Did you use any windows application to listen to USB port?
Developer
Posts: 112
Registered: ‎07-19-2009
My Device: Not Specified

Re: USB Connection to the Desktop

New Member
Posts: 1
Registered: ‎07-27-2010
My Device: 8900

Re: USB Connection to the Desktop

Please, does anybody knows how can i send sms, from an application in pc, through a blackberry using usb data cable.?? 

 

please i need some kind of help or sample code..

 

thanks