I am trying to hide libraries behind another, for simplicity. But I can't deal with the objects required by the libraries. Basically I want to use the objects both in my .cpp and .ino file, but I am getting errors about double definition, or not declared in this scope.
test.ino
#include "lib.h"
#include "obj.cpp"
void setup() {
mesh.setNodeID(40);
mesh.begin();
}
void loop() {
mesh.update();
}
lib.cpp
#include "Arduino.h"
#include "lib.h"
#include "obj.cpp"
int message = 1;
void send() {
if (!mesh.write(&message, 'C', sizeof(message))) {
// If a write fails, check connectivity to the mesh network
if ( ! mesh.checkConnection() ) {
//refresh the network address
Serial.println("Renewing Address");
mesh.renewAddress();
} else {
Serial.println("Sending failed, Test OK");
}
} else {
Serial.print("Sent OK");
}
}
lib.h
#ifndef lib_h
#define lib_h
void send();
#endif
obj.cpp
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>
#include <EEPROM.h>
RF24 radio(7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio, network);