Am coming to Arduino from Swift and Python and am struggling with a very basic question on how to arrange classes / libraries.
Am trying to create a BIOTDevice class that contains a pointer to a BIOTThing object.
Here is BIOTDevice.h
#ifndef BIOTDevice_h
#define BIOTDevice_h
#include "Arduino.h"
#include "BIOTThing.h"
class BIOTDevice {
public:
BIOTDevice();
void setThing(BIOTThing *thing);
BIOTThing *_thing;
};
#endif
Here is BIOTDevice.cpp
#include "Arduino.h"
#include "BIOTDevice.h"
#include "BIOTThing.h"
BIOTDevice::BIOTDevice() {
Serial.println("BIOT Device init");
}
void BIOTDevice::setThing(BIOTThing *thing){
Serial.println("Setting thing in device");
_thing = thing;
_thing->sayHello();
}
Here is BIOTThing.h
#ifndef BIOTThing_h
#define BIOTThing_h
#include "Arduino.h"
#include "BIOTDevice.h"
class BIOTThing{
public:
BIOTThing();
void sayHello();
};
#endif
Here is BIOTTHing.cpp
#include "Arduino.h"
#include "BIOTThing.h"
#include "BIOTDevice.h"
BIOTThing::BIOTThing() {
Serial.println("BIOT Thing init");
}
void BIOTThing::sayHello() {
Serial.println("BIOT Thing says hello");
}
Here is the main ino file
#include "BIOTDevice.h"
#include "BIOTThing.h"
void setup() {
Serial.begin(115200);
Serial.println("\nMain Program start");
BIOTDevice device = BIOTDevice();
BIOTThing thing = BIOTThing();
device.setThing(&thing);
}
void loop() {}
Im on a Mac. The .h and .cpp files are all stored in the same folder as the main.ino file
The error message is
In file included from sketch/BIOTThing.h:5:0,
from sketch/BIOTThing.cpp:2:
BIOTDevice.h:10: error: 'BIOTThing' has not been declared
void setThing(BIOTThing *thing);
^
BIOTDevice.h:11: error: 'BIOTThing' does not name a type
BIOTThing *_thing;
^
exit status 1
'BIOTThing' has not been declared
I think this has to do with file locations but having spent an hour, cannot figure out where else to put it (tried libraries sub folder under a BIOT folder as well).
Thank you for any help!