Projet TTPA (Table Tennis Performance Analyser)  1.3
BTS SN 2019
Types publics | Connecteurs publics | Signaux | Fonctions membres publiques | Propriétés | Fonctions membres privées | Attributs privés | Liste de tous les membres
Référence de la classe CommunicationBluetooth

Assure la détection des périphériques TTPA, leur connexion (et déconnexion) et une communication (envoyer et recevoir des trames) Plus de détails...

#include <communicationbluetooth.h>

Graphe de collaboration de CommunicationBluetooth:
Collaboration graph

Types publics

enum  EtatSeance { Initial = 0, EnCours = 1, EnPause = 2, Terminee }
 
enum  EtatDeLaSeance { Initial = 0, EnCours = 1, EnPause = 2, Arretee }
 

Connecteurs publics

void nouveauClient ()
 
void socketConnected ()
 la socket est connecté Plus de détails...
 
void socketDisconnected ()
 la socket est déconnecté Plus de détails...
 
void socketReadyRead ()
 la socket est prête à lire les informations Plus de détails...
 
void socketErreur (QBluetoothSocket::SocketError error)
 la socket indique une erreur de connexion Plus de détails...
 
void deviceConnected (const QBluetoothAddress &adresse)
 
void deviceDisconnected (const QBluetoothAddress &adresse)
 
void error (QBluetoothLocalDevice::Error erreur)
 
void ajouterPeripheriqueTTPA (const QBluetoothDeviceInfo &)
 
void rechercheTerminee ()
 
void rechercheErreur (QBluetoothDeviceDiscoveryAgent::Error erreur)
 
void recevoirTramePeripheriqueTTPA (QString nomPeripherique, QString trame)
 

Signaux

void connecte ()
 
void erreur ()
 
void impactZone (QString numeroZone)
 
void departSeance (QString nomJoueur, QString zoneObjectif, QString zoneRobot)
 
void mettreEnPauseSeance ()
 Met la séance en pause. Plus de détails...
 
void repriseSeance ()
 
void finSeance ()
 
void resetSeance ()
 
void recherche ()
 signal indiquant que l'état de la recherche de périphériques a changé Plus de détails...
 
void detecte ()
 
void fini ()
 
void robotDetecte ()
 
void ecranDetecte ()
 
void tableDetecte ()
 
void peripheriquesTTPAUpdated ()
 
void erreurRobot ()
 

Fonctions membres publiques

 CommunicationBluetooth (QObject *parent=nullptr)
 
 ~CommunicationBluetooth ()
 Définition du destructeur la classe CommunicationBluetooth. Plus de détails...
 
EtatSeance getEtatSeance ()
 
void demarrer ()
 demarre le serveur Plus de détails...
 
void arreter ()
 arrete le serveur Plus de détails...
 
 CommunicationBluetooth ()
 Définition du constructeur la classe CommunicationBluetooth. Plus de détails...
 
 ~CommunicationBluetooth ()
 
EtatDeLaSeance getEtatSeance ()
 
Q_INVOKABLE void rechercherPeripheriquesTTPA ()
 Assure la recherche d'appareils bluetooth "TTPA". Plus de détails...
 
Q_INVOKABLE void arreterRecherche ()
 Permet d'arreter la recherche des appareils bluetooth "TTPA". Plus de détails...
 
Q_INVOKABLE bool estValide ()
 Retourne vrai si l'appareil correspond à un appareil "TTPA". Plus de détails...
 
Q_INVOKABLE void connecterPeripheriquesTTPA ()
 Connecte individuelle chaque appareil TTPA détecté Plus de détails...
 
Q_INVOKABLE void deconnecterPeripheriquesTTPA ()
 Déconnecte individuelle chaque appareil TTPA détecté Plus de détails...
 
Q_INVOKABLE bool envoyerPeripheriqueTTPA (QString nom, QString message)
 Permet d'envoyer une trame à un périphérique TTPA identifié par son nom. Plus de détails...
 
Q_INVOKABLE bool demarrerSeance (QString nomJoueur, QString zoneObjectif, QString zoneRobot, int frequenceBalle, int nbBalles, int effet, int puissance, bool rotation)
 
Q_INVOKABLE bool demarrerSeanceRobot (int frequenceBalle, int nbBalles, int effet, int puissance, bool rotation)
 Envoi une trame contenant les paramètres du robot au robot-ttpa. Plus de détails...
 
Q_INVOKABLE bool demarrerSeanceEcran (QString nomJoueur, QString zoneObjectif, QString zoneRobot)
 Envoi une trame de démarrage de séance à l'ecran. Plus de détails...
 
Q_INVOKABLE bool demarrerSeanceTable (int nbBalles)
 Envoi une trame de démarrage de séance à la table. Plus de détails...
 
Q_INVOKABLE bool mettreEnPauseSeance ()
 
Q_INVOKABLE bool reprendreLaSeance ()
 Reprend la séance. Plus de détails...
 
Q_INVOKABLE bool arreterSeance ()
 Met subitement fin à la séance peut importe son état. Plus de détails...
 
bool finirSeance ()
 Met fin à la séance lorsque le robot indique qu'il à tirer toutes ses balles. Plus de détails...
 
bool envoyerZoneImpactee (QString zone)
 Dès que la table envoie une trame contenant la zone impactée, la méthode l'envoie à l'écran ttpa. Plus de détails...
 
bool envoyerErreurRobot ()
 Si le robot détecte un bourrage de balle ou une absence de balle, une trame est envoyée à l'écran ttpa. Plus de détails...
 
Q_INVOKABLE QString getZoneObjectif (QString zoneObjectif)
 Permet d'obtenir la zone objectif. Plus de détails...
 
Q_INVOKABLE QString getZoneRobot (QString zoneRobot)
 Permet d'obtenir la zone robot. Plus de détails...
 
Q_INVOKABLE PeripheriqueTTPAgetPeripheriqueTTPA (QString nom)
 
QString getNomPeripheriqueBluetoothLocal ()
 
QString getAdressePeripheriqueBluetoothLocal ()
 
QVariant getPeripheriquesTTPA ()
 

Propriétés

QString nomPeripheriqueBluetoothLocal
 le nom du périphérique Bluetooth de la tablette Plus de détails...
 
QString adressePeripheriqueBluetoothLocal
 l'adresse MAC du périphérique Bluetooth de la tablette Plus de détails...
 
bool peripheriqueEcranTTPADetecte
 
bool peripheriqueTableTTPADetecte
 
bool peripheriqueRobotTTPADetecte
 
bool etatRecherche
 
QVariant peripheriquesTTPA
 
bool erreurRobotDetecte
 

Fonctions membres privées

void decoderTrame (QString trame)
 permet de décoder la trame émise par le terminal mobile Plus de détails...
 

Attributs privés

QBluetoothLocalDevice monBluetooth
 
QBluetoothServer * serveur
 
QBluetoothSocket * socket
 la socket Plus de détails...
 
QBluetoothServiceInfo serviceInfo
 
QString nom
 
QString adresse
 
bool etatConnexion
 L'état de connexion. Plus de détails...
 
bool connexionErreur
 Savoir si il a une erreur de connexion. Plus de détails...
 
EtatSeance etatSeance
 
QBluetoothLocalDevice peripheriqueBluetoothLocal
 le périphérique Bluetooth de la tablette Plus de détails...
 
QList< QObject * > peripheriquesTTPA
 liste des périphériques Bluetooth TTPA détectés au maximum 3 (Robot, Table et Ecran) Plus de détails...
 
QBluetoothDeviceDiscoveryAgent * discoveryAgentDevice
 l'agent permettant de découvrir des périphériques Bluetooth Plus de détails...
 
EtatDeLaSeance etatSeance
 

Description détaillée

Auteur
Hammouma Youssef
Version
0.1
Date
20/03/2019 10:30:20

Documentation des énumérations membres

◆ EtatDeLaSeance

Valeurs énumérées
Initial 
EnCours 
EnPause 
Arretee 
55  {
56  Initial = 0,
57  EnCours = 1,
58  EnPause = 2,
59  Arretee
60  };
Definition: terminal-TTPA/communicationbluetooth.h:59
Definition: ecran-TTPA/communicationbluetooth.h:40
Definition: ecran-TTPA/communicationbluetooth.h:39
Definition: ecran-TTPA/communicationbluetooth.h:41

◆ EtatSeance

Valeurs énumérées
Initial 
EnCours 
EnPause 
Terminee 
38  {
39  Initial = 0,
40  EnCours = 1,
41  EnPause,
42  Terminee
43  };
Definition: ecran-TTPA/communicationbluetooth.h:40
Definition: ecran-TTPA/communicationbluetooth.h:39
Definition: ecran-TTPA/communicationbluetooth.h:41
Definition: ecran-TTPA/communicationbluetooth.h:42

Documentation des constructeurs et destructeur

◆ CommunicationBluetooth() [1/2]

CommunicationBluetooth::CommunicationBluetooth ( QObject *  parent = nullptr)

Références adresse, connexionErreur, deviceConnected(), deviceDisconnected(), error(), etatConnexion, etatSeance, monBluetooth, et nom.

26  : QObject(parent), serveur(nullptr), socket(nullptr)
27 {
28  qDebug() << Q_FUNC_INFO;
29  etatConnexion = false;
30  connexionErreur = false;
31  etatSeance = EtatSeance::Initial;
32  if (!monBluetooth.isValid())
33  {
34  qDebug() << Q_FUNC_INFO << "Bluetooth valide" << monBluetooth.isValid();
35  return;
36  }
37 
38  //qDebug() << Q_FUNC_INFO << monBluetooth.hostMode();
39  monBluetooth.powerOn();
40  nom = monBluetooth.name();
41  adresse = monBluetooth.address().toString();
42  qDebug() << Q_FUNC_INFO << "nom" << nom << "adresse" << adresse;
43  monBluetooth.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
44  //monBluetooth.setHostMode(QBluetoothLocalDevice::HostConnectable);
45 
46  connect(&monBluetooth, SIGNAL(deviceConnected(QBluetoothAddress)), this, SLOT(deviceConnected(QBluetoothAddress)));
47  connect(&monBluetooth, SIGNAL(deviceDisconnected(QBluetoothAddress)), this, SLOT(deviceDisconnected(QBluetoothAddress)));
48  connect(&monBluetooth, SIGNAL(error(QBluetoothLocalDevice::Error)), this, SLOT(error(QBluetoothLocalDevice::Error)));
49 }
QString adresse
Definition: ecran-TTPA/communicationbluetooth.h:55
bool connexionErreur
Savoir si il a une erreur de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:57
QString nom
Definition: ecran-TTPA/communicationbluetooth.h:54
QBluetoothLocalDevice monBluetooth
Definition: ecran-TTPA/communicationbluetooth.h:50
QBluetoothSocket * socket
la socket
Definition: ecran-TTPA/communicationbluetooth.h:52
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
void deviceConnected(const QBluetoothAddress &adresse)
Definition: ecran-TTPA/communicationbluetooth.cpp:271
QBluetoothServer * serveur
Definition: ecran-TTPA/communicationbluetooth.h:51
void deviceDisconnected(const QBluetoothAddress &adresse)
Definition: ecran-TTPA/communicationbluetooth.cpp:276
bool etatConnexion
L&#39;état de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:56
void error(QBluetoothLocalDevice::Error erreur)
Definition: ecran-TTPA/communicationbluetooth.cpp:281

◆ ~CommunicationBluetooth() [1/2]

CommunicationBluetooth::~CommunicationBluetooth ( )
Paramètres
parentQObject*

Références arreter(), et monBluetooth.

Référencé par CommunicationBluetooth().

61 {
62  arreter();
63  monBluetooth.setHostMode(QBluetoothLocalDevice::HostPoweredOff);
64  qDebug() << Q_FUNC_INFO;
65 }
QBluetoothLocalDevice monBluetooth
Definition: ecran-TTPA/communicationbluetooth.h:50
void arreter()
arrete le serveur
Definition: ecran-TTPA/communicationbluetooth.cpp:235

◆ CommunicationBluetooth() [2/2]

CommunicationBluetooth::CommunicationBluetooth ( )
Paramètres
parentQObject*

Références adressePeripheriqueBluetoothLocal, ajouterPeripheriqueTTPA(), discoveryAgentDevice, error(), etatSeance, nomPeripheriqueBluetoothLocal, peripheriqueBluetoothLocal, peripheriquesTTPA, rechercheErreur(), rechercheTerminee(), et ~CommunicationBluetooth().

20 {
21  qDebug() << Q_FUNC_INFO;
22  if (!peripheriqueBluetoothLocal.isValid())
23  {
24  qDebug() << Q_FUNC_INFO << "Bluetooth désactivé !";
25  //qCritical("Bluetooth désactivé !");
26  return;
27  }
28 
29  // Le Bluetooth de la tablette
34 
35  // Recherche
36  peripheriqueBluetoothLocal.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
37  discoveryAgentDevice = new QBluetoothDeviceDiscoveryAgent(this);
38 
39  // Slot pour la recherche de périphériques Bluetooth TTPA
40  connect(discoveryAgentDevice, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this,
41 SLOT(ajouterPeripheriqueTTPA(QBluetoothDeviceInfo)));
42  connect(discoveryAgentDevice, SIGNAL(canceled()), this, SLOT(rechercheTerminee()));
43  connect(discoveryAgentDevice, SIGNAL(finished()), this, SLOT(rechercheTerminee()));
44  connect(discoveryAgentDevice, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(rechercheErreur(QBluetoothDeviceDiscoveryAgent::Error)));
45 
46  etatSeance = EtatDeLaSeance::Initial;
47 }
QString nomPeripheriqueBluetoothLocal
le nom du périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:41
bool peripheriqueRobotTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:45
QString adressePeripheriqueBluetoothLocal
l&#39;adresse MAC du périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:42
void rechercheErreur(QBluetoothDeviceDiscoveryAgent::Error erreur)
Definition: terminal-TTPA/communicationbluetooth.cpp:363
bool peripheriqueEcranTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:43
void rechercheTerminee()
Definition: terminal-TTPA/communicationbluetooth.cpp:355
void ajouterPeripheriqueTTPA(const QBluetoothDeviceInfo &)
Definition: terminal-TTPA/communicationbluetooth.cpp:309
QBluetoothLocalDevice peripheriqueBluetoothLocal
le périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:220
bool etatRecherche
Definition: terminal-TTPA/communicationbluetooth.h:46
QBluetoothDeviceDiscoveryAgent * discoveryAgentDevice
l&#39;agent permettant de découvrir des périphériques Bluetooth
Definition: terminal-TTPA/communicationbluetooth.h:224
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
bool peripheriqueTableTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:44
void error(QBluetoothLocalDevice::Error erreur)
Definition: ecran-TTPA/communicationbluetooth.cpp:281

◆ ~CommunicationBluetooth() [2/2]

CommunicationBluetooth::~CommunicationBluetooth ( )

Documentation des fonctions membres

◆ ajouterPeripheriqueTTPA

void CommunicationBluetooth::ajouterPeripheriqueTTPA ( const QBluetoothDeviceInfo &  info)
slot

Références arreterRecherche(), detecte(), peripheriqueEcranTTPADetecte, peripheriqueRobotTTPADetecte, peripheriquesTTPA, et peripheriqueTableTTPADetecte.

Référencé par CommunicationBluetooth().

310 {
311  qDebug() << Q_FUNC_INFO << info.name() << info.address().toString();
312 
313  if(info.name() == "table-ttpa-2")
314  {
315  qDebug() << Q_FUNC_INFO << "périphérique Table TTPA découvert" << info.name();
316  PeripheriqueTTPA *tableTTPA = new PeripheriqueTTPA(info.name(), info.address().toString(), this);
317  peripheriquesTTPA.append(tableTTPA);
319  emit detecte();
320  }
321 
322  if(info.name() == "robot-ttpa-11")
323  {
324  qDebug() << Q_FUNC_INFO << "périphérique Robot TTPA découvert" << info.name();
325  PeripheriqueTTPA *robotTTPA = new PeripheriqueTTPA(info.name(), info.address().toString(), this);
326  peripheriquesTTPA.append(robotTTPA);
328  emit detecte();
329  }
330 
331  if(info.name() == "ecran-ttpa-2")
332  {
333  qDebug() << Q_FUNC_INFO << "périphérique Ecran TTPA découvert" << info.name();
334  PeripheriqueTTPA *ecranTTPA = new PeripheriqueTTPA(info.name(), info.address().toString(), this);
335  peripheriquesTTPA.append(ecranTTPA);
337  emit detecte();
338  }
339 
340  // 3 sur 3
342  {
344  }
345  // 2 sur 3
346  /*if(peripheriqueRobotTTPADetecte && peripheriqueTableTTPADetecte)
347  {
348  arreterRecherche();
349  }*/
350  // 1 sur 3
351  /*if(peripheriqueRobotTTPADetecte)
352  arreterRecherche();*/
353 }
bool peripheriqueRobotTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:45
Permet la communication avec les appareils Bluetooth TTPA.
Definition: peripheriqueTTPA.h:32
bool peripheriqueEcranTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:43
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
Q_INVOKABLE void arreterRecherche()
Permet d&#39;arreter la recherche des appareils bluetooth "TTPA".
Definition: terminal-TTPA/communicationbluetooth.cpp:79
bool peripheriqueTableTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:44

◆ arreter()

void CommunicationBluetooth::arreter ( )

Références serveur, serviceInfo, et socket.

Référencé par ~CommunicationBluetooth().

236 {
237  if (!serveur)
238  return;
239 
240  serviceInfo.unregisterService();
241 
242  if (socket)
243  {
244  if (socket->isOpen())
245  socket->close();
246  delete socket;
247  socket = nullptr;
248  }
249 
250  delete serveur;
251  serveur = nullptr;
252 }
QBluetoothServiceInfo serviceInfo
Definition: ecran-TTPA/communicationbluetooth.h:53
QBluetoothSocket * socket
la socket
Definition: ecran-TTPA/communicationbluetooth.h:52
QBluetoothServer * serveur
Definition: ecran-TTPA/communicationbluetooth.h:51

◆ arreterRecherche()

void CommunicationBluetooth::arreterRecherche ( )

Références discoveryAgentDevice, et etatRecherche.

Référencé par ajouterPeripheriqueTTPA().

80 {
81  qDebug() << Q_FUNC_INFO;
82  if (!etatRecherche)
83  return;
84  if(discoveryAgentDevice != NULL && discoveryAgentDevice->isActive())
85  {
86  discoveryAgentDevice->stop();
87  }
88 }
bool etatRecherche
Definition: terminal-TTPA/communicationbluetooth.h:46
QBluetoothDeviceDiscoveryAgent * discoveryAgentDevice
l&#39;agent permettant de découvrir des périphériques Bluetooth
Definition: terminal-TTPA/communicationbluetooth.h:224

◆ arreterSeance()

bool CommunicationBluetooth::arreterSeance ( )
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Références envoyerPeripheriqueTTPA(), et etatSeance.

240 {
241  qDebug() << Q_FUNC_INFO;
242 
243  QString trameArret = ":RESET*00\r\n";
244 
245  envoyerPeripheriqueTTPA("robot-ttpa-11", trameArret);
246  envoyerPeripheriqueTTPA("ecran-ttpa-2", trameArret);
247  envoyerPeripheriqueTTPA("table-ttpa-2", trameArret);
248  etatSeance = EtatDeLaSeance::Initial;
249 
250  return true;
251 }
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ connecte

void CommunicationBluetooth::connecte ( )
signal

◆ connecterPeripheriquesTTPA()

void CommunicationBluetooth::connecterPeripheriquesTTPA ( )

Références PeripheriqueTTPA::connecter(), PeripheriqueTTPA::estConnecte(), PeripheriqueTTPA::getNom(), peripheriquesTTPA, et recevoirTramePeripheriqueTTPA().

407 {
408  qDebug() << Q_FUNC_INFO << peripheriquesTTPA.size();
409 
410  // liste les appareils TTPA détectés
411  for(int i=0; i < peripheriquesTTPA.size(); i++)
412  {
413  PeripheriqueTTPA *peripheriqueTTPA = (PeripheriqueTTPA *)peripheriquesTTPA[i];
414  if(!peripheriqueTTPA->estConnecte())
415  {
416  qDebug() << Q_FUNC_INFO << peripheriqueTTPA << peripheriqueTTPA->getNom();
417  peripheriqueTTPA->connecter();
418  connect(peripheriqueTTPA, SIGNAL(trameRecue(QString,QString)), this, SLOT(recevoirTramePeripheriqueTTPA(QString,QString)));
419  }
420  }
421 }
void recevoirTramePeripheriqueTTPA(QString nomPeripherique, QString trame)
Definition: terminal-TTPA/communicationbluetooth.cpp:368
Permet la communication avec les appareils Bluetooth TTPA.
Definition: peripheriqueTTPA.h:32
Q_INVOKABLE bool estConnecte()
Retourne vrai si l&#39;appareil est connecté
Definition: peripheriqueTTPA.cpp:115
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
QString getNom() const
Definition: peripheriqueTTPA.cpp:20
Q_INVOKABLE void connecter()
Connecte le terminal mobile à l&#39;appareil "TTPA".
Definition: peripheriqueTTPA.cpp:30

