From d388a0b3355903df569e7fee39efb30cc288075d Mon Sep 17 00:00:00 2001 From: schneider Date: Fri, 16 Dec 2011 01:10:27 +0100 Subject: [PATCH] r_player: changed default mac, added more feedback --- firmware/l0dable/r_player.c | 53 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/firmware/l0dable/r_player.c b/firmware/l0dable/r_player.c index a4c0a3f..fb46308 100644 --- a/firmware/l0dable/r_player.c +++ b/firmware/l0dable/r_player.c @@ -10,13 +10,10 @@ #include "basic/config.h" #include "usetable.h" -#define REMOTE_CHANNEL 81 -//mac that the player receives -#define PLAYER_MAC "\x1\x2\x3\x2\x1" - -//mac that the game receives -#define GAME_MAC "\x1\x2\x3\x2\x1" +//channel and mac used to transmit game announcements +#define ANNOUNCE_CHANNEL 81 +#define ANNOUNCE_MAC "REM0T" struct NRF_CFG config; @@ -66,12 +63,8 @@ struct packet{ uint16_t crc; }__attribute__((packed)); -#define sizeof(p) (sizeof(struct packet)) - #define FLAGS_MASS_GAME 1 - #define FLAGS_ACK_JOINOK 1 - #define MASS_ID 1 /**************************************************************************/ @@ -108,9 +101,8 @@ void ram(void) GLOBAL(privacy) = 3; config.nrmacs=1; config.maclen[0] = 32; - config.channel = REMOTE_CHANNEL; - memcpy(config.txmac, GAME_MAC, 5); - memcpy(config.mac0, PLAYER_MAC, 5); + config.channel = ANNOUNCE_CHANNEL; + memcpy(config.mac0, ANNOUNCE_MAC, 5); nrf_config_set(&config); id = getRandom(); @@ -170,15 +162,11 @@ uint8_t joinGame() int i; 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++){ + lcdClear(); + lcdPrintln("Joining game"); + lcdRefresh(); + p.len=sizeof(p); p.protocol='G'; p.command='J'; @@ -195,16 +183,28 @@ uint8_t joinGame() if( len==sizeof(p) ){ if( (p.len==32) && (p.protocol=='G') && p.command=='a' ){ //check sanity, protocol 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; - else + }else{ + lcdPrintln("Join rejected"); + lcdRefresh(); + getInputWait(); + getInputWaitRelease(); return 0; + } } } } delayms(70); } + lcdPrintln("timeout :("); + lcdRefresh(); + getInputWait(); + getInputWaitRelease(); + return 0; } @@ -213,9 +213,8 @@ uint8_t selectGame() int len, i, selected; struct packet p; int a = 0; - config.channel = REMOTE_CHANNEL; - memcpy(config.txmac, GAME_MAC, 5); - memcpy(config.mac0, PLAYER_MAC, 5); + config.channel = ANNOUNCE_CHANNEL; + memcpy(config.mac0, ANNOUNCE_MAC, 5); nrf_config_set(&config); gamecount = 0; @@ -272,7 +271,7 @@ void processPacket(struct packet *p) //processText(&(p->c.text)); } else if (p->command=='N'){ - //processNick(&(p->c.nickrequest)); + //processNickRequest(&(p->c.nickrequest)); } else if (p->command=='A'){ processAnnounce(&(p->c.announce));