Skip to content
Snippets Groups Projects
Commit 9962c01f authored by Puissegur Alexis's avatar Puissegur Alexis
Browse files

jsp ce que j'ai fait

parent cc794012
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ public class BluetoothManager implements DiscoveryListener {
private final List<BluetoothConnection> connections = new ArrayList<BluetoothConnection>();
private BluetoothThread t;
private FXMLVueController observer;
private static final String THINGZ_ID = "201611073171";
public BluetoothThread getWorkingThread(){
return t;
}
......@@ -76,7 +76,6 @@ public class BluetoothManager implements DiscoveryListener {
@Override
public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
System.out.println("hey ! " + servRecord);
for(ServiceRecord s : servRecord) {
System.out.println("-------"+ s + "-------");
}
......@@ -92,7 +91,7 @@ public class BluetoothManager implements DiscoveryListener {
DiscoveryAgent agent = localDevice.getDiscoveryAgent();
RemoteDevice[] devices = agent.retrieveDevices(DiscoveryAgent.PREKNOWN);
for(RemoteDevice d : devices) {
if(d.getBluetoothAddress().equals("201611073171")) {
if(d.getBluetoothAddress().equals(THINGZ_ID)) {
System.out.println("Thingz trouve");
synchronized(lock) {
int result = agent.searchServices(null, desiredServiceUuids, d, this);
......@@ -101,12 +100,9 @@ public class BluetoothManager implements DiscoveryListener {
continue;
}
lock.wait();
System.out.println("service records found");
if(null != serviceRecords && serviceRecords.size() > 0) {
System.out.println("YA DES SERVICES");
System.out.println("service records found");
for(ServiceRecord serviceRecord: serviceRecords) {
String connectionUrl = serviceRecord.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false); // I have no idea what these args are
StreamConnection connection;
......
......@@ -6,10 +6,11 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.misc.IOUtils;
public class BluetoothThread extends Thread {
private static final int PACKET_SIZE = 18;
private BluetoothConnection connection;
private boolean keepGoing = true;
private String buffer;
......@@ -34,13 +35,10 @@ public class BluetoothThread extends Thread {
byte b;
try {
// Each packet must start with two SYNC bytes in a row
byte[] payload = new byte[16];
byte[] payload = new byte[PACKET_SIZE];
connection.getInputStream().read(payload);
this.buffer = new String(payload, StandardCharsets.UTF_8);
notifyObserver();
//connection.getOutputStream().write("SOUND".getBytes());
notifyObserver();
} catch (Exception e) {
System.out.println("Could not read stream" + e);
}
......@@ -74,5 +72,10 @@ public class BluetoothThread extends Thread {
}
}
}
public void sendInstruction(String instruction)throws IOException {
connection.getOutputStream().write(instruction.getBytes());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment