GrOOm  0.2
BTS SNIR LaSalle Avignon 2020
Référence de la classe com.example.groom.Communication

Déclaration de la classe Communication. Plus de détails...

Graphe de collaboration de com.example.groom.Communication:
Collaboration graph

Classes

class  TReception
 Déclaration de la classe TReception. Plus de détails...
 

Fonctions membres publiques

void attendre (int millis)
 Méthode pour attendre avant de passer à la prochaine ligne d'exécution. Plus de détails...
 
 Communication (BluetoothDevice device, Handler handler)
 Constructeur de la classe Communication. Plus de détails...
 
void connecter ()
 Méthode pour se connecter à l'appareil. Plus de détails...
 
boolean deconnecter ()
 Méthode pour se déconnecter de l'appareil. Plus de détails...
 
void envoyer (String data)
 Méthode pour envoyer une trame. Plus de détails...
 
String getAdresse ()
 Accesseur get de l'adresse. Plus de détails...
 
BluetoothDevice getDevice ()
 Accesseur get de l'appareil. Plus de détails...
 
String getNom ()
 Accesseur get du nom. Plus de détails...
 

Attributs publics statiques

static final int CODE_CONNEXION = 0
 Code de connexion. Plus de détails...
 
static final int CODE_DECONNEXION = 2
 Code de déconnexion. Plus de détails...
 
static final int CODE_RECEPTION = 1
 Code de réception d'une trame. Plus de détails...
 

Attributs privés

String adresse
 L'adresse. Plus de détails...
 
BluetoothDevice device
 L'objet device. Plus de détails...
 
Handler handler
 L'objet handler. Plus de détails...
 
String nom
 Le nom. Plus de détails...
 
InputStream receiveStream = null
 L'objet receiveStream. Plus de détails...
 
OutputStream sendStream = null
 L'objet sendStream. Plus de détails...
 
BluetoothSocket socket = null
 L'objet socket. Plus de détails...
 
TReception tReception
 L'objet tReception. Plus de détails...
 

Attributs privés statiques

static final String TAG = "Communication"
 TAG pour les logs. Plus de détails...
 

Description détaillée

Déclaration de la classe Communication.

Définition à la ligne 25 du fichier Communication.java.

Documentation des constructeurs et destructeur

◆ Communication()

com.example.groom.Communication.Communication ( BluetoothDevice  device,
Handler  handler 
)

Constructeur de la classe Communication.

Paramètres
deviceL'appareil où on va se connecter
handlerL'handler

Définition à la ligne 53 du fichier Communication.java.

Références com.example.groom.Communication.device, com.example.groom.Communication.getNom(), et com.example.groom.Communication.handler.

54  {
55  this.handler = handler;
56  if (device != null)
57  {
58  this.device = device;
59  this.nom = device.getName();
60  this.adresse = device.getAddress();
61 
62  try
63  {
64  socket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
65  receiveStream = socket.getInputStream();
66  sendStream = socket.getOutputStream();
67  }
68  catch (IOException e)
69  {
70  e.printStackTrace();
71  }
72  }
73  else
74  {
75  this.device = device;
76  this.nom = "Aucun";
77  this.adresse = "";
78  }
79 
80  if(socket != null)
81  tReception = new TReception(handler);
82  Log.v(TAG, "Communication() : Nom = " + getNom());
83  }
String getNom()
Accesseur get du nom.
static final String TAG
TAG pour les logs.
Handler handler
L'objet handler.
InputStream receiveStream
L'objet receiveStream.
BluetoothDevice device
L'objet device.
OutputStream sendStream
L'objet sendStream.
BluetoothSocket socket
L'objet socket.
TReception tReception
L'objet tReception.
String adresse
L'adresse.

Documentation des fonctions membres

◆ attendre()

void com.example.groom.Communication.attendre ( int  millis)

Méthode pour attendre avant de passer à la prochaine ligne d'exécution.

Paramètres
millisle temps d'attent en ms

Définition à la ligne 217 du fichier Communication.java.

218  {
219  try
220  {
221  Thread.sleep(millis);
222  }
223  catch (InterruptedException e)
224  {
225  e.printStackTrace();
226  }
227  }

◆ connecter()

com.example.groom.Communication.connecter ( )

Méthode pour se connecter à l'appareil.

Définition à la ligne 123 du fichier Communication.java.

Références com.example.groom.Communication.CODE_CONNEXION, et com.example.groom.Communication.getNom().

Référencé par com.example.groom.IHMGroom.onCreate().

124  {
125  new Thread()
126  {
127  @Override public void run()
128  {
129  try
130  {
131  socket.connect();
132 
133  Message msg = Message.obtain();
134  msg.what = CODE_CONNEXION;
135  handler.sendMessage(msg);
136 
137  if(tReception != null)
138  tReception.start();
139  Log.v(TAG, "connecter() : Nom = " + getNom());
140  }
141  catch (IOException e)
142  {
143  Log.d(TAG, "Erreur connect()");
144  e.printStackTrace();
145  }
146  }
147  }.start();
148  }
String getNom()
Accesseur get du nom.
static final String TAG
TAG pour les logs.
Handler handler
L'objet handler.
static final int CODE_CONNEXION
Code de connexion.
BluetoothSocket socket
L'objet socket.
TReception tReception
L'objet tReception.

◆ deconnecter()

com.example.groom.Communication.deconnecter ( )

Méthode pour se déconnecter de l'appareil.

