TTPA (Mobile)  1.1
BTS SN-IR La Salle Avignon 2018
 Tout Classes Fichiers Fonctions Variables
Classes | Fonctions membres publiques | Attributs publics statiques | Attributs privés
Référence de la classe com.ttpa.iris.ttpamobile.PeripheriqueBluetooth
Graphe de collaboration de com.ttpa.iris.ttpamobile.PeripheriqueBluetooth:
Collaboration graph
[légende]

Liste de tous les membres

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

Description détaillée

Created by smaniotto on 04/04/18.


Documentation des constructeurs et destructeur

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);
    }

Documentation des fonctions membres

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();
    }

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;
        }
    }

Documentation des données membres


La documentation de cette classe a été générée à partir du fichier suivant :
 Tout Classes Fichiers Fonctions Variables