mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* added RTCClock::getCurrentTimeUnique(), for when timestamps need to be unique (if temp rapid-fire)
This commit is contained in:
parent
a115626afd
commit
ba181da94a
4 changed files with 19 additions and 7 deletions
12
src/Mesh.h
12
src/Mesh.h
|
|
@ -8,6 +8,10 @@ namespace mesh {
|
|||
* An abstraction of the device's Realtime Clock.
|
||||
*/
|
||||
class RTCClock {
|
||||
uint32_t last_unique;
|
||||
protected:
|
||||
RTCClock() { last_unique = 0; }
|
||||
|
||||
public:
|
||||
/**
|
||||
* \returns the current time. in UNIX epoch seconds.
|
||||
|
|
@ -18,6 +22,14 @@ public:
|
|||
* \param time current time in UNIX epoch seconds.
|
||||
*/
|
||||
virtual void setCurrentTime(uint32_t time) = 0;
|
||||
|
||||
uint32_t getCurrentTimeUnique() {
|
||||
uint32_t t = getCurrentTime();
|
||||
if (t <= last_unique) {
|
||||
return ++last_unique;
|
||||
}
|
||||
return last_unique = t;
|
||||
}
|
||||
};
|
||||
|
||||
class GroupChannel {
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ bool BaseChatMesh::sendLogin(const ContactInfo& recipient, const char* password,
|
|||
|
||||
int tlen;
|
||||
uint8_t temp[24];
|
||||
uint32_t now = getRTCClock()->getCurrentTime();
|
||||
uint32_t now = getRTCClock()->getCurrentTimeUnique();
|
||||
memcpy(temp, &now, 4); // mostly an extra blob to help make packet_hash unique
|
||||
if (recipient.type == ADV_TYPE_ROOM) {
|
||||
memcpy(&temp[4], &recipient.sync_since, 4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue