inject network into nuki instance

This commit is contained in:
technyon
2022-03-25 20:08:24 +01:00
parent 2b668f08fa
commit fb5dcfaac6
3 changed files with 16 additions and 10 deletions

View File

@@ -1,8 +1,9 @@
#include "Nuki.h"
#include <FreeRTOS.h>
Nuki::Nuki(const std::string& name, uint32_t id)
: _nukiBle(name, id)
Nuki::Nuki(const std::string& name, uint32_t id, Network* network)
: _nukiBle(name, id),
_network(network)
{
}

6
Nuki.h
View File

@@ -2,19 +2,21 @@
#include "NukiBle.h"
#include "NukiConstants.h"
#include "Network.h"
class Nuki
{
public:
Nuki(const std::string& name, uint32_t id);
Nuki(const std::string& name, uint32_t id, Network* network);
void initialize();
void update();
private:
NukiBle _nukiBle;
bool _paired = false;
Network* _network;
KeyTurnerState _keyTurnerState;
bool _paired = false;
};

View File

@@ -6,14 +6,14 @@
#define ESP32
Network network;
Nuki nuki("Main Door", 2020001);
Network* network;
Nuki* nuki;
void networkTask(void *pvParameters)
{
while(true)
{
network.update();
network->update();
}
}
@@ -21,7 +21,7 @@ void nukiTask(void *pvParameters)
{
while(true)
{
nuki.update();
nuki->update();
}
}
@@ -33,8 +33,11 @@ void setupTasks()
void setup()
{
network.initialize();
nuki.initialize();
network = new Network();
nuki = new Nuki("Main Door", 2020001, network);
network->initialize();
nuki->initialize();
setupTasks();
}