Classes | |
class | TReception |
Fonctions membres publiques | |
PeripheriqueBluetooth (BluetoothDevice device, Handler handler) | |
BluetoothDevice | getDevice () |
String | getNom () |
String | getAdresse () |
boolean | estConnecte () |
void | setNom (String nom) |
String | toString () |
void | envoyer (String data) |
void | connecter () |
boolean | deconnecter (boolean fermeture) |
Attributs publics statiques | |
static final int | CODE_CONNEXION = 0 |
static final int | CODE_RECEPTION = 1 |
static final int | CODE_DECONNEXION = 2 |
Attributs privés | |
String | nom |
String | adresse |
Handler | handler = null |
BluetoothDevice | device = null |
BluetoothSocket | socket = null |
InputStream | receiveStream = null |
OutputStream | sendStream = null |
TReception | tReception |
Created by smaniotto on 04/04/18.
com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.PeripheriqueBluetooth | ( | BluetoothDevice | device, |
Handler | handler | ||
) |
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.adresse, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.device, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.handler, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.nom, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.receiveStream, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.sendStream, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.socket, et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.tReception.
{ if(device != null) { this.device = device; this.nom = device.getName(); this.adresse = device.getAddress(); this.handler = handler; } else { this.device = device; this.nom = "Aucun"; this.adresse = ""; this.handler = handler; } try { System.out.println("<Bluetooth> nom " + device.getName()); ParcelUuid[] uuids = device.getUuids(); if(uuids != null) for(int i = 0; i < uuids.length; i++) System.out.println("<Bluetooth> uuid " + uuids[i].getUuid().toString()); else System.out.println("<Bluetooth> uuid null !"); socket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB")); //socket = device.createRfcommSocketToServiceRecord(uuids[0].getUuid()); System.out.println("<Bluetooth> new socket"); // API 23 //System.out.println("<Bluetooth> max receive packet size : " + socket.getMaxReceivePacketSize()); //System.out.println("<Bluetooth> max transmit packet size : " + socket.getMaxTransmitPacketSize()); //System.out.println("<Bluetooth> connection type : " + socket.getConnectionType()); receiveStream = socket.getInputStream(); sendStream = socket.getOutputStream(); } catch (IOException e) { e.printStackTrace(); System.out.println("<Bluetooth> Erreur socket !"); socket = null; } if(socket != null) tReception = new TReception(handler); }
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.CODE_CONNEXION, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.getAdresse(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.getNom(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.handler, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.socket, et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.tReception.
Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothLanceur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothTable().
{ new Thread() { @Override public void run() { try { System.out.println("<Bluetooth> socket connect ..."); socket.connect(); System.out.println("<Bluetooth> socket connect ok"); Message msg = Message.obtain(); //msg.arg1 = CODE_CONNEXION; Bundle b = new Bundle(); b.putString("nom", getNom()); b.putString("adresse", getAdresse()); b.putInt("etat", CODE_CONNEXION); b.putString("donnees", ""); msg.setData(b); handler.sendMessage(msg); tReception.start(); } catch (IOException e) { System.out.println("<Bluetooth> Erreur connect !"); e.printStackTrace(); } } }.start(); }
boolean com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.deconnecter | ( | boolean | fermeture | ) |
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.TReception.arreter(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.socket, et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.tReception.
Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.deconnexionPeripheriquesBluetooth().
{ try { //if(estConnecte()) { tReception.arreter(); if(fermeture) { socket.close(); System.out.println("<Bluetooth> socket close"); } return true; } } catch (IOException e) { System.out.println("<Bluetooth> Erreur close !"); e.printStackTrace(); return false; } }
void com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.envoyer | ( | String | data | ) |
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.sendStream, et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.socket.
Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothTable(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameDebutSeancePeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTramePeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTramePeripheriqueBluetoothLanceur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameRepriseSeancePeripheriqueBluetoothLanceur().
{ if(socket == null) return; try { //if(estConnecte()) if(socket.isConnected()) { System.out.println("<Bluetooth> Envoyer " + data); sendStream.write(data.getBytes()); sendStream.flush(); } else { System.out.println("<Bluetooth> Envoyer (non connecté) " + data); } } catch (IOException e) { System.out.println("<Bluetooth> Erreur socket write !"); e.printStackTrace(); } }
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.socket.
Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothTable(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothTable(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameDebutSeancePeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTramePeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTramePeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameRepriseSeancePeripheriqueBluetoothLanceur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.verifierConnexionAppareilsBluetoothRequis().
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.adresse.
Référencé par com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter(), et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.TReception.run().
{ return adresse; }
BluetoothDevice com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.getDevice | ( | ) |
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.device.
{ return device; }
Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.nom.
Référencé par com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter(), et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.TReception.run().
{ return nom; }
void com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.setNom | ( | String | nom | ) |
String com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.adresse [private] |
final int com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.CODE_CONNEXION = 0 [static] |
Référencé par com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter().
final int com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.CODE_DECONNEXION = 2 [static] |
final int com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.CODE_RECEPTION = 1 [static] |
BluetoothDevice com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.device = null [private] |
Handler com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.handler = null [private] |
String com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.nom [private] |
InputStream com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.receiveStream = null [private] |
OutputStream com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.sendStream = null [private] |
BluetoothSocket com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.socket = null [private] |
Référencé par com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.deconnecter(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.envoyer(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), et com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.PeripheriqueBluetooth().