I would like to scan the BLE devices on the Raspberry Pi in Java. I used the posted BLE scanning script (ibeacon_scan.sh) from the answer of jjnebeker. It works really great, when I start it on my UNIX laptop with the following Java code:
public void init(String[] commands){
// commands -> {"/bin/bash","-c","/<PATH>/ibeacon_scan.sh"}
ProcessBuilder processBuilder = new ProcessBuilder(commands);
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();
createAndStartProcessOutputHandlerThread(process);
}
private Thread createAndStartProcessOutputHandlerThread(Process process) {
Thread thread = new Thread(new Runnable() {
public void run() {
Scanner scan = null;
try {
scan = new Scanner(process.getInputStream());
while (true) {
if(scan.hasNext()){
String line = scan.nextLine();
LOG.info("LINE: ", line);
}
}
} finally {
if(scan != null) {
scan.close();
}
}
});
thread.start();
return thread;
}
I started the script as sudo on the Raspberry Pi and I get only empty lines but no other informations as exceptions or something else :(
EDIT: The script runs correctly when I execute it in the shell on the Raspberry Pi.
I have no idea how to fix this problem. Can you help me, please?