Exception: Bluetooth Device is not ready - java

My java application makes a bluetooth server and waits for connection.My program works fine in windows.
but when I try to run it in Linux it gives this error.How can I resolve this?
BlueCove version 2.1.1-SNAPSHOT on bluez
javax.bluetooth.BluetoothStateException: Bluetooth Device is not ready. [1] Operation not permitted
at com.intel.bluetooth.BluetoothStackBlueZ.nativeSetLocalDeviceDiscoverable(Native Method)
at com.intel.bluetooth.BluetoothStackBlueZ.setLocalDeviceDiscoverable(BluetoothStackBlueZ.java:307)
at javax.bluetooth.LocalDevice.setDiscoverable(LocalDevice.java:206)
at bluetoothjava.WaitThread.waitForConnection(WaitThread.java:32)
at bluetoothjava.WaitThread.run(WaitThread.java:18)
at java.base/java.lang.Thread.run(Thread.java:834)
BlueCove stack shutdown completed

Related

BlueCove cannot connect do Device "Permission Denied [13]"

I am trying to connect to a bluetooth device, which i can pair to when setting the target device in pair mode, but trying to reconnect with the following method causes errors.
The Code that causes it:
StreamConnection streamConnection = null;
try {
streamConnection = (StreamConnection)Connector.open("btspp://A0E6F8FECB26:1;authenticate=false;encrypt=false;master=false");
callback.onSocketCreated(streamConnection);
callback.onConnectionSucceed();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The Exception That occurs
java.io.IOException: Failed to connect. [13] Permission denied
at com.intel.bluetooth.BluetoothStackBlueZ.connectionRfOpenClientConnectionImpl(Native Method)
at com.intel.bluetooth.BluetoothStackBlueZ.connectionRfOpenClientConnection(BluetoothStackBlueZ.java:574)
at com.intel.bluetooth.BluetoothRFCommClientConnection.<init>(BluetoothRFCommClientConnection.java:37)
at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:379)
at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:162)
at javax.microedition.io.Connector.open(Connector.java:83)
at insight.utils.ConnectionEstablisher.run(ConnectionEstablisher.java:170)
I have to use Java and this is the only Library I found (That somewhat works) for this purpose:
BlueCove version 2.1.1-SNAPSHOT on bluez
I am on Arch Linux with the newest bluez Version and I have already tried This Fix to no avail.
Any help is appreciated
So essentially, the issue was the entire Bluetooth Stack / how it propagates "pairing requests" to the Bluetooth Stack.
As a sidenote I was using BlueZ (5.56) on Arch Linux and the bluecove library for Java.
I was looking into alternative Bluetooth Stacks and thought about trying the same code on Windows 10, which doesnt use the BlueZ Stack.
Windows then popped up a window where it asked if i wanted to pair to this device.
This was the main difference between Windows and Linux.
Windows / its bluetooth stack or whatever is responsible for it, actually registered the device as "paired".
This then allowed me to re-connect to the device without any "Permission Denied" issues.
Hope this helps anyone that has to deal with this library or has similar issues.

Android Studio debug native code lldb server work infinity

I have Android app which are writed use Java and C++/JNI code. My C++/JNI part work bad. I want to debug native code.
I work in Android Studio.
I did all step which take official site
enter link description here
But when I start debug I see line
Starting LLDB server
And he does not finish. I wait 30 min but he does not finish.
What I must to do. Because I think this bug or I must to take some settings.
I found error. But I did not understand. When I test app from USB cable all work good. But when I want to test my app through wifi (I use Android Wifi ADB) LLDB Debug server start, but not attach to process.
If I debug java code use java debugger all work good.
All output in debug console:
Connecting to org.temp.test
Waiting for application to start debug server
Waiting for application to come online: org.temp.test.test | org.temp.test
Connecting to org.temp.test
Now Launching Native Debug Session
Starting LLDB server: /data/data/org.temp.test/lldb/bin/start_lldb_server.sh /data/data/org.temp.test/lldb unix-abstract /data/data/org.temp.test/lldb/tmp platform-1524470360668.sock "lldb process:gdb-remote packets"

Error Win XP setting serial port state

I have the following code fragment to show a HELLO WORLD by a USB Device (Display Posiflex PD-2800 for POS).
I use the GiovynetDrive library to manage a virtual COM port.
The code runs perfectly (assuming the COM3 is available).
SerialPort = new SerialPort();
Parameters settings = new Parameters();
settings.setPort("COM3");
settings.setBaudRate(Baud._19200);
Port = new Com(settings); //<<--Seting crash when restart
Port.sendString("HELLO WORLD");
Port.close();
My problem is that when I turn off the computer, it doesn't turn off the device (USB power). This cause that the next startup, the code throws the Exception:
java.lang.Exception: Error setting serial port COM3 state.
at giovynet.nativelink.SerialPort.openPortC(Native Method)
at giovynet.serial.Com.<init>(Com.java:48)
.........
This forces me to unplug and plug the USB device and then it works well again.
I think this behavior of the S.O. is configurable, but I don't know as.
UPDATE:
When the USB device is in the restart pending state, I can make a print test without problems using a text only printer (generic driver of the S.O.). Then I can see the print test by my viewer but from my java code still not working until I unplug it.
The S.O. is Windows XP and the USB root HUB (of the device management) have unabled the option "Allow the computer turn off the device to save energy".