◆ decoderTrame()

void CommunicationBluetooth::decoderTrame ( QString  trame)
private
Paramètres
QStringtrame est la trame ecran-ttpa-1

Démarrage $ecran-ttpa-1:START;JULIEN;2;1*XX

+- Zone Robot

| +— Zone Objectif +----— Nom Joueur

$ecran-ttpa-1:STAT;2*XX | | +--------— Numéro Zone Impact

Références departSeance(), etatSeance, finSeance(), impactZone(), mettreEnPauseSeance(), repriseSeance(), et resetSeance().

Référencé par socketConnected(), socketDisconnected(), et socketReadyRead().

124 {
125  QStringList trames;
126  trame.remove("\r\n");
127  qDebug() << Q_FUNC_INFO << "trame" << trame;
128 
129  const QString typeTrame = "ecran-ttpa";
130  QString donnees;
131  QString nomJoueur;
132  QString zoneRobot;
133  QString zoneObjectif;
134  QString numeroZone;
135 
136  if(trame.startsWith("$" + typeTrame))
137  {
152  donnees = trame.section(':', 1, 1); // START;JULIEN;2;1*XX
153  if(trame.contains("START") && (etatSeance == EtatSeance::Initial || etatSeance == EtatSeance::Terminee))
154  {
155  etatSeance = EtatSeance::EnCours;
156  // START;JULIEN;2;1*XX
157  nomJoueur = donnees.section(';', 1, 1);
158  zoneObjectif = donnees.section(';', 2, 2);
159  zoneRobot = donnees.section(';', 3, 3).at(0);
160  qDebug() << Q_FUNC_INFO << "nomJoueur" << nomJoueur << "zoneObjectif" << zoneObjectif << "zoneRobot" << zoneRobot;
161  emit departSeance(nomJoueur, zoneObjectif, zoneRobot);
162  }
163  else if(trame.contains("STAT") && etatSeance == EtatSeance::EnCours)
164  {
165  // STAT;2*XX
166  numeroZone = donnees.section(';', 1, 1).at(0);
167  qDebug() << Q_FUNC_INFO << "numeroZone" << numeroZone;
168  emit impactZone(numeroZone);
169  }
170  else if(trame.contains("PAUSE") && etatSeance == EtatSeance::EnCours)
171  {
172  etatSeance = EtatSeance::EnPause;
173  //PAUSE*XX
174  emit mettreEnPauseSeance();
175  }
176  else if(trame.contains("RESUME") && etatSeance == EtatSeance::EnPause)
177  {
178  etatSeance = EtatSeance::EnCours;
179  //RESUME*XX
180  emit repriseSeance();
181  }
182  else if(trame.contains("END") && etatSeance == EtatSeance::EnCours)
183  {
184  etatSeance = EtatSeance::Terminee;
185  //END*XX
186  emit finSeance();
187  }
188  else if(trame.contains("RESET") && (etatSeance == EtatSeance::EnCours || etatSeance == EtatSeance::EnPause || etatSeance == EtatSeance::Terminee))
189  {
190  etatSeance = EtatSeance::Initial;
191  //RESET*XX
192  emit resetSeance();
193  }
194  }
195 }
void mettreEnPauseSeance()
Met la séance en pause.
Definition: terminal-TTPA/communicationbluetooth.cpp:205
void impactZone(QString numeroZone)
void departSeance(QString nomJoueur, QString zoneObjectif, QString zoneRobot)
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58

◆ deconnecterPeripheriquesTTPA()

void CommunicationBluetooth::deconnecterPeripheriquesTTPA ( )

Références PeripheriqueTTPA::deconnecter(), PeripheriqueTTPA::getNom(), peripheriquesTTPA, et recevoirTramePeripheriqueTTPA().

424 {
425  qDebug() << Q_FUNC_INFO;
426 
427  // liste les appareils TTPA détectés
428  for(int i=0; i < peripheriquesTTPA.size(); i++)
429  {
430  PeripheriqueTTPA *peripheriqueTTPA = (PeripheriqueTTPA *)peripheriquesTTPA[i];
431  qDebug() << Q_FUNC_INFO << "déconnecter" << peripheriqueTTPA->getNom();
432  disconnect(peripheriqueTTPA, SIGNAL(trameRecue(QString,QString)), this, SLOT(recevoirTramePeripheriqueTTPA(QString,QString)));
433  peripheriqueTTPA->deconnecter();
434  }
435 }
Q_INVOKABLE void deconnecter()
Deconnecte l&#39;appareil "TTPA" connecté
Definition: peripheriqueTTPA.cpp:51
void recevoirTramePeripheriqueTTPA(QString nomPeripherique, QString trame)
Definition: terminal-TTPA/communicationbluetooth.cpp:368
Permet la communication avec les appareils Bluetooth TTPA.
Definition: peripheriqueTTPA.h:32
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
QString getNom() const
Definition: peripheriqueTTPA.cpp:20

◆ demarrer()

void CommunicationBluetooth::demarrer ( )

Références nouveauClient(), serveur, serviceInfo, serviceNom(), et serviceUuid().

Référencé par TtpaIhm::TtpaIhm().

219 {
220  if (!serveur)
221  {
222  serveur = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
223  connect(serveur, SIGNAL(newConnection()), this, SLOT(nouveauClient()));
224 
225  QBluetoothUuid uuid = QBluetoothUuid(serviceUuid);
226  serviceInfo = serveur->listen(uuid, serviceNom);
227  qDebug() << Q_FUNC_INFO << "serviceInfo" << serviceInfo;
228  }
229 }
static const QString serviceNom(QStringLiteral("raspberry"))
QBluetoothServiceInfo serviceInfo
Definition: ecran-TTPA/communicationbluetooth.h:53
QBluetoothServer * serveur
Definition: ecran-TTPA/communicationbluetooth.h:51
void nouveauClient()
Definition: ecran-TTPA/communicationbluetooth.cpp:255
static const QString serviceUuid(QStringLiteral("00001101-0000-1000-8000-00805F9B34FB"))

◆ demarrerSeance()

bool CommunicationBluetooth::demarrerSeance ( QString  nomJoueur,
QString  zoneObjectif,
QString  zoneRobot,
int  frequenceBalle,
int  nbBalles,
int  effet,
int  puissance,
bool  rotation 
)

Références demarrerSeanceEcran(), demarrerSeanceRobot(), demarrerSeanceTable(), etatSeance, et Initial.

