Example #1
0
/*----------------------------------------------------------------------------*
 *  NAME
 *      appSetRandomAddress
 *
 *  DESCRIPTION
 *      This function generates a non-resolvable private address and sets it
 *      to the firmware.
 *
 *  RETURNS
 *      Nothing.
 *
 *----------------------------------------------------------------------------*/
static void appSetRandomAddress(void)
{
    BD_ADDR_T addr;

    /* "completely" random MAC addresses by default: */
    for(;;)
    {
        uint32 now = TimeGet32();
        /* Random32() is just two of them, no use */
        uint32 rnd = Random16();
        addr.uap = 0xff & (rnd ^ now);
        /* No sub-part may be zero or all-1s */
        if ( 0 == addr.uap || 0xff == addr.uap ) continue;
        addr.lap = 0xffffff & ((now >> 8) ^ (73 * rnd));
        if ( 0 == addr.lap || 0xffffff == addr.lap ) continue;
        addr.nap = 0x3fff & rnd;
        if ( 0 == addr.nap || 0x3fff == addr.nap ) continue;
        break;
    }

    /* Set it to actually be an acceptable random address */
    addr.nap &= ~BD_ADDR_NAP_RANDOM_TYPE_MASK;
    addr.nap |=  BD_ADDR_NAP_RANDOM_TYPE_NONRESOLV;
    GapSetRandomAddress(&addr);
}
Example #2
0
/*----------------------------------------------------------------------------*
 *  NAME
 *      appRandomDelay
 *
 *  DESCRIPTION
 *      This function generates a random delay from 0 to 10ms in steps of 50us.
 *
 *  RETURNS
 *      Returns delay in Micro Seconds.
 *
 *---------------------------------------------------------------------------*/
static uint16 appRandomDelay(void)
{
    uint16 rand_num = Random16();
    rand_num = rand_num%201;
    return (rand_num * 50);
}
Example #3
0
uint32_t Random32(void)
{
    uint16_t output = Random16() << 16 | Random16();
    return output;
}