code pour recevoir des trames et mettre les char sur le port usb

Dependencies:   mbed

Fork of APP4 by S5info_H14

Committer:
RufflesAllD
Date:
Tue Feb 25 16:31:11 2014 +0000
Revision:
5:daf08fff7abb
Parent:
4:56b1ca37a175
Child:
7:a6f58e5d1188
Final, valid?, comment?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joGenie 0:71df0feee697 1 #ifndef COORDINATEUR_HPP
joGenie 0:71df0feee697 2 #define COORDINATEUR_HPP
joGenie 0:71df0feee697 3
joGenie 0:71df0feee697 4 #include <string>
RufflesAllD 5:daf08fff7abb 5 #include <sstream>
joGenie 2:7515831bb5f5 6 #include "trame.hpp"
RufflesAllD 5:daf08fff7abb 7 #include "EthernetInterface.h"
RufflesAllD 5:daf08fff7abb 8 #include "Websocket.h"
joGenie 0:71df0feee697 9
joGenie 0:71df0feee697 10 using namespace std;
joGenie 0:71df0feee697 11
RufflesAllD 5:daf08fff7abb 12 /* Description de la classe Coordinateur
RufflesAllD 5:daf08fff7abb 13 *
RufflesAllD 5:daf08fff7abb 14 * La classe Coordinateur configure le coordinateur, reçoit les trames du routeurs et envoie les informations à un site web
RufflesAllD 5:daf08fff7abb 15 *
RufflesAllD 5:daf08fff7abb 16 */
joGenie 0:71df0feee697 17 class Coordinateur
joGenie 0:71df0feee697 18 {
joGenie 0:71df0feee697 19 public:
RufflesAllD 5:daf08fff7abb 20 // Enum pour la machine d'état qui reconstruit les trames reçues
RufflesAllD 5:daf08fff7abb 21 enum Etat { Start, Length, Length2, Data };
RufflesAllD 5:daf08fff7abb 22
joGenie 0:71df0feee697 23 // Constructeur
joGenie 2:7515831bb5f5 24 Coordinateur(PinName _tx, PinName _rx);
RufflesAllD 5:daf08fff7abb 25 // Destructeur
RufflesAllD 5:daf08fff7abb 26 ~Coordinateur();
joGenie 0:71df0feee697 27
RufflesAllD 5:daf08fff7abb 28 // Set le réseau du coordinateur
RufflesAllD 5:daf08fff7abb 29 void setPanID(string _pan);
RufflesAllD 5:daf08fff7abb 30 // Initialise la connection ethernet et le websocket
RufflesAllD 5:daf08fff7abb 31 void setURL(string _url);
RufflesAllD 5:daf08fff7abb 32 // Attend de recevoir les trames
RufflesAllD 5:daf08fff7abb 33 void getBytes();
joGenie 3:350f07072089 34
joGenie 0:71df0feee697 35 private:
RufflesAllD 5:daf08fff7abb 36 // Machine à état qui reçoit les trames
RufflesAllD 5:daf08fff7abb 37 void etatTrame(char c);
RufflesAllD 5:daf08fff7abb 38 // Envoie le data reçu à la page web
RufflesAllD 5:daf08fff7abb 39 void sendDataToWeb(char *data, int length);
RufflesAllD 5:daf08fff7abb 40 string intToString(int value);
RufflesAllD 5:daf08fff7abb 41
joGenie 2:7515831bb5f5 42 Trame trame;
joGenie 0:71df0feee697 43 string pan;
RufflesAllD 5:daf08fff7abb 44 string url;
RufflesAllD 5:daf08fff7abb 45 Serial xbee;
RufflesAllD 5:daf08fff7abb 46 Etat etat;
RufflesAllD 5:daf08fff7abb 47 char length[2];
RufflesAllD 5:daf08fff7abb 48 int length_int;
RufflesAllD 5:daf08fff7abb 49 int counter;
RufflesAllD 5:daf08fff7abb 50 char *data;
RufflesAllD 5:daf08fff7abb 51
RufflesAllD 5:daf08fff7abb 52 EthernetInterface *eth;
RufflesAllD 5:daf08fff7abb 53 Websocket *ws;
joGenie 0:71df0feee697 54 };
joGenie 0:71df0feee697 55
joGenie 0:71df0feee697 56 #endif