Here it is. Sorry and thank you.
INO:
#include "Arduino.h"
#include <EDB.h>
#include "Runner.h"
#include "DBabstraction.h"
// Define structures and classes
// Define variables and constants
#define UsbSerial Serial // rename Serial ports
// Variables
Runner myRunner;
// Add setup code
void setup()
{
UsbSerial.begin(115200);
UsbSerial.print("[SETUP] [Start]\n");
}
// Add loop code
void loop()
{
myRunner.run();
delay(1000);
}
DBabstraction.h
#ifndef DBabstraction_h
#define DBabstraction_h
#include "Arduino.h"
#include <EDB.h>
//Use SPIFFS FS as data storage
#include "LStorage.h"
#include "LFlash.h"
#define Drv LFlash // use Internal 10M Flash
#define TABLE_SIZE 8192
// The number of demo records that should be created. This should be less
// than (TABLE_SIZE - sizeof(EDB_Header)) / sizeof(LogEvent). If it is higher,
// operations will return EDB_OUT_OF_RANGE for all records outside the usable range.
#define RECORDS_TO_CREATE 10
// Arbitrary record definition for this table.
// This should be modified to reflect your record needs.
struct Data_Struct {
int id;
int temperature;
}
data_struct;
//
class DBabstraction {
public:
DBabstraction();
EDB *myDB = new EDB(DBabstraction::dbWriter, DBabstraction::dbReader); //
void begin();
static LFile myFile;
static void dbWriter( unsigned long address, byte data );
static byte dbReader( unsigned long address );
private:
static DBabstraction * pInstance;
};
#endif // DBabstraction_h
DBabstraction.cpp:
// Library header
#include "DBabstraction.h"
//constructor
DBabstraction::DBabstraction(){
pInstance = this;
}
//public functions
void DBabstraction::dbWriter(unsigned long address, byte data ){
/* nothing */
}
byte DBabstraction::dbReader( unsigned long address){
/* nothing */
}
//public functions
void DBabstraction::begin(){
/* nothing */
}
// Code DBabstraction.cpp
Runner.h:
#ifndef Runner_h
#define Runner_h
#include "Arduino.h"
#include "DBabstraction.h"
class Runner {
public:
Runner();
void run();
//DBabstraction myAbstraction = new DBabstraction(); // ???
static DBabstraction *globalDB;
void globalConfigWriter( unsigned long address, byte data ) {
globalDB->dbWriter(address, data);
}
byte globalConfigReader( unsigned long address ) {
return globalDB->dbReader(address);
}
private:
};
#endif // Runner_h
Runner.cpp:
// Library header
#include "Runner.h"
// Code
/**************************************************/
// public functions
Runner::Runner(){
globalDB = new DBabstraction();
if(globalDB)
globalDB->begin();
}
void Runner::run(){
Serial.printf("ok\n");
}
Compilation:
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o: In function `DBabstraction::begin()':
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp:11: multiple definition of `data_struct'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o:/Users/Thibault/Desktop/CPPtest/CPPTEST.ino:24: first defined here
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o: In function `Runner::run()':
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp:8: multiple definition of `data_struct'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/CPPTEST.ino.cpp.o:/Users/Thibault/Desktop/CPPtest/CPPTEST.ino:24: first defined here
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/DBabstraction.cpp.o: In function `DBabstraction::DBabstraction()':
DBabstraction.cpp:(.text._ZN13DBabstractionC2Ev+0x38): warning: undefined reference to `DBabstraction::pInstance'
/var/folders/y8/2cf22w216j7cxt1k7g54v1y80000gp/T/arduino_build_563584/sketch/Runner.cpp.o: In function `Runner::Runner()':
Runner.cpp:(.text._ZN6RunnerC2Ev+0x30): warning: undefined reference to `Runner::globalDB'
collect2: error: ld returned 1 exit status
Using library EDB at version 1.0.4 in folder: /Users/Thibault/Documents/Arduino/libraries/EDB
Using library LStorage in folder: /Users/Thibault/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.23/libraries/LStorage (legacy)
exit status 1
Error compiling for board LinkIt ONE.