BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 05-07-2010, 11:17 PM   #1 (permalink)
New Member
Join Date: May 2010
Model: none
Carrier: none
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default USB connection using stream level API

Please Login to Remove!

Hi all,

I'm new to BlackBerry programming, and I need your advise my friends...

I'm trying to establish USB connection between desktop and my device. I'm using JDK 4.7.

As we know it's to ways to establish connection through USB:

1. Using stream connection (

2. Using low-level API (USBPort)

I tried both ways, and I found problems in both situations:

1. Using first method we have stream functionality, and this is definitely advantage, but I can't figure out, how can I handle that connection was established? We are calling, and have as a return value valid StreamConnection object, than we are opening streams, and also have valid objects. It's no any analogue like AcceptAndOpen or something similar... One way that I see in this situation, is to open channel using connector, and than wait on blocking read on input stream, but this is workaround, and I don't really want to use it, because when you writing echo server for demonstration - it's one thing, but if you writing full functional system, it's quite different.

2. This method (low level) full opposite to first - you have a lot of control (callbacks using USBPortListener, writing/reading, etc), but in return, you should handle a lot of things manually, like for example: to send/receive big packets of data you should care about buffering, implementing receiving/sending is robust, because you should not only call read/write function, but you should handle callbacks like dataSent/dataReceived and so on, besides you should correctly handle all callbacks. And when you try to implement all this stuff, synchronize it, you starting to think something like "It should be something here another, simple solution, I need just to find it...".

So, the question: is it some possibility when we are using stream level API, to know that connection is established? Synchronous/asynchronous - doesn't matter. Or may be you know some other ways how to connect using USB without all these unneeded stuff?

Thank you in advance!

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