146 {
147  if(etatSeance == Initial)
148  {
149  demarrerSeanceRobot(frequenceBalle, nbBalles, effet, puissance, rotation);
150  demarrerSeanceEcran(nomJoueur, zoneObjectif, zoneRobot);
151  demarrerSeanceTable(nbBalles);
152  etatSeance = EtatDeLaSeance::EnCours;
153  }
154 }
Definition: ecran-TTPA/communicationbluetooth.h:39
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
Q_INVOKABLE bool demarrerSeanceEcran(QString nomJoueur, QString zoneObjectif, QString zoneRobot)
Envoi une trame de démarrage de séance à l&#39;ecran.
Definition: terminal-TTPA/communicationbluetooth.cpp:176
Q_INVOKABLE bool demarrerSeanceTable(int nbBalles)
Envoi une trame de démarrage de séance à la table.
Definition: terminal-TTPA/communicationbluetooth.cpp:190
Q_INVOKABLE bool demarrerSeanceRobot(int frequenceBalle, int nbBalles, int effet, int puissance, bool rotation)
Envoi une trame contenant les paramètres du robot au robot-ttpa.
Definition: terminal-TTPA/communicationbluetooth.cpp:156

◆ demarrerSeanceEcran()

bool CommunicationBluetooth::demarrerSeanceEcran ( QString  nomJoueur,
QString  zoneObjectif,
QString  zoneRobot 
)
Paramètres
nomJoueurQString nom du joueur
zoneObjectifQString trame respectant le protocole TTPA
zoneRobotQString trame respectant le protocole TTPA
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Références envoyerPeripheriqueTTPA().

Référencé par demarrerSeance().

177 {
178  qDebug() << Q_FUNC_INFO << "ecran-ttpa" << nomJoueur << zoneObjectif << zoneRobot;
179 
180  //QString trameReset = ":RESET*00\r\n";
181  //envoyerPeripheriqueTTPA("ecran-ttpa-2", trameReset);
182 
183  QString trameDemarrageEcran = ":START;" + nomJoueur + ";" + zoneObjectif + ";" +zoneRobot + "*00\r\n";
184 
185  envoyerPeripheriqueTTPA("ecran-ttpa-2", trameDemarrageEcran);
186 
187  return true;
188 }
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ demarrerSeanceRobot()

bool CommunicationBluetooth::demarrerSeanceRobot ( int  frequenceBalle,
int  nbBalles,
int  effet,
int  puissance,
bool  rotation 
)
Paramètres
frequenceBalleint nom du périphérique Bluetooth
nbBallesint trame respectant le protocole TTPA
effetint trame respectant le protocole TTPA
puissanceint trame respectant le protocole TTPA
rotationbool trame respectant le protocole TTPA
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Références envoyerPeripheriqueTTPA().

Référencé par demarrerSeance().

157 {
158  qDebug() << Q_FUNC_INFO << "robot-ttpa" << frequenceBalle << nbBalles << effet << puissance << rotation;
159 
160  QString QfrequenceBalle = QString::number(frequenceBalle);
161  QString QnbBalles = QString::number(nbBalles);
162  QString Qeffet = QString::number(effet);
163  QString Qpuissance = QString::number(puissance);
164  QString Qrotation = QString::number(rotation);
165 
166  QString trameReset = ":RESET*00\r\n";
167  envoyerPeripheriqueTTPA("robot-ttpa-11", trameReset);
168 
169  QString trameDemarrageRobot = ":START;" + QfrequenceBalle + ";" + QnbBalles + ";" + Qeffet + ";"+ Qpuissance + ";" + Qrotation + "*00\r\n";
170 
171  envoyerPeripheriqueTTPA("robot-ttpa-11", trameDemarrageRobot);
172 
173  return true;
174 }
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ demarrerSeanceTable()

bool CommunicationBluetooth::demarrerSeanceTable ( int  nbBalles)
Paramètres
nbBallesint Nombre de balles
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Références envoyerPeripheriqueTTPA().

Référencé par demarrerSeance().

191 {
192  qDebug() << Q_FUNC_INFO << "table-ttpa" << nbBalles;
193 
194  QString trameReset = ":RESET*00\r\n";
195  envoyerPeripheriqueTTPA("table-ttpa-2", trameReset);
196 
197  QString QnbBalles = QString::number(nbBalles);
198  QString trameDemarrageTable = ":START;"+ QnbBalles + "*00\r\n";
199 
200  envoyerPeripheriqueTTPA("table-ttpa-2", trameDemarrageTable);
201 
202  return true;
203 }
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ departSeance

void CommunicationBluetooth::departSeance ( QString  nomJoueur,
QString  zoneObjectif,
QString  zoneRobot 
)
signal

Référencé par decoderTrame().

◆ detecte

void CommunicationBluetooth::detecte ( )
signal

◆ deviceConnected

void CommunicationBluetooth::deviceConnected ( const QBluetoothAddress &  adresse)
slot

Références monBluetooth.

Référencé par CommunicationBluetooth().

272 {
273  qDebug() << Q_FUNC_INFO << adresse << adresse.toString() << monBluetooth.pairingStatus(adresse);
274 }
QString adresse
Definition: ecran-TTPA/communicationbluetooth.h:55
QBluetoothLocalDevice monBluetooth
Definition: ecran-TTPA/communicationbluetooth.h:50

◆ deviceDisconnected

void CommunicationBluetooth::deviceDisconnected ( const QBluetoothAddress &  adresse)
slot

Références adresse.

Référencé par CommunicationBluetooth().

277 {
278  qDebug() << Q_FUNC_INFO << adresse;
279 }
QString adresse
Definition: ecran-TTPA/communicationbluetooth.h:55

◆ ecranDetecte

void CommunicationBluetooth::ecranDetecte ( )
signal

◆ envoyerErreurRobot()

bool CommunicationBluetooth::envoyerErreurRobot ( )
Renvoie
bool vrai si la trame a pu être envoyée au périphérique TTPA

Références envoyerPeripheriqueTTPA().

Référencé par recevoirTramePeripheriqueTTPA().

281 {
282  qDebug() << Q_FUNC_INFO;
283 
284  QString trameErreur = ":INFO;Bourrage du robot ou Absence de balle*00\r\n";
285 
286  envoyerPeripheriqueTTPA("ecran-ttpa-2", trameErreur);
287 }
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ envoyerPeripheriqueTTPA()

bool CommunicationBluetooth::envoyerPeripheriqueTTPA ( QString  nom,
QString  message 
)
Paramètres
nomQString nom du périphérique Bluetooth
messageQString trame respectant le protocole TTPA
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Références PeripheriqueTTPA::envoyer(), PeripheriqueTTPA::getNom(), nom, et peripheriquesTTPA.

Référencé par arreterSeance(), demarrerSeanceEcran(), demarrerSeanceRobot(), demarrerSeanceTable(), envoyerErreurRobot(), envoyerZoneImpactee(), finirSeance(), et reprendreLaSeance().

130 {
131  qDebug() << Q_FUNC_INFO << "nom" << nom << "message" << message;
132  // liste les appareils TTPA détectés
133  for(int i=0; i < peripheriquesTTPA.size(); i++)
134  {
135  if(((PeripheriqueTTPA *)peripheriquesTTPA[i])->getNom() == nom)
136  {
137  PeripheriqueTTPA *peripheriqueTTPA = (PeripheriqueTTPA *)peripheriquesTTPA[i];
138  qDebug() << Q_FUNC_INFO << "envoyer" << peripheriqueTTPA->getNom();
139  return peripheriqueTTPA->envoyer(nom + message);
140  }
141  }
142  return false;
143 }
Q_INVOKABLE bool envoyer(QString trame)
Envoie une trame à l&#39;appareil "TTPA" connecté
Definition: peripheriqueTTPA.cpp:101
Permet la communication avec les appareils Bluetooth TTPA.
Definition: peripheriqueTTPA.h:32
QString nom
Definition: ecran-TTPA/communicationbluetooth.h:54
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
QString getNom() const
Definition: peripheriqueTTPA.cpp:20

◆ envoyerZoneImpactee()

bool CommunicationBluetooth::envoyerZoneImpactee ( QString  zone)
Paramètres
zoneQString zone impactée
Renvoie
bool vrai si la trame a pu être envoyée au périphérique TTPA

Références envoyerPeripheriqueTTPA().

Référencé par recevoirTramePeripheriqueTTPA().

272 {
273  qDebug() << Q_FUNC_INFO;
274 
275  QString trameStatistique = ":STAT;" + zone + "*00\r\n";
276 
277  envoyerPeripheriqueTTPA("ecran-ttpa-2", trameStatistique);
278 }
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ erreur

void CommunicationBluetooth::erreur ( )
signal

Référencé par error(), et rechercheErreur().

◆ erreurRobot

void CommunicationBluetooth::erreurRobot ( )
signal

◆ error

void CommunicationBluetooth::error ( QBluetoothLocalDevice::Error  erreur)
slot

Références erreur().

Référencé par CommunicationBluetooth(), et socketErreur().

282 {
283  qDebug() << Q_FUNC_INFO << erreur;
284 }

◆ estValide()

bool CommunicationBluetooth::estValide ( )
Renvoie
Vrai si l'appareil est conforme aux normes "TTPA"

Références peripheriqueBluetoothLocal.

91 {
92  return peripheriqueBluetoothLocal.isValid();
93 }
QBluetoothLocalDevice peripheriqueBluetoothLocal
le périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:220

◆ fini

void CommunicationBluetooth::fini ( )
signal

Référencé par finirSeance().

◆ finirSeance()

bool CommunicationBluetooth::finirSeance ( )
Renvoie
bool vrai si la trame a pu être envoyée au périphérique TTPA

Références EnCours, envoyerPeripheriqueTTPA(), etatSeance, et fini().

Référencé par recevoirTramePeripheriqueTTPA().

254 {
255  qDebug() << Q_FUNC_INFO;
256 
257  QString trameFin = ":END*00\r\n";
258 
259  if(etatSeance == EnCours)
260  {
261  envoyerPeripheriqueTTPA("robot-ttpa-11", trameFin);
262  envoyerPeripheriqueTTPA("ecran-ttpa-2", trameFin);
263  envoyerPeripheriqueTTPA("table-ttpa-2", trameFin);
264  emit fini();
265  etatSeance = EtatDeLaSeance::Arretee;
266  return true;
267  }
268  return false;
269 }
Definition: ecran-TTPA/communicationbluetooth.h:40
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ finSeance

void CommunicationBluetooth::finSeance ( )
signal

Référencé par decoderTrame().

◆ getAdressePeripheriqueBluetoothLocal()

QString CommunicationBluetooth::getAdressePeripheriqueBluetoothLocal ( )

Références adressePeripheriqueBluetoothLocal.

101 {
103 }
QString adressePeripheriqueBluetoothLocal
l&#39;adresse MAC du périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:42

◆ getEtatSeance() [1/2]

CommunicationBluetooth::EtatSeance CommunicationBluetooth::getEtatSeance ( )

Références etatSeance.

210 {
211  return etatSeance;
212 }
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58

◆ getEtatSeance() [2/2]

EtatDeLaSeance CommunicationBluetooth::getEtatSeance ( )

◆ getNomPeripheriqueBluetoothLocal()

QString CommunicationBluetooth::getNomPeripheriqueBluetoothLocal ( )

Références nomPeripheriqueBluetoothLocal.

96 {
98 }
QString nomPeripheriqueBluetoothLocal
le nom du périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:41

◆ getPeripheriquesTTPA()

QVariant CommunicationBluetooth::getPeripheriquesTTPA ( )

Références peripheriquesTTPA.

106 {
107  return QVariant::fromValue(peripheriquesTTPA);
108 }
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47

◆ getPeripheriqueTTPA()

PeripheriqueTTPA * CommunicationBluetooth::getPeripheriqueTTPA ( QString  nom)

Références PeripheriqueTTPA::getNom(), nom, et peripheriquesTTPA.

111 {
112  bool trouve = false;
113  PeripheriqueTTPA *peripheriqueTTPA = nullptr;
114 
115  // liste les appareils TTPA détectés
116  for(int i=0; i < peripheriquesTTPA.size() && !trouve; i++)
117  {
118  if(((PeripheriqueTTPA *)peripheriquesTTPA[i])->getNom() == nom)
119  {
120  peripheriqueTTPA = (PeripheriqueTTPA *)peripheriquesTTPA[i];
121  qDebug() << Q_FUNC_INFO << "return" << peripheriqueTTPA->getNom();
122  trouve = true;
123  }
124  }
125  return peripheriqueTTPA;
126 }
Permet la communication avec les appareils Bluetooth TTPA.
Definition: peripheriqueTTPA.h:32
QString nom
Definition: ecran-TTPA/communicationbluetooth.h:54
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
QString getNom() const
Definition: peripheriqueTTPA.cpp:20

◆ getZoneObjectif()

QString CommunicationBluetooth::getZoneObjectif ( QString  zoneObjectif)
Paramètres
zoneObjectifQString numéro de la zone objectif choisie par le joueur
Renvoie
QString numéro de la zone objectif
290 {
291  QString numeroZoneObjectif = zoneObjectif;
292  QStringRef b(&numeroZoneObjectif, 5, 1);
293  numeroZoneObjectif = b.toString();
294  qDebug() << Q_FUNC_INFO << "Numero zone objectif : " << numeroZoneObjectif;
295 
296  return numeroZoneObjectif;
297 }

◆ getZoneRobot()

QString CommunicationBluetooth::getZoneRobot ( QString  zoneRobot)
Paramètres
zoneRobotQString numéro de la zone robot choisie par le joueur
Renvoie
QString numéro de la zone robot
300 {
301  QString numeroZoneRobot = zoneRobot;
302  QStringRef b(&numeroZoneRobot, 5, 1);
303  numeroZoneRobot = b.toString();
304  qDebug() << Q_FUNC_INFO << "Numero zone robot : " << numeroZoneRobot;
305 
306  return numeroZoneRobot;
307 }

◆ impactZone

void CommunicationBluetooth::impactZone ( QString  numeroZone)
signal

Référencé par decoderTrame().

◆ mettreEnPauseSeance [1/2]

