r_player: changed default mac, added more feedback

This commit is contained in:
schneider 2011-12-16 01:10:27 +01:00
parent b7610d29e7
commit d388a0b335
1 changed files with 26 additions and 27 deletions

View File

@ -10,13 +10,10 @@
#include "basic/config.h" #include "basic/config.h"
#include "usetable.h" #include "usetable.h"
#define REMOTE_CHANNEL 81
//mac that the player receives //channel and mac used to transmit game announcements
#define PLAYER_MAC "\x1\x2\x3\x2\x1" #define ANNOUNCE_CHANNEL 81
#define ANNOUNCE_MAC "REM0T"
//mac that the game receives
#define GAME_MAC "\x1\x2\x3\x2\x1"
struct NRF_CFG config; struct NRF_CFG config;
@ -66,12 +63,8 @@ struct packet{
uint16_t crc; uint16_t crc;
}__attribute__((packed)); }__attribute__((packed));
#define sizeof(p) (sizeof(struct packet))
#define FLAGS_MASS_GAME 1 #define FLAGS_MASS_GAME 1
#define FLAGS_ACK_JOINOK 1 #define FLAGS_ACK_JOINOK 1
#define MASS_ID 1 #define MASS_ID 1
/**************************************************************************/ /**************************************************************************/
@ -108,9 +101,8 @@ void ram(void)
GLOBAL(privacy) = 3; GLOBAL(privacy) = 3;
config.nrmacs=1; config.nrmacs=1;
config.maclen[0] = 32; config.maclen[0] = 32;
config.channel = REMOTE_CHANNEL; config.channel = ANNOUNCE_CHANNEL;
memcpy(config.txmac, GAME_MAC, 5); memcpy(config.mac0, ANNOUNCE_MAC, 5);
memcpy(config.mac0, PLAYER_MAC, 5);
nrf_config_set(&config); nrf_config_set(&config);
id = getRandom(); id = getRandom();
@ -170,15 +162,11 @@ uint8_t joinGame()
int i; int i;
struct packet p; struct packet p;
//config.nrmacs=1;
//config.maclen[0] = 32;
//config.channel = REMOTE_CHANNEL;
//memcpy(config.txmac, GAME_MAC, 5);
//memcpy(config.mac0, PLAYER_MAC, 5);
//nrf_config_set(&config);
lcdClear();
for(i=0; i<10; i++){ for(i=0; i<10; i++){
lcdClear();
lcdPrintln("Joining game");
lcdRefresh();
p.len=sizeof(p); p.len=sizeof(p);
p.protocol='G'; p.protocol='G';
p.command='J'; p.command='J';
@ -195,16 +183,28 @@ uint8_t joinGame()
if( len==sizeof(p) ){ if( len==sizeof(p) ){
if( (p.len==32) && (p.protocol=='G') && p.command=='a' ){ //check sanity, protocol if( (p.len==32) && (p.protocol=='G') && p.command=='a' ){ //check sanity, protocol
if( p.id == id && p.ctr == ctr ){ if( p.id == id && p.ctr == ctr ){
if( p.c.ack.flags & FLAGS_ACK_JOINOK ) if( p.c.ack.flags & FLAGS_ACK_JOINOK ){
lcdPrintln("Join OK");
lcdRefresh();
return 1; return 1;
else }else{
lcdPrintln("Join rejected");
lcdRefresh();
getInputWait();
getInputWaitRelease();
return 0; return 0;
} }
} }
} }
}
delayms(70); delayms(70);
} }
lcdPrintln("timeout :(");
lcdRefresh();
getInputWait();
getInputWaitRelease();
return 0; return 0;
} }
@ -213,9 +213,8 @@ uint8_t selectGame()
int len, i, selected; int len, i, selected;
struct packet p; struct packet p;
int a = 0; int a = 0;
config.channel = REMOTE_CHANNEL; config.channel = ANNOUNCE_CHANNEL;
memcpy(config.txmac, GAME_MAC, 5); memcpy(config.mac0, ANNOUNCE_MAC, 5);
memcpy(config.mac0, PLAYER_MAC, 5);
nrf_config_set(&config); nrf_config_set(&config);
gamecount = 0; gamecount = 0;
@ -272,7 +271,7 @@ void processPacket(struct packet *p)
//processText(&(p->c.text)); //processText(&(p->c.text));
} }
else if (p->command=='N'){ else if (p->command=='N'){
//processNick(&(p->c.nickrequest)); //processNickRequest(&(p->c.nickrequest));
} }
else if (p->command=='A'){ else if (p->command=='A'){
processAnnounce(&(p->c.announce)); processAnnounce(&(p->c.announce));