Renvoie
boolean true si déconnecté, false si une erreur a été rencontrée

Définition à la ligne 156 du fichier Communication.java.

Références com.example.groom.Communication.TReception.arreter(), et com.example.groom.Communication.CODE_DECONNEXION.

Référencé par com.example.groom.IHMGroom.finish(), et com.example.groom.IHMGroom.onClick().

157  {
158  try
159  {
161 
162  socket.close();
163 
164  Message msg = Message.obtain();
165  msg.what = CODE_DECONNEXION;
166  handler.sendMessage(msg);
167 
168  return true;
169  }
170  catch (IOException e)
171  {
172  Log.d(TAG, "Erreur close()");
173  e.printStackTrace();
174  return false;
175  }
176  }
static final String TAG
TAG pour les logs.
Handler handler
L'objet handler.
static final int CODE_DECONNEXION
Code de déconnexion.
BluetoothSocket socket
L'objet socket.
TReception tReception
L'objet tReception.
void arreter()
Méthode pour arrêter la réception.

◆ envoyer()

com.example.groom.Communication.envoyer ( String  data)

Méthode pour envoyer une trame.

Paramètres
datales données à envoyer

Définition à la ligne 184 du fichier Communication.java.

Référencé par com.example.groom.IHMGroom.initialiserSaisieMessagePerso(), et com.example.groom.IHMGroom.onClick().

185  {
186  final String trame = data;
187 
188  if(socket == null)
189  return;
190 
191  new Thread()
192  {
193  @Override public void run()
194  {
195  try
196  {
197  if(socket.isConnected())
198  {
199  sendStream.write(trame.getBytes());
200  sendStream.flush();
201  Log.d(TAG, "envoyer() trame : " + trame);
202  }
203  }
204  catch (IOException e)
205  {
206  Log.d(TAG, "Erreur write()");
207  e.printStackTrace();
208  }
209  }
210  }.start();
211  }
static final String TAG
TAG pour les logs.
OutputStream sendStream
L'objet sendStream.
BluetoothSocket socket
L'objet socket.

◆ getAdresse()

com.example.groom.Communication.getAdresse ( )

Accesseur get de l'adresse.

Renvoie
String l'adresse

Définition à la ligne 102 du fichier Communication.java.

Références com.example.groom.Communication.adresse.

103  {
104  return adresse;
105  }
String adresse
L'adresse.

◆ getDevice()

com.example.groom.Communication.getDevice ( )

Accesseur get de l'appareil.

Renvoie
BluetoothDevice l'appareil

Définition à la ligne 113 du fichier Communication.java.

Références com.example.groom.Communication.device.

114  {
115  return device;
116  }
BluetoothDevice device
L'objet device.

◆ getNom()

com.example.groom.Communication.getNom ( )

Accesseur get du nom.

Renvoie
String le nom

Définition à la ligne 91 du fichier Communication.java.

Références com.example.groom.Communication.nom.

Référencé par com.example.groom.Communication.Communication(), et com.example.groom.Communication.connecter().

92  {
93  return nom;
94  }

Documentation des données membres

◆ adresse

String com.example.groom.Communication.adresse
private

L'adresse.

Définition à la ligne 40 du fichier Communication.java.

Référencé par com.example.groom.Communication.getAdresse().

◆ CODE_CONNEXION

final int com.example.groom.Communication.CODE_CONNEXION = 0
static

Code de connexion.

Définition à la ligne 31 du fichier Communication.java.

Référencé par com.example.groom.Communication.connecter().

◆ CODE_DECONNEXION

final int com.example.groom.Communication.CODE_DECONNEXION = 2
static

Code de déconnexion.

Définition à la ligne 33 du fichier Communication.java.

Référencé par com.example.groom.Communication.deconnecter().

◆ CODE_RECEPTION

final int com.example.groom.Communication.CODE_RECEPTION = 1
static

Code de réception d'une trame.

Définition à la ligne 32 du fichier Communication.java.

Référencé par com.example.groom.Communication.TReception.run().

◆ device

BluetoothDevice com.example.groom.Communication.device
private

L'objet device.

Attributs

Définition à la ligne 38 du fichier Communication.java.

Référencé par com.example.groom.Communication.Communication(), et com.example.groom.Communication.getDevice().

◆ handler

Handler com.example.groom.Communication.handler
private

L'objet handler.

Définition à la ligne 41 du fichier Communication.java.

Référencé par com.example.groom.Communication.Communication().

◆ nom

String com.example.groom.Communication.nom
private

Le nom.

Définition à la ligne 39 du fichier Communication.java.

Référencé par com.example.groom.Communication.getNom().

◆ receiveStream

InputStream com.example.groom.Communication.receiveStream = null
private

L'objet receiveStream.

Définition à la ligne 43 du fichier Communication.java.

◆ sendStream

OutputStream com.example.groom.Communication.sendStream = null
private

L'objet sendStream.

Définition à la ligne 44 du fichier Communication.java.

◆ socket

BluetoothSocket com.example.groom.Communication.socket = null
private

L'objet socket.

Définition à la ligne 42 du fichier Communication.java.

◆ TAG

final String com.example.groom.Communication.TAG = "Communication"
staticprivate

TAG pour les logs.

Constantes

Définition à la ligne 30 du fichier Communication.java.

◆ tReception

TReception com.example.groom.Communication.tReception
private

L'objet tReception.

Définition à la ligne 45 du fichier Communication.java.


La documentation de cette classe a été générée à partir du fichier suivant :