Polytech school project. RICM4 students, see http://air.imag.fr/index.php/Projets-2016-2017-Station_de_pompage_connect%C3%A9e for more information
Dependencies: SX1272Lib mbed WakeUp
Fork of SX1272PingPong by
trame.cpp
- Committer:
- chevamax
- Date:
- 2017-04-01
- Revision:
- 17:cce0eada6d82
- Parent:
- 15:79a78f997f18
File content as of revision 17:cce0eada6d82:
#include "mbed.h" #include "trame.h" #include "debug.h" TrameData::TrameData(char idE, char idS, int nbNiveau, char etatP, char niveau, char batterie){ idEmetteur = idE; idStation = idS; if(nbNiveau >= 63){ nombreNiveau = 0x1F; }else{ nombreNiveau = (char) nbNiveau; } mettreAJourEtatPompe(etatP); mettreAJourNiveauCuve(niveau); mettreAJourNiveauBatterie(batterie); trame[4]=0; } char getiemebit(char c, int i) { return ((c>>(7-i)) & 1); } char* TrameData::creerTrame(){ trame[0] = idStation; trame[1] = idEmetteur; trame[2] = (etatPompe<<7)|(nombreNiveau<<2)|(niveauCuve>>3); trame[3] = (niveauCuve<<5)|(niveauBatterie); //Etat Pompe for(int i=0; i < 8; i++){ if(getiemebit(etatPompe, i)){ debug("1"); } else{ debug("0"); } } debug("\r\n"); //nombreNiveau for(int i=0; i < 8; i++){ if(getiemebit(nombreNiveau, i)){ debug("1"); } else{ debug("0"); } } debug("\r\n"); //niveauCuve for(int i=0; i < 8; i++){ if(getiemebit(niveauCuve, i)){ debug("1"); } else{ debug("0"); } } debug("\r\n"); //niveauBatterie for(int i=0; i < 8; i++){ if(getiemebit(niveauBatterie, i)){ debug("1"); } else{ debug("0"); } } //debug("%c ; %c ; %c\r\n",trame[0],trame[1],trame[2]); char courant; debug("%d\r\n", sizeof(char)); for(int j=0; j<4;j++){ courant = trame[j]; for(int i=0; i < 8; i++){ if(getiemebit(courant, i)){ debug("1"); } else{ debug("0"); } } debug(" "); } debug("\r\n"); return trame; } void TrameData::mettreAJourEtatPompe(char etatP){ etatPompe = etatP; } void TrameData::mettreAJourNiveauCuve(char niveau){ niveauCuve = niveau; } void TrameData::mettreAJourNiveauBatterie(char niveau){ niveauBatterie = niveau; }