Skip to content

Commit

Permalink
Merge pull request #60 from technyon/main
Browse files Browse the repository at this point in the history
use atomic types for shared variables in onResult
  • Loading branch information
Bascy authored Jun 18, 2024
2 parents 2e4fbca + 9610e7d commit 1c0ecf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/NukiBle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ NukiBle::NukiBle(const std::string& deviceName,
deviceServiceUUID(deviceServiceUUID),
gdioUUID(gdioUUID),
userDataUUID(userDataUUID),
preferencesId(preferencedId) {
preferencesId(preferencedId)
{
rssi = 0;
lastReceivedBeaconTs = 0;
lastHeartbeat = 0;
}

NukiBle::~NukiBle() {
Expand Down
7 changes: 4 additions & 3 deletions src/NukiBle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <Preferences.h>
#include <esp_task_wdt.h>
#include <BleInterfaces.h>
#include <atomic>
#include "sodium/crypto_secretbox.h"

#define GENERAL_TIMEOUT 3000
Expand Down Expand Up @@ -363,7 +364,7 @@ class NukiBle : public BLEClientCallbacks, public BleScanner::Subscriber {
Nuki::CommandState nukiCommandState = Nuki::CommandState::Idle;

uint32_t timeNow = 0;
uint32_t lastHeartbeat = 0;
std::atomic_uint lastHeartbeat;

BleScanner::Publisher* bleScanner = nullptr;
bool isPaired = false;
Expand All @@ -388,8 +389,8 @@ class NukiBle : public BLEClientCallbacks, public BleScanner::Subscriber {
bool keypadCodeCountReceived = false;
uint16_t logEntryCount = 0;
bool loggingEnabled = false;
int rssi = 0;
unsigned long lastReceivedBeaconTs = 0;
std::atomic_int rssi;
std::atomic_ulong lastReceivedBeaconTs;
std::list<KeypadEntry> listOfKeyPadEntries;
std::list<AuthorizationEntry> listOfAuthorizationEntries;
AuthorizationIdType authorizationIdType = AuthorizationIdType::Bridge;
Expand Down

0 comments on commit 1c0ecf3

Please sign in to comment.