Projet TTPA (Table Tennis Performance Analyser)  1.3
BTS SN 2019
terminal-TTPA/communicationbluetooth.h
Aller à la documentation de ce fichier.
1 
12 #ifndef CommunicationBluetooth_H
13 #define CommunicationBluetooth_H
14 
15 #include <QBluetoothLocalDevice>
16 #include <QBluetoothAddress>
17 #include <QBluetoothUuid>
18 #include <QBluetoothDeviceInfo>
19 #include <QBluetoothServiceInfo>
20 #include <QBluetoothDeviceDiscoveryAgent>
21 
22 #define SERVICE_UUID "{00001101-0000-1000-8000-00805F9B34FB}"
23 
24 class PeripheriqueTTPA;
25 
38 class CommunicationBluetooth : public QObject
39 {
40  Q_OBJECT
42  Q_PROPERTY(QString adressePeripheriqueBluetoothLocal MEMBER adressePeripheriqueBluetoothLocal NOTIFY detecte)
43  Q_PROPERTY(bool peripheriqueEcranTTPADetecte MEMBER peripheriqueEcranTTPADetecte NOTIFY detecte)
44  Q_PROPERTY(bool peripheriqueTableTTPADetecte MEMBER peripheriqueTableTTPADetecte NOTIFY detecte)
45  Q_PROPERTY(bool peripheriqueRobotTTPADetecte MEMBER peripheriqueRobotTTPADetecte NOTIFY detecte)
46  Q_PROPERTY(bool etatRecherche MEMBER etatRecherche NOTIFY recherche)
48  Q_PROPERTY(bool erreurRobotDetecte MEMBER erreurRobotDetecte NOTIFY erreurRobot)
49 
50 public:
52  ~CommunicationBluetooth();
53 
55  {
56  Initial = 0,
57  EnCours = 1,
58  EnPause = 2,
60  };
61 
63 
70  Q_INVOKABLE void rechercherPeripheriquesTTPA();
71 
78  Q_INVOKABLE void arreterRecherche();
79 
87  Q_INVOKABLE bool estValide();
88 
94  Q_INVOKABLE void connecterPeripheriquesTTPA();
95 
101  Q_INVOKABLE void deconnecterPeripheriquesTTPA();
102 
111  Q_INVOKABLE bool envoyerPeripheriqueTTPA(QString nom, QString message);
112 
113 
114  Q_INVOKABLE bool demarrerSeance(QString nomJoueur, QString zoneObjectif, QString zoneRobot, int frequenceBalle, int nbBalles, int effet, int puissance, bool rotation);
115 
127  Q_INVOKABLE bool demarrerSeanceRobot(int frequenceBalle, int nbBalles, int effet, int puissance, bool rotation);
128 
138  Q_INVOKABLE bool demarrerSeanceEcran(QString nomJoueur, QString zoneObjectif, QString zoneRobot);
139 
147  Q_INVOKABLE bool demarrerSeanceTable(int nbBalles);
148 
155  Q_INVOKABLE bool mettreEnPauseSeance();
156 
163  Q_INVOKABLE bool reprendreLaSeance();
164 
171  Q_INVOKABLE bool arreterSeance();
172 
178  bool finirSeance();
179 
186  bool envoyerZoneImpactee(QString zone);
187 
193  bool envoyerErreurRobot();
194 
202  Q_INVOKABLE QString getZoneObjectif(QString zoneObjectif);
203 
211  Q_INVOKABLE QString getZoneRobot(QString zoneRobot);
212 
213  Q_INVOKABLE PeripheriqueTTPA* getPeripheriqueTTPA(QString nom);
214 
217  QVariant getPeripheriquesTTPA();
218 
219 private:
220  QBluetoothLocalDevice peripheriqueBluetoothLocal;
223  QList<QObject*> peripheriquesTTPA;
224  QBluetoothDeviceDiscoveryAgent *discoveryAgentDevice;
225  bool etatRecherche;
229  bool erreurRobotDetecte;
231 
232 public slots:
233  void ajouterPeripheriqueTTPA(const QBluetoothDeviceInfo&);
234  void rechercheTerminee();
235  void rechercheErreur(QBluetoothDeviceDiscoveryAgent::Error erreur);
236  void recevoirTramePeripheriqueTTPA(QString nomPeripherique, QString trame);
237 
238 signals:
239  void recherche();
240  void detecte();
241  void fini();
242  void robotDetecte();
243  void ecranDetecte();
244  void tableDetecte();
246  void erreurRobot();
247 };
248 
249 #endif // CommunicationBluetooth_H
QString nomPeripheriqueBluetoothLocal
le nom du périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:41
void mettreEnPauseSeance()
Met la séance en pause.
Definition: terminal-TTPA/communicationbluetooth.cpp:205
void recevoirTramePeripheriqueTTPA(QString nomPeripherique, QString trame)
Definition: terminal-TTPA/communicationbluetooth.cpp:368
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
Permet la communication avec les appareils Bluetooth TTPA.
Definition: peripheriqueTTPA.h:32
EtatSeance getEtatSeance()
Definition: ecran-TTPA/communicationbluetooth.cpp:209
void rechercheErreur(QBluetoothDeviceDiscoveryAgent::Error erreur)
Definition: terminal-TTPA/communicationbluetooth.cpp:363
bool erreurRobotDetecte
Definition: terminal-TTPA/communicationbluetooth.h:48
QString getNomPeripheriqueBluetoothLocal()
Definition: terminal-TTPA/communicationbluetooth.cpp:95
QString getAdressePeripheriqueBluetoothLocal()
Definition: terminal-TTPA/communicationbluetooth.cpp:100
bool peripheriqueEcranTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:43
QString nom
Definition: ecran-TTPA/communicationbluetooth.h:54
QList< QObject * > peripheriquesTTPA
liste des périphériques Bluetooth TTPA détectés au maximum 3 (Robot, Table et Ecran) ...
Definition: terminal-TTPA/communicationbluetooth.h:223
Q_INVOKABLE bool estValide()
Retourne vrai si l&#39;appareil correspond à un appareil "TTPA".
Definition: terminal-TTPA/communicationbluetooth.cpp:90
QVariant peripheriquesTTPA
Definition: terminal-TTPA/communicationbluetooth.h:47
void rechercheTerminee()
Definition: terminal-TTPA/communicationbluetooth.cpp:355
void ajouterPeripheriqueTTPA(const QBluetoothDeviceInfo &)
Definition: terminal-TTPA/communicationbluetooth.cpp:309
Q_INVOKABLE bool reprendreLaSeance()
Reprend la séance.
Definition: terminal-TTPA/communicationbluetooth.cpp:222
Definition: terminal-TTPA/communicationbluetooth.h:59
Definition: ecran-TTPA/communicationbluetooth.h:40
EtatDeLaSeance
Definition: terminal-TTPA/communicationbluetooth.h:54
QBluetoothLocalDevice peripheriqueBluetoothLocal
le périphérique Bluetooth de la tablette
Definition: terminal-TTPA/communicationbluetooth.h:220
Q_INVOKABLE void arreterRecherche()
Permet d&#39;arreter la recherche des appareils bluetooth "TTPA".
Definition: terminal-TTPA/communicationbluetooth.cpp:79
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
Definition: ecran-TTPA/communicationbluetooth.h:39
void recherche()
signal indiquant que l&#39;état de la recherche de périphériques a changé
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
Q_INVOKABLE QString getZoneObjectif(QString zoneObjectif)
Permet d&#39;obtenir la zone objectif.
Definition: terminal-TTPA/communicationbluetooth.cpp:289
bool finirSeance()
Met fin à la séance lorsque le robot indique qu&#39;il à tirer toutes ses balles.
Definition: terminal-TTPA/communicationbluetooth.cpp:253
Q_INVOKABLE bool demarrerSeance(QString nomJoueur, QString zoneObjectif, QString zoneRobot, int frequenceBalle, int nbBalles, int effet, int puissance, bool rotation)
Definition: terminal-TTPA/communicationbluetooth.cpp:145
Q_INVOKABLE PeripheriqueTTPA * getPeripheriqueTTPA(QString nom)
Definition: terminal-TTPA/communicationbluetooth.cpp:110
Q_INVOKABLE bool arreterSeance()
Met subitement fin à la séance peut importe son état.
Definition: terminal-TTPA/communicationbluetooth.cpp:239
EtatDeLaSeance etatSeance
Definition: terminal-TTPA/communicationbluetooth.h:230
Definition: ecran-TTPA/communicationbluetooth.h:41
Q_INVOKABLE void connecterPeripheriquesTTPA()
Connecte individuelle chaque appareil TTPA détecté
Definition: terminal-TTPA/communicationbluetooth.cpp:406
Assure la détection des périphériques TTPA, leur connexion (et déconnexion) et une communication (env...
Definition: ecran-TTPA/communicationbluetooth.h:29
Q_INVOKABLE QString getZoneRobot(QString zoneRobot)
Permet d&#39;obtenir la zone robot.
Definition: terminal-TTPA/communicationbluetooth.cpp:299
Q_INVOKABLE void rechercherPeripheriquesTTPA()
Assure la recherche d&#39;appareils bluetooth "TTPA".
Definition: terminal-TTPA/communicationbluetooth.cpp:55
bool peripheriqueTableTTPADetecte
Definition: terminal-TTPA/communicationbluetooth.h:44
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
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
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
QVariant getPeripheriquesTTPA()
Definition: terminal-TTPA/communicationbluetooth.cpp:105
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
Q_INVOKABLE void deconnecterPeripheriquesTTPA()
Déconnecte individuelle chaque appareil TTPA détecté
Definition: terminal-TTPA/communicationbluetooth.cpp:423