Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Repo_Noeud_Mobile by
Diff: Communication/Xbee.cpp
- Revision:
- 44:0862bc49ffa7
- Parent:
- 42:94d329a40290
- Child:
- 48:bc531288c220
- Child:
- 50:48e8da5fc1ae
--- a/Communication/Xbee.cpp Wed Apr 08 14:10:12 2015 +0000 +++ b/Communication/Xbee.cpp Wed Apr 08 19:38:12 2015 +0000 @@ -116,52 +116,52 @@ //Structure de reception sera Fixe_Vers_Mobile void Xbee::Recevoir() { - Fixe_Vers_Mobile receivedData; + char buffer[3]; int index = 0; - char buffer[8]; while(true) { if (XbeePin->readable()) { //Start byte if (XbeePin->getc() == 0x7E) { + index = 0; + //Get length and frame type - while (index != 3) { + while (index < 3) { buffer[index] = XbeePin->getc(); index++; } index = 0; //If frame is a receive packet if (buffer[2] == 0x90) { + //Ici va falloir compter le nombre de bytes de niaiseries - //qui se passent avant les datas, 13 je crois + //qui se passent avant les datas, 11 je crois do { char c = XbeePin->getc(); index++; - } while (index != 13); - - //Game - receivedData.game = XbeePin->getc(); - - //Etat - buffer[0] = XbeePin->getc(); - receivedData.etat = buffer[0] == 0 ? false : true; - - //Est-ce qu'il y a un minimum de byte dans les data? + } while (index < 11); + index = 0; - //Validate end byte - if (XbeePin->getc() == 0x7E) { - message_vers_mobile *emile = MailboxReception.alloc(); - - // Verifier si mail pointe pas vers 0 [boite pleine] - while (emile == 0) { - wait_ms(25); - emile = MailboxReception.alloc(); - } - emile->donnees = receivedData; - MailboxReception.put(emile); + //GameID + int gameMode = XbeePin->getc() - 60; + index++; + + //ChkSum + buffer[0] = XbeePin->getc(); + + Fixe_Vers_Mobile *emile = mailbox_TypeDeJeu.alloc(); + + // Verifier si mail pointe pas vers 0 [boite pleine] + while (emile == 0) { + wait_ms(25); + emile = mailbox_TypeDeJeu.alloc(); } + emile->game = GameMode_e(gameMode); + mailbox_TypeDeJeu.put(emile); + index = 0; } } } + index = 0; } }