How to resolve java errors that pop up when loading Mirth Connect Administrator

I recently inherited a server running Mirth Connect with little documentation. The Mirth Connect server itself is running fine on the server, and I am able to connect to the web portal via port 8443 (and can log into the web-based administrator without any issues).
My problems occur when I run the ice tea java web start. Things go fine up until I enter my credentials and the interface starts to build; I receive the following error notice:
Could not load code template plugin: com.mirth.connect.connectors.http.HttpSenderCodeTe mplatePlugin
net.sourceforge.jnlp.runtime.JNLPClassLoader.loadClass(JNLPClassLoader.java:1535)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:191)
com.mirth.connect.client.ui.LoadedExtensions.initialize(LoadedExtensions.java:131)
com.mirth.connect.client.ui.Frame.initializeExtens ions(Frame.java:484)
com.mirth.connect.client.ui.Frame.setupFrame(Frame .java:382)
com.mirth.connect.client.ui.Mirth.<init>(Mirth.jav a:62)
com.mirth.connect.client.ui.LoginPanel$8.doInBackg round(LoginPanel.java:438)
com.mirth.connect.client.ui.LoginPanel$8.doInBackg round(LoginPanel.java:407)
javax.swing.SwingWorker$1.call(SwingWorker.java:29 6)
java.util.concurrent.FutureTask.run(FutureTask.jav a:262)
javax.swing.SwingWorker.run(SwingWorker.java:335)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
It pops up when the login dialog reads: "Please wait, loading extensions" and it continuously pops up until the dialog reads: "Please wait, loading channel editor" at which point the dialog box seems stuck on that loading screen.
I am using Mirth Connect 3.1.1, running it on Ubuntu 14.04 on an AWS EC2 instance, with Java version 1.7.0_76
Are there any generic reasons as to why this might occur? Any suggestions as to how I can investigate and resolve this?
Can you try clearing java cache, because i had this type of issue and clearing java cache worked for me .

Android app force closing when opening amarino connection

I am new to android development, and have run into a problem I seem unable to solve.
My android app should be able to communicate with my arduino device, sending info
to and retrieving info from my device. I have set up my connection between the two
with a bluetooth device and I am using amarino to facilitate the communication.
Now I can connect with amarino and send data and receive data, now I want to do this from
my app. The problem comes when I enter this line:
private static final String DEVICE_ADDRESS = "07:12:04:16:68:18";
Amarino.connect(this, DEVICE_ADDRESS);
The number is the MAC address of my bluetooth adapter connected to my arduino device.
As soon as I run my app on my phone it just force closes due to unexpected error.
Now as I said, I am a bit of a noob when it comes to android, so I installed logCat to try get some log info out of it. All I got from it was this somewhat unhelpful error message:
com.example.projectgreetv3/.StartingPlace
10-24 15:22:55.140 E/AndroidRuntime(4906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.projectgreetv3/com.example.projectgreetv3.StartingPlace}: java.lang.ClassNotFoundException: com.example.projectgreetv3.StartingPlace in loader dalvik.system.PathClassLoader[/data/app/com.example.projectgreetv3-1.apk]
10-24 15:22:55.140 E/AndroidRuntime(4906): Caused by: java.lang.ClassNotFoundException: com.example.projectgreetv3.StartingPlace in loader dalvik.system.PathClassLoader[/data/app/com.example.projectgreetv3-1.apk]
10-24 15:22:55.148 W/ActivityManager(539): Force finishing activity com.example.projectgreetv3/.StartingPlace
10-24 15:21:51.726 I/UinboxLogger(4585): [UinboxReceiver] onReceive() >> intent.getData() : com.example.projectgreetv3
10-24 15:21:52.382 I/UninstallAppProgress(4575): Finished uninstalling pkg: com.example.projectgreetv3
10-24 15:22:52.523 D/PackageManager(539): Scanning package com.example.projectgreetv3
I hope someone can help me with this, as I am on wits end.
For more info on:
- Arduino:
- http://www.arduino.cc/
- Amarino:
http://www.amarino-toolkit.net/
If you look a bit further down on your stacktrace (in the logcat) you will probably see that the cause of this crash is an NetworkOnMainThreadException. (If you are running Android 3.0 or higher)
Please make sure that you do all your network communication on a separate thread (Thread/ASyncTask).
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

Categories

Resources