bool CommunicationBluetooth::mettreEnPauseSeance ( )
signal
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Référencé par decoderTrame().

206 {
207  qDebug() << Q_FUNC_INFO;
208 
209  QString tramePause = ":PAUSE*00\r\n";
210 
211  if(etatSeance == EtatDeLaSeance::EnCours)
212  {
213  envoyerPeripheriqueTTPA("robot-ttpa-11", tramePause);
214  envoyerPeripheriqueTTPA("ecran-ttpa-2", tramePause);
215  envoyerPeripheriqueTTPA("table-ttpa-2", tramePause);
216  etatSeance = EtatDeLaSeance::EnPause;
217  return true;
218  }
219  return false;
220 }
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ mettreEnPauseSeance() [2/2]

Q_INVOKABLE bool CommunicationBluetooth::mettreEnPauseSeance ( )

◆ nouveauClient

void CommunicationBluetooth::nouveauClient ( )
slot

Références etatConnexion, serveur, socket, socketDisconnected(), et socketReadyRead().

Référencé par demarrer().

256 {
257  // on récupère la socket
258  socket = serveur->nextPendingConnection();
259  if (!socket)
260  return;
261 
262  connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
263  connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
264  //connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError)));
265  //connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socketStateChanged(QBluetoothSocket::SocketState)));
266 
267  etatConnexion = true;
268  qDebug() << Q_FUNC_INFO;
269 }
void socketReadyRead()
la socket est prête à lire les informations
Definition: ecran-TTPA/communicationbluetooth.cpp:98
void socketDisconnected()
la socket est déconnecté
Definition: ecran-TTPA/communicationbluetooth.cpp:85
QBluetoothSocket * socket
la socket
Definition: ecran-TTPA/communicationbluetooth.h:52
QBluetoothServer * serveur
Definition: ecran-TTPA/communicationbluetooth.h:51
bool etatConnexion
L&#39;état de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:56

◆ peripheriquesTTPAUpdated

void CommunicationBluetooth::peripheriquesTTPAUpdated ( )
signal

◆ recevoirTramePeripheriqueTTPA

void CommunicationBluetooth::recevoirTramePeripheriqueTTPA ( QString  nomPeripherique,
QString  trame 
)
slot

Références envoyerErreurRobot(), envoyerZoneImpactee(), erreurRobot(), erreurRobotDetecte, etatSeance, et finirSeance().

Référencé par connecterPeripheriquesTTPA(), et deconnecterPeripheriquesTTPA().

369 {
370  qDebug() << Q_FUNC_INFO << "nomPeripherique" << nomPeripherique << "trame" << trame;
371 
372  if(etatSeance != EtatDeLaSeance::EnCours)
373  return;
374 
375  if(trame.contains("IMPACT"))
376  {
377  QStringRef traitementImpactTable(&trame,21, 1);
378  QString donneesImpact = traitementImpactTable.toString();
379  int zoneImpact = donneesImpact.toInt();
380  donneesImpact = QString::number(zoneImpact-1);
381  qDebug() << Q_FUNC_INFO << "donneesImpact" << donneesImpact;
382  envoyerZoneImpactee(donneesImpact);
383  }
384  else if(trame.contains("ERROR")) // ROBOT
385  {
386  QStringRef traitementBourrageRobot(&trame, 21, 1);
387  QStringRef traitementAbsenceDeBalleRobot(&trame, 23, 1);
388  QStringRef traitementErreurParametresRobot(&trame, 25, 1);
389  QString bourrageDeBalle = traitementBourrageRobot.toString();
390  QString absenceDeBalle = traitementAbsenceDeBalleRobot.toString();
391  QString erreurParametres = traitementErreurParametresRobot.toString();
392  qDebug() << Q_FUNC_INFO << "bourrageBalle" << bourrageDeBalle << "absenceBalle" << absenceDeBalle << "erreurParametre" << erreurParametres;
393  // 1. signaler à l'IHM
394  erreurRobotDetecte = false;
395  emit erreurRobot();
396  // 2. envoyer trame à l'écran
398  // A voir : passage à l'état ERREUR ou PAUSE ?
399  }
400  else if(trame.contains("FINISH"))
401  {
402  finirSeance();
403  }
404 }
bool erreurRobotDetecte
Definition: terminal-TTPA/communicationbluetooth.h:48
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
bool envoyerErreurRobot()
Si le robot détecte un bourrage de balle ou une absence de balle, une trame est envoyée à l&#39;écran ttp...
Definition: terminal-TTPA/communicationbluetooth.cpp:280
bool finirSeance()
Met fin à la séance lorsque le robot indique qu&#39;il à tirer toutes ses balles.
Definition: terminal-TTPA/communicationbluetooth.cpp:253
bool envoyerZoneImpactee(QString zone)
Dès que la table envoie une trame contenant la zone impactée, la méthode l&#39;envoie à l&#39;écran ttpa...
Definition: terminal-TTPA/communicationbluetooth.cpp:271

◆ recherche

void CommunicationBluetooth::recherche ( )
signal

◆ rechercheErreur

void CommunicationBluetooth::rechercheErreur ( QBluetoothDeviceDiscoveryAgent::Error  erreur)
slot

Références erreur().

Référencé par CommunicationBluetooth().

364 {
365  qDebug() << Q_FUNC_INFO << erreur;
366 }

◆ rechercherPeripheriquesTTPA()

CommunicationBluetooth::rechercherPeripheriquesTTPA ( )

Références detecte(), discoveryAgentDevice, etatRecherche, peripheriqueEcranTTPADetecte, peripheriqueRobotTTPADetecte, peripheriquesTTPA, peripheriquesTTPAUpdated(), peripheriqueTableTTPADetecte, et recherche().

56 {
57  qDebug() << Q_FUNC_INFO;
58 
59  qDeleteAll(peripheriquesTTPA);
60  peripheriquesTTPA.clear();
64  emit detecte();
66 
67  if(discoveryAgentDevice != NULL)
68  {
69  qDebug() << Q_FUNC_INFO << discoveryAgentDevice->isActive();
70  discoveryAgentDevice->start();
71  if (discoveryAgentDevice->isActive())
72  {
73  etatRecherche = true;
74  emit recherche();
75  }
76  }
77 }
bool peripheriqueRobotTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:45
bool peripheriqueEcranTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:43
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
bool etatRecherche
Definition: terminal-TTPA/communicationbluetooth.h:46
QBluetoothDeviceDiscoveryAgent * discoveryAgentDevice
l&#39;agent permettant de découvrir des périphériques Bluetooth
Definition: terminal-TTPA/communicationbluetooth.h:224
void recherche()
signal indiquant que l&#39;état de la recherche de périphériques a changé
bool peripheriqueTableTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:44

◆ rechercheTerminee

void CommunicationBluetooth::rechercheTerminee ( )
slot

Références detecte(), etatRecherche, peripheriquesTTPAUpdated(), et recherche().

Référencé par CommunicationBluetooth().

