Hi,

I have to generate random number for a node to use in key generation. But i
always get the same random number. So ichanged seed value using the current
system time as shown below.

module SecurityC{

    uses interface Boot;
    uses interface Random;
    uses interface ParameterInit<uint16_t> as SeedInit;
    uses interface Timer<TMilli>;
}

implementation{

    uint32_t rand1;
    uint32_t t;

    event void Timer.fired() {

         t=call Timer.getNow();
        dbg("Boot", "%s Current time: %d \n", sim_time_string(), t);
    }

    event void Boot.booted()
    {

        dbg("Boot", "Application booted.\n");
        t=call Timer.getNow();
        call SeedInit.init(t);

        rand1 = (call Random.rand32()%10)+7;

        dbg("Boot", "%s Random number 1: %d \n", sim_time_string(), rand1);

    }
}

But still i am getting the same number always. How to solve this?
Regards,

Jisha Mary Jose
......jMj......
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to