Afficheur-AREA  1.1
BTS SNIR LaSalle Avignon 2021
Communication.h
Aller à la documentation de ce fichier.
1 #ifndef COMMUNICATION_H
2 #define COMMUNICATION_H
3 
4 #include <QObject>
5 #include <QString>
6 #include <QBluetoothLocalDevice>
7 #include <QBluetoothServer>
8 #include <QBluetoothSocket>
9 
19 #define ENTETE_TRAME "MOBILE_AREA"
20 #define CHAMP_TYPE_TRAME 1
21 
22 #define NOM_CLUB_1 2
23 #define NOM_CLUB_2 3
24 
25 #define ID_PARTIE 2
26 
27 #define POINTS_JOUEUR_A 3
28 #define POINTS_JOUEUR_B 4
29 #define MANCHES_JOUEUR_A 5
30 #define MANCHES_JOUEUR_B 6
31 
32 #define ETAT 3
33 
34 #define NB_CHAMPS_PARTIE_SIMPLE 7
35 
36 
42 {
47  NET,
49 };
50 
51 static const QString uuidService(QStringLiteral("0000110a-0000-1000-8000-00805f9b34fb"));
52 static const QString nomService(QStringLiteral("Afficheur_AREA"));
53 
54 class Rencontre;
55 
61 class Communication : public QObject
62 {
63  Q_OBJECT
64 private:
66  QBluetoothServer *serveur;
67  QBluetoothSocket *socket;
68  QBluetoothLocalDevice peripheriqueLocal;
69  QBluetoothServiceInfo serviceInfo;
71  QString trame;
72  QString trames;
73  QStringList infosTrame;
74 
75  bool traiterTrame(QStringList infosTrame);
76 
77 public:
78  Communication(QObject *parent = nullptr);
79  ~Communication();
80 
81  void initialiser();
82  void demarrer();
83  void arreter();
84  QString getTrame() const;
85 
86 private slots:
87  void connecterSocket();
88  void deconnecterSocket();
89  void recevoirErreurSocket(QBluetoothSocket::SocketError erreurSocket);
90  void connecterTerminalMobile(const QBluetoothAddress &adresse);
91  void deconnecterTerminalMobile(const QBluetoothAddress &adresse);
92  void recevoirErreurBluetooth(QBluetoothLocalDevice::Error erreurBluetooth);
93  void lireTrame();
94 
95 signals:
96  void debutRencontre(QString club1, QString club2);
97  void creationPartieSimple(QStringList infoTrame);
98  void creationPartieDouble(QStringList infoTrame);
99  void nouveauScorePartie(int idPartie, int scoreA, int scoreB, int nbManchesJoueurA, int nbManchesJoueurB);
100  void changementEtatPartie(int idPartie, QString etatPartie);
101  void detectionNET(int idPartie);
102  void demandeTempsMort();
103  void socketConnectee();
104  void socketDeconnectee();
105 };
106 
107 #endif // COMMUNICATION_H
QString trame
Une trame extraite.
Definition: Communication.h:71
void recevoirErreurBluetooth(QBluetoothLocalDevice::Error erreurBluetooth)
Méthode slot de débug qui signale une erreur de Bluetooth.
void lireTrame()
Méthode slot qui lit les trames recues et les séparent en plusieurs trames afin de les traiter...
void recevoirErreurSocket(QBluetoothSocket::SocketError erreurSocket)
Méthode slot de débug qui signale une erreur du socket.
QString nomPeripheriqueLocal
Nom du périphérique local.
Definition: Communication.h:70
~Communication()
Déstructeur de la classe Communication.
Rencontre * rencontre
Pointeur pour la relation avec la classe Rencontre.
Definition: Communication.h:65
void changementEtatPartie(int idPartie, QString etatPartie)
Signal de début ou de fin de partie.
static const QString uuidService(QStringLiteral("0000110a-0000-1000-8000-00805f9b34fb"))
void deconnecterTerminalMobile(const QBluetoothAddress &adresse)
Méthode slot de débug qui signale la déconnexion d&#39;un terminal mobile.
Déclaration de la classe Rencontre.
Definition: Rencontre.h:31
void detectionNET(int idPartie)
Signal de détection d&#39;une sequence de net.
void demarrer()
Méthode qui démarre le serveur Bluetooth.
bool traiterTrame(QStringList infosTrame)
Méthode qui raite la trame recue selon le champ TypeTrame.
QBluetoothServiceInfo serviceInfo
Informations sur le service bluetooth.
Definition: Communication.h:69
TypeTrame
Les différents types de trame.
Definition: Communication.h:41
QBluetoothServer * serveur
Le serveur Bluetooth.
Definition: Communication.h:66
QString getTrame() const
Méthode qui retourne la derniere trame recue.
void socketDeconnectee()
Signal de déconnextion de socket.
void connecterSocket()
Méthode slot qui permet la connection au socket du serveur et connecte les signaux et slots...
QBluetoothSocket * socket
La socket de communication Bluetooth.
Definition: Communication.h:67
QString trames
Les trames recues.
Definition: Communication.h:72
void creationPartieDouble(QStringList infoTrame)
Signal de création d&#39;une partie double.
void creationPartieSimple(QStringList infoTrame)
Signal de création d&#39;une partie simple.
QBluetoothLocalDevice peripheriqueLocal
L&#39;interface Bluetooth de la Raspberry Pi.
Definition: Communication.h:68
Déclaration de la classe Communication.
Definition: Communication.h:61
void nouveauScorePartie(int idPartie, int scoreA, int scoreB, int nbManchesJoueurA, int nbManchesJoueurB)
Signal de rafraichissement du score d&#39;une partie.
QStringList infosTrame
Les informations transmises dans la trame.
Definition: Communication.h:73
void socketConnectee()
Signal de connextion de socket.
void arreter()
Méthode qui arrête le serveur Bluetooth.
static const QString nomService(QStringLiteral("Afficheur_AREA"))
void initialiser()
Méthode qui prépare la connexion Bluetooth en mode serveur.
void demandeTempsMort()
Signal de demande de temps mort.
void debutRencontre(QString club1, QString club2)
Signal de début de rencontre.
Communication(QObject *parent=nullptr)
Constructeur de la classe Communication.
void deconnecterSocket()
Méthode slot de déconnexion du socket.
void connecterTerminalMobile(const QBluetoothAddress &adresse)
Méthode slot de débug qui signale la connextion d&#39;un teminal mobile.