void ram() { lcdClear(); lcdPrintln("SPAM:"); while(getInputRaw() != BTN_LEFT) { char c[2] = {0, 0}; c[0] = (char)getRandom(); uint8_t pkt[32]; MO_TYPE_set(pkt, c[0]); MO_GEN_set(pkt, 0xFF); if (c[0] >= 'A' && c[0] <= 'Z') MO_TIME_set(pkt, 1313803870); else if (c[0] >= 'a' && c[0] <= 'z') MO_TIME_set(pkt, getRandom() % 16777216); else MO_TIME_set(pkt, (uint32_t)getRandom()); strcpy((char *)MO_BODY(pkt), "chaosbay.camp.ccc.de"); if (!mesh_sanity(pkt)) { lcdPrint("Sending: "); lcdPrintln(c); lcdRefresh(); MPKT *mpkt = meshGetMessage(c[0]); mpkt->flags = MF_USED; memcpy(mpkt->pkt, pkt, 32); } } }
static uint32_t highscore_get(char nick[]){ MPKT * mpkt= meshGetMessage('j'); strcpy(nick,(char*)MO_BODY(mpkt->pkt)); return MO_TIME(mpkt->pkt); }
static bool highscore_set(uint32_t score, char nick[]) { MPKT * mpkt= meshGetMessage('i'); if(MO_TIME(mpkt->pkt)>score) return false; MO_TIME_set(mpkt->pkt,score); strcpy((char*)MO_BODY(mpkt->pkt),nick); return true; }
uint8_t mesh_recvqloop_work(void){ __attribute__ ((aligned (4))) uint8_t buf[32]; int len; len=nrf_rcv_pkt_poll_dec(sizeof(buf),buf,meshkey); // Receive if(len<=0){ return 0; }; if(MO_GEN(buf)>meshgen){ if(meshgen) meshgen++; else meshgen=MO_GEN(buf); _timet=0; meshincctr=0; meshnice=0; }; if(MO_TYPE(buf)=='T'){ time_t toff=MO_TIME(buf)-((getTimer()+(600/SYSTICKSPEED))/(1000/SYSTICKSPEED)); if (toff>_timet){ // Do not live in the past. _timet = toff; meshincctr++; }; if(MO_BODY(buf)[4] > meshnice) meshnice=MO_BODY(buf)[4]; return 1; }; // Safety: Truncate ascii packets by 0-ing the CRC buf[MESHPKTSIZE-2]=0; // Store packet in a same/free slot MPKT* mpkt=meshGetMessage(MO_TYPE(buf)); // Skip locked packet if(mpkt->flags&MF_LOCK) return 2; // only accept newer/better packets if(mpkt->flags==MF_USED) if(MO_TIME(buf)<=MO_TIME(mpkt->pkt)) return 2; if((MO_TYPE(buf)>='A' && MO_TYPE(buf)<='C') || (MO_TYPE(buf)>='A' && MO_TYPE(buf)<='C')) meshmsg=1; memcpy(mpkt->pkt,buf,MESHPKTSIZE); mpkt->flags=MF_USED; return 1; };
static void transmitGeigerMeshVal(uint32_t cpm,uint32_t time) { if (perMin>0) { MPKT * mpkt= meshGetMessage('g'); MO_TIME_set(mpkt->pkt,(time & 0xFFFFF)); strcpy((char*)MO_BODY(mpkt->pkt),IntToStr(cpm,5,0)); strcpy((char*)(MO_BODY(mpkt->pkt)+strlen((char*)MO_BODY(mpkt->pkt)))," cpm"); lcdPrint("S:"); lcdPrintln((char*)MO_BODY(mpkt->pkt)); } }
static bool set_msg(char m[]) { MPKT * mpkt = meshGetMessage('D'); MO_TIME_set(mpkt->pkt,1313803870); strcpy((char*)MO_BODY(mpkt->pkt),m); // if(GLOBAL(privacy)==0){ // uint32touint8p(GetUUID32(),mpkt->pkt+26); // mpkt->pkt[25]=0; // }; return true; }
static uint32_t highscore_get(char nick[]){ #if 0 MPKT * mpkt= meshGetMessage('s'); char * packet_nick = (char*)MO_BODY(mpkt->pkt); // the packet crc end is already zeroed if(MAXNICK<MESHPKTSIZE-2-6-1) packet_nick[MAXNICK-1] = 0; strcpy(nick, packet_nick); return MO_TIME(mpkt->pkt); #endif return 0; }
static void getGeigerMeshVal() { MPKT * mpkt= meshGetMessage('g'); //char buf[32]; if (MO_TIME(mpkt->pkt)!=0) { lcdPrint("Mesh:"); lcdPrintln((char*)MO_BODY(mpkt->pkt)); //lcdPrintln("cpm"); } else { mpkt->flags=MF_FREE; } }
static bool highscore_set(uint32_t score, char nick[]) { MPKT * mpkt= meshGetMessage('j'); if(MO_TIME(mpkt->pkt)>score) return false; MO_TIME_set(mpkt->pkt,score); strcpy((char*)MO_BODY(mpkt->pkt),nick); if(GLOBAL(privacy)==0){ uint32touint8p(GetUUID32(),mpkt->pkt+26); mpkt->pkt[25]=0; }; return true; }
static uint32_t highscore_get() { uint32_t score = 0; readFile("snake.5cr", &score, sizeof(score)); // old r0ket code to send highscore to the world #if 0 MPKT * mpkt= meshGetMessage('s'); char * packet_nick = (char*)MO_BODY(mpkt->pkt); // the packet crc end is already zeroed if(MAXNICK<MESHPKTSIZE-2-6-1) packet_nick[MAXNICK-1] = 0; strcpy(nick, packet_nick); return MO_TIME(mpkt->pkt); #endif return score; }
static bool highscore_set(uint32_t score) { writeFile("snake.5cr", &score , sizeof(uint32_t)); // old r0ket code to get highscore from the world #if 0 MPKT * mpkt= meshGetMessage('s'); if(MO_TIME(mpkt->pkt)>score) return false; MO_TIME_set(mpkt->pkt,score); strcpy((char*)MO_BODY(mpkt->pkt),nick); if(GLOBAL(privacy)==0) { uint32touint8p(GetUUID32(),mpkt->pkt+26); mpkt->pkt[25]=0; }; #endif return true; }
static void time_set(time_t time) { MPKT *mpkt = meshGetMessage('T'); MO_TIME_set(mpkt->pkt, time); }
static void bar_set(char *s) { MPKT *mpkt = meshGetMessage('b'); MO_TIME_set(mpkt->pkt, 2342); strcpy((char*)MO_BODY(mpkt->pkt),s); }
static void foo_set(char *s) { MPKT *mpkt = meshGetMessage('G'); MO_TIME_set(mpkt->pkt, 1313803870); strcpy((char*)MO_BODY(mpkt->pkt),s); }