Hello all,
I am trying to set the event handlers using functions within an object with everything acting within the object (see below). I have chopped out most of the code.
in the header file:
class ObjectName {
public:
void DiscoverBLE(BLEDevice peripheral);
void establishBLE();
void ReScan(BLEDevice peripheral);
};
in the cpp file:
void ObjectName::establishBLE() {
~~~
BLE.setEventHandler(BLEDiscovered, DiscoverBLE);
BLE.setEventHandler(BLEDisconnected, ReScan);
~~~
}
void ObjectName::DiscoverBLE(BLEDevice peripheral) {
~~~
}
void ObjectName::ReScan(BLEDevice peripheral) {
~~~
}
However, I get the errors:
"argument of type "void (ObjectName::*)(BLEDevice peripheral)" is incompatible with parameter of type "BLEDeviceEventHandler""
and
"invalid use of non-static member function 'void ObjectName::DiscoverBLE(BLEDevice)"
Now I know roughly what both of those means, notably how the second is referring to the fact that I need to use a defined object, something like:
ObjectName Object1;
~~~
BLE.setEventHandler(BLEDiscovered, Object1.DiscoverBLE);
But that gives different errors.
Am I doing something wrong here or does setEventHandler() not allow for this type of argument at all?
Thanks,
Matt