Skip to content

Commit d2500e1

Browse files
committed
simplified MessageID Class
removed ESPTrueRandom library
1 parent 94d5aaf commit d2500e1

File tree

4 files changed

+14
-234
lines changed

4 files changed

+14
-234
lines changed

src/SinricPro.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include "SinricProQueue.h"
1818
#include "SinricProNTP.h"
1919

20-
#include "extralib/ESPTrueRandom/ESPTrueRandom.h"
21-
2220
class SinricProClass : public SinricProInterface {
2321
public:
2422
void begin(String socketAuthToken, String signingKey, String serverURL = SERVER_URL);

src/SinricProMessageid.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@
88
#ifndef __MESSAGEID_H__
99
#define __MESSAGEID_H__
1010

11-
#include "extralib/ESPTrueRandom/ESPTrueRandom.h"
12-
1311
class MessageID {
1412
public:
1513
MessageID();
16-
char* getID() { return msg_id; };
14+
const String& getID() { return _id; }
1715
private:
18-
void newMsgId();
19-
char msg_id[37];
16+
String _id;
2017
};
2118

2219
MessageID::MessageID() {
23-
newMsgId();
24-
}
25-
26-
void MessageID::newMsgId() {
27-
byte new_uuid[16];
28-
ESPTrueRandom.uuid(new_uuid);
29-
strlcpy(msg_id, ESPTrueRandom.uuidToString(new_uuid).c_str(), 37);
20+
_id = "";
21+
for (byte i=0; i<16; i++) {
22+
byte rnd = random(255);
23+
if (i==4) _id += "-";
24+
if (i==6) { _id += "-"; rnd = 0x40 | (0x0F & rnd); } // 0100xxxx to set version 4
25+
if (i==8) { _id += "-"; rnd = 0x80 | (0x3F & rnd); } // 10xxxxxx to set reserved bits
26+
if (i==10) _id += "-";
27+
byte high_nibble = rnd >> 4;
28+
byte low_nibble = rnd & 0x0f;
29+
_id += "0123456789abcdef"[high_nibble];
30+
_id += "0123456789abcdef"[low_nibble];
31+
}
3032
}
3133

3234
#endif // __MESSAGEID_H__

src/extralib/ESPTrueRandom/ESPTrueRandom.cpp

Lines changed: 0 additions & 174 deletions
This file was deleted.

src/extralib/ESPTrueRandom/ESPTrueRandom.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)