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:
Marcel Schulz 2017-12-15 14:06:14 +01:00
parent 9c7ad75225
commit 5f809c2aa0
3 changed files with 34 additions and 2 deletions

32
src/SBDevice.cpp Normal file
View 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
}

View File

@ -1,6 +1,8 @@
#ifndef _SB_NETWORK_DEVCIE_
#define _SB_NETWORK_DEVCIE_
#include "SBNetwork_config.h"
#include "SBTypes.h"
#include <EEPROM.h>
class SBNetworkDevice {

View File

@ -8,8 +8,6 @@
#include <RF24.h>
#include <nRF24L01.h>
#include "SBTypes.h"
#include "SBNetwork_config.h"
#include "SBDevice.h"
#define BROADCAST_MAC (SBMacAddress(0x9E, 0x0E, 0x9E, 0x0E, 0x9E))