Example #1
0
File: spam.c Project: astro/lun1k
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);
        }
    }
}
Example #2
0
void initMesh(void){
    for(int i=0;i<MESHBUFSIZE;i++){
        meshbuffer[i].flags=MF_FREE;
    };
    memset(meshbuffer[0].pkt,0,MESHPKTSIZE);
    meshbuffer[0].pkt[0]='T';
    MO_TIME_set(meshbuffer[0].pkt,getSeconds());
    meshbuffer[0].flags=MF_USED;
};
Example #3
0
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;
}
Example #4
0
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));
	}
}
Example #5
0
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;
}
Example #6
0
File: jump.c Project: Bediko/r0ket
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;
}
Example #7
0
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;
}
Example #8
0
void mesh_sendloop(void){
    int ctr=0;
    __attribute__ ((aligned (4))) uint8_t buf[32];
    int status;
    uint32_t rnd=0xffffffff;

    if(meshnice)
        rnd=getRandom();

    nrf_config_get(&oldconfig);
    nrf_set_channel(MESH_CHANNEL);
    nrf_set_tx_mac(strlen(MESH_MAC),(uint8_t*)MESH_MAC);

    // Update [T]ime packet
    MO_TIME_set(meshbuffer[0].pkt,getSeconds());
    MO_GEN_set(meshbuffer[0].pkt,meshgen);
    if(GLOBAL(privacy)==0)
        uint32touint8p(GetUUID32(),MO_BODY(meshbuffer[0].pkt));
    else
        uint32touint8p(0,MO_BODY(meshbuffer[0].pkt));

    MO_BODY(meshbuffer[0].pkt)[4]=meshnice;

    for (int i=0;i<MESHBUFSIZE;i++){
        if(!meshbuffer[i].flags&MF_USED)
            continue;
        if(meshbuffer[i].flags&MF_LOCK)
            continue;
        if(meshnice&0xf){
            if((rnd++)%0xf < (meshnice&0x0f)){
                meshincctr++;
                continue;
            };
        };
        ctr++;
        memcpy(buf,meshbuffer[i].pkt,MESHPKTSIZE);
        status=nrf_snd_pkt_crc_encr(MESHPKTSIZE,buf,meshkey);
        //Check status? But what would we do...
    };

    nrf_config_set(&oldconfig);
};
Example #9
0
File: f00nk.c Project: astro/lun1k
static void time_set(time_t time) {
  MPKT *mpkt = meshGetMessage('T');
  MO_TIME_set(mpkt->pkt, time);
}
Example #10
0
File: f00nk.c Project: astro/lun1k
static void bar_set(char *s) {
  MPKT *mpkt = meshGetMessage('b');
  MO_TIME_set(mpkt->pkt, 2342);
  strcpy((char*)MO_BODY(mpkt->pkt),s);
}
Example #11
0
File: f00nk.c Project: astro/lun1k
static void foo_set(char *s) {
  MPKT *mpkt = meshGetMessage('G');
  MO_TIME_set(mpkt->pkt, 1313803870);
  strcpy((char*)MO_BODY(mpkt->pkt),s);
}