MQTT Client for mbed LPC1768 and Application Board over Ethernet; publish only.

Dependencies:   C12832 MMA7660 MQTT

Fork of HelloMQTT by MQTT

genRandom

Back

genRandom dient ausschließlich im Klassenraum bzw. am Brocker, um unterschiedliche Client-IDs in der Startphase zu haben:

static const char alphanum[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int stringLength = sizeof(alphanum) - 1;
// use for random
#include "MMA7660.h"
 
MMA7660 MMA(p28, p27);

char genRandom()
{
    if (MMA.testConnection())
        logMessage("get seed: Please shake the board for 1s \r\n");
    int x;    
    for (int i=0; i < 5; i++) {
        x=(int) (MMA.z() * MMA.z() * MMA.z()*100)% 65;
        //logMessage("seed: %d\r\n", x);
        wait_ms(200);
    }
    srand (x);
    return alphanum[rand() % stringLength];
}


All wikipages