356 {
357  etatRecherche = false;
358  emit recherche();
359  emit detecte();
361 }
bool etatRecherche
Definition: terminal-TTPA/communicationbluetooth.h:46
void recherche()
signal indiquant que l&#39;état de la recherche de périphériques a changé

◆ reprendreLaSeance()

bool CommunicationBluetooth::reprendreLaSeance ( )
Renvoie
bool vrai si la trame a pu être envoyé au périphérique TTPA

Références envoyerPeripheriqueTTPA(), et etatSeance.

223 {
224  qDebug() << Q_FUNC_INFO;
225 
226  QString trameReprise = ":RESUME*00\r\n";
227 
228  if(etatSeance == EtatDeLaSeance::EnPause)
229  {
230  envoyerPeripheriqueTTPA("robot-ttpa-11", trameReprise);
231  envoyerPeripheriqueTTPA("ecran-ttpa-2", trameReprise);
232  envoyerPeripheriqueTTPA("table-ttpa-2", trameReprise);
233  etatSeance = EtatDeLaSeance::EnCours;
234  return true;
235  }
236  return false;
237 }
EtatSeance etatSeance
Definition: ecran-TTPA/communicationbluetooth.h:58
Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message)
Permet d&#39;envoyer une trame à un périphérique TTPA identifié par son nom.
Definition: terminal-TTPA/communicationbluetooth.cpp:129

◆ repriseSeance

void CommunicationBluetooth::repriseSeance ( )
signal

Référencé par decoderTrame().

◆ resetSeance

void CommunicationBluetooth::resetSeance ( )
signal

Référencé par decoderTrame().

◆ robotDetecte

void CommunicationBluetooth::robotDetecte ( )
signal

◆ socketConnected

void CommunicationBluetooth::socketConnected ( )
slot

Références connexionErreur, decoderTrame(), et etatConnexion.

73 {
74  qDebug() << Q_FUNC_INFO;
75  connect(this, SIGNAL(donneesRecues(QString)),this, SLOT(decoderTrame(QString)));
76  etatConnexion = true;
77  connexionErreur = false;
78 }
bool connexionErreur
Savoir si il a une erreur de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:57
void decoderTrame(QString trame)
permet de décoder la trame émise par le terminal mobile
Definition: ecran-TTPA/communicationbluetooth.cpp:123
bool etatConnexion
L&#39;état de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:56

◆ socketDisconnected

void CommunicationBluetooth::socketDisconnected ( )
slot

Références connexionErreur, decoderTrame(), et etatConnexion.

Référencé par nouveauClient().

86 {
87  qDebug() << Q_FUNC_INFO;
88  disconnect(this, SIGNAL(donneesRecues(QString)),this, SLOT(decoderTrame(QString)));
89  etatConnexion = false;
90  connexionErreur = false;
91 }
bool connexionErreur
Savoir si il a une erreur de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:57
void decoderTrame(QString trame)
permet de décoder la trame émise par le terminal mobile
Definition: ecran-TTPA/communicationbluetooth.cpp:123
bool etatConnexion
L&#39;état de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:56

◆ socketErreur

void CommunicationBluetooth::socketErreur ( QBluetoothSocket::SocketError  error)
slot
Paramètres
QBluetoothSocket::SocketErrorerror est la socket erreur

Références connexionErreur, error(), et etatConnexion.

203 {
204  qDebug() << Q_FUNC_INFO << "erreur" << error;
205  etatConnexion = false;
206  connexionErreur = true;
207 }
bool connexionErreur
Savoir si il a une erreur de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:57
bool etatConnexion
L&#39;état de connexion.
Definition: ecran-TTPA/communicationbluetooth.h:56
void error(QBluetoothLocalDevice::Error erreur)
Definition: ecran-TTPA/communicationbluetooth.cpp:281

◆ socketReadyRead

void CommunicationBluetooth::socketReadyRead ( )
slot

Références decoderTrame(), et socket.

Référencé par nouveauClient().

99 {
100  QByteArray donneesRecues;
101 
102  while(socket->canReadLine())
103  {
104  donneesRecues += socket->readLine();
105  usleep(150000);
106  }
107 
108  if(donneesRecues.contains("\r\n"))
109  {
110  qDebug() << Q_FUNC_INFO << "donneesRecues" << donneesRecues;
111  decoderTrame(QString(donneesRecues.data()));
112  donneesRecues.clear();
113  }
114 }
QBluetoothSocket * socket
la socket
Definition: ecran-TTPA/communicationbluetooth.h:52
void decoderTrame(QString trame)
permet de décoder la trame émise par le terminal mobile
Definition: ecran-TTPA/communicationbluetooth.cpp:123

◆ tableDetecte

void CommunicationBluetooth::tableDetecte ( )
signal

Documentation des données membres

◆ adresse

QString CommunicationBluetooth::adresse
private

◆ connexionErreur

bool CommunicationBluetooth::connexionErreur
private

◆ discoveryAgentDevice

QBluetoothDeviceDiscoveryAgent* CommunicationBluetooth::discoveryAgentDevice
private

◆ etatConnexion

bool CommunicationBluetooth::etatConnexion
private

◆ etatSeance [1/2]

EtatSeance CommunicationBluetooth::etatSeance
private

◆ etatSeance [2/2]

EtatDeLaSeance CommunicationBluetooth::etatSeance
private

◆ monBluetooth

QBluetoothLocalDevice CommunicationBluetooth::monBluetooth
private

◆ nom

QString CommunicationBluetooth::nom
private

◆ peripheriqueBluetoothLocal

QBluetoothLocalDevice CommunicationBluetooth::peripheriqueBluetoothLocal
private

Référencé par CommunicationBluetooth(), et estValide().

◆ peripheriquesTTPA

QList<QObject*> CommunicationBluetooth::peripheriquesTTPA
private

◆ serveur

QBluetoothServer* CommunicationBluetooth::serveur
private

Référencé par arreter(), demarrer(), et nouveauClient().

◆ serviceInfo

QBluetoothServiceInfo CommunicationBluetooth::serviceInfo
private

Référencé par arreter(), et demarrer().

◆ socket

QBluetoothSocket* CommunicationBluetooth::socket
private

Documentation des propriétés

◆ adressePeripheriqueBluetoothLocal

QString CommunicationBluetooth::adressePeripheriqueBluetoothLocal

◆ erreurRobotDetecte

bool CommunicationBluetooth::erreurRobotDetecte

◆ etatRecherche

bool CommunicationBluetooth::etatRecherche

◆ nomPeripheriqueBluetoothLocal

QString CommunicationBluetooth::nomPeripheriqueBluetoothLocal

◆ peripheriqueEcranTTPADetecte

bool CommunicationBluetooth::peripheriqueEcranTTPADetecte

◆ peripheriqueRobotTTPADetecte

bool CommunicationBluetooth::peripheriqueRobotTTPADetecte

◆ peripheriquesTTPA

QVariant CommunicationBluetooth::peripheriquesTTPA
read

◆ peripheriqueTableTTPADetecte

bool CommunicationBluetooth::peripheriqueTableTTPADetecte

La documentation de cette classe a été générée à partir des fichiers suivants :