update ble lib

This commit is contained in:
technyon
2022-04-02 13:59:10 +02:00
parent 4bc07356a0
commit 8b1c5ddf5e
9 changed files with 57 additions and 55 deletions

46
NukiWrapper.h Normal file
View File

@@ -0,0 +1,46 @@
#pragma once
#include "NukiBle.h"
#include "Network.h"
#include "NukiConstants.h"
#include "NukiDataTypes.h"
class NukiWrapper : public Nuki::SmartlockEventHandler
{
public:
NukiWrapper(const std::string& name, uint32_t id, Network* network, Preferences* preferences);
void initialize();
void update();
const bool isPaired();
void notify(Nuki::EventType eventType) override;
private:
static void onLockActionReceived(const char* value);
void updateKeyTurnerState();
void updateBatteryState();
Nuki::LockAction lockActionToEnum(const char* str); // char array at least 14 characters
Nuki::NukiBle _nukiBle;
BleScanner _bleScanner;
Network* _network;
Preferences* _preferences;
int _intervalLockstate = 0; // seconds
int _intervalBattery = 0; // seconds
Nuki::KeyTurnerState _lastKeyTurnerState;
Nuki::KeyTurnerState _keyTurnerState;
Nuki::BatteryReport _batteryReport;
Nuki::BatteryReport _lastBatteryReport;
bool _paired = false;
bool _statusUpdated = false;
unsigned long _nextLockStateUpdateTs = 0;
unsigned long _nextBatteryReportTs = 0;
Nuki::LockAction _nextLockAction = (Nuki::LockAction)0xff;
};