Did some changes in header include structure, because the library was not compiling successfully after extracting code to SBDevice.cpp.
This commit is contained in:
parent
9c7ad75225
commit
5f809c2aa0
32
src/SBDevice.cpp
Normal file
32
src/SBDevice.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "SBDevice.h"
|
||||||
|
|
||||||
|
SBMasterStorage SBMasterStorage::initialize() {
|
||||||
|
SBMasterStorage storage;
|
||||||
|
#if defined(ESP8266)
|
||||||
|
EEPROM.begin(SB_NETWORK_FLASH_SIZE);
|
||||||
|
#endif
|
||||||
|
EEPROM.get(0 + sizeof(SBNetworkDevice), storage);
|
||||||
|
if (storage.ID[0] != 'M' || storage.ID[1] != 'S') {
|
||||||
|
// We have to create a new one
|
||||||
|
storage.ID[0] = 'M';
|
||||||
|
storage.ID[1] = 'S';
|
||||||
|
Serial.println("Creating new Master Storage");
|
||||||
|
EEPROM.put(0 + sizeof(SBNetworkDevice), storage);
|
||||||
|
#if defined(ESP8266)
|
||||||
|
EEPROM.commit();
|
||||||
|
EEPROM.end();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBMasterStorage::save() {
|
||||||
|
#if defined(ESP8266)
|
||||||
|
EEPROM.begin(SB_NETWORK_FLASH_SIZE);
|
||||||
|
#endif
|
||||||
|
EEPROM.put(sizeof(SBNetworkDevice), *this);
|
||||||
|
#if defined(ESP8266)
|
||||||
|
EEPROM.commit();
|
||||||
|
EEPROM.end();
|
||||||
|
#endif
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _SB_NETWORK_DEVCIE_
|
#ifndef _SB_NETWORK_DEVCIE_
|
||||||
#define _SB_NETWORK_DEVCIE_
|
#define _SB_NETWORK_DEVCIE_
|
||||||
|
|
||||||
|
#include "SBNetwork_config.h"
|
||||||
|
#include "SBTypes.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|
||||||
class SBNetworkDevice {
|
class SBNetworkDevice {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
#include <RF24.h>
|
#include <RF24.h>
|
||||||
#include <nRF24L01.h>
|
#include <nRF24L01.h>
|
||||||
|
|
||||||
#include "SBTypes.h"
|
|
||||||
#include "SBNetwork_config.h"
|
|
||||||
#include "SBDevice.h"
|
#include "SBDevice.h"
|
||||||
|
|
||||||
#define BROADCAST_MAC (SBMacAddress(0x9E, 0x0E, 0x9E, 0x0E, 0x9E))
|
#define BROADCAST_MAC (SBMacAddress(0x9E, 0x0E, 0x9E, 0x0E, 0x9E))
|
||||||
|
Loading…
Reference in New Issue
Block a user