11-06-2008 06:38 PM
I don't get the Major and Minor device class on a 8703e. Any idea why?
Here is the result of the code below execute on 3 differents phone:
8703e v4.2.1.110 (Platform 2.3.0.22)
Found: 001641D886FB, Major:0, Minor:0
Found: 001CCCBA3F0F, Major:0, Minor:0
Found: 0019A1EDD64A, Major:0, Minor:0
Found: 008098D4BB48, Major:0, Minor:0
8700 v4.2.1.101 (Platform 2.3.0.81)
Found: 001641D886FB, Major:0, Minor:0
Found: 001CCCBA3F0F, Major:0, Minor:0
Found: 0019A1EDD64A, Major:0, Minor:0
Found: 008098D4BB48, Major:1f00, Minor:0
8330 v4.3.0.124 (Platform 3.1.0.71)
Found: 001641D886FB, Major:100, Minor:c
Found: 001CCCBA3F0F, Major:200, Minor:c
Found: 0019A1EDD64A, Major:200, Minor:4
Found: 008098D4BB48, Major:1f00, Minor:0
The first 3 device found are other cell phone around in the office (I don't care for those). The 4th one though is the one I'm interested in (it's our device based on a Azuro Bluetooth OEM module).
Here is the code:
package pascal;
import net.rim.device.api.ui.UiApplication;
public class BTDeviceClass extends UiApplication {
public static BTDeviceClass app;
public static void main(String[] args) {
try {
app = new BTDeviceClass();
app.pushScreen(BTDeviceClassScreen.getInstance());
app.enterEventDispatcher();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
package pascal;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import javax.bluetooth.*;
public class BTDeviceClassScreen extends MainScreen implements DiscoveryListener {
static final String NEWLINE = "\n";
private RichTextField resultField;
private MenuItem searchMenu;
private StringBuffer sbuf;
DiscoveryAgent agent;
BTDeviceClassScreen() {
sbuf = new StringBuffer();
}
public static BTDeviceClassScreen getInstance() throws BluetoothStateException {
BTDeviceClassScreen instance = new BTDeviceClassScreen();
instance.initUI();
instance.agent = LocalDevice.getLocalDevice().getDiscoveryAgent();
return instance;
}
void doSearchMenu() throws BluetoothStateException {
sbuf.setLength(0);
agent.startInquiry(DiscoveryAgent.GIAC, this);
}
private void appendLine(String string) {
sbuf.append(string).append(NEWLINE);
synchronized (UiApplication.getEventLock()) {
resultField.setText(sbuf.toString());
}
}
private void initUI() {
add(getResultField());
}
private Field getResultField() {
if (resultField==null)
resultField = new RichTextField();
return resultField;
}
protected void makeMenu(Menu menu, int instance) {
menu.add(getSearchMenu());
}
private MenuItem getSearchMenu() {
if (searchMenu==null) {
searchMenu = new MenuItem("Search", 1, 10) {
public void run() {
try {
doSearchMenu();
} catch (BluetoothStateException e) {
e.printStackTrace();
appendLine(e.toString());
}
}
};
}
return searchMenu;
}
public void deviceDiscovered(RemoteDevice device, DeviceClass deviceClass) {
appendLine("Found: " + device.getBluetoothAddress()
+ ", Major:" + Integer.toHexString(deviceClass.getMajorDeviceClass())
+ ", Minor:" + Integer.toHexString(deviceClass.getMinorDeviceClass()));
}
public void inquiryCompleted(int discType) {
appendLine("Search Completed: " + discType);
}
public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
}
public void serviceSearchCompleted(int transID, int respCode) {
}
}
Solved! Go to Solution.
11-10-2008 05:24 PM
11-10-2008 05:42 PM
Did you try pairing your device first? I ran into a problem where the device class numbers are zero if the device is not paired. This was confirmed by RIM as a bug in 4.2.1
http://supportforums.blackberry.com/rim/board/mess
To work around this I had to implement logic that checks the friendly name as a back up.
11-10-2008 05:47 PM
RIGHT ON!!!
Thank you very much! I was getting more pressure from the management to solve this one ![]()