I’m looking to try to build a library, but when I compile it, it doesn’t know what “String” is. The code works fine if I move it to my base ino file, but the error is happening on the cpp and h files. what am I doning wrong?
More info please - we can’t help based on this little.
What lib, what code?
my own lib.
here is the .h
#ifndef __INC_EchoPhotonBridge_H
#define __INC_EchoPhotonBridge_H
#define MAX_ECHO_DEVICES 20
//ECHOPHOTONBRIDGE_NAMESPACE_BEGIN
int (*fOnOff[MAX_ECHO_DEVICES]) (int, String);
int (*fPercent[MAX_ECHO_DEVICES]) (int, String);
int (*fColor[MAX_ECHO_DEVICES]) (int, String);
int (*fLock[MAX_ECHO_DEVICES]) (int, String);
int (*fTemp[MAX_ECHO_DEVICES]) (int, String);
String devices = "";
void addEchoDevice(String deviceName,
int (*functionOnOff) (int,String),
int (*functionPercent) (int,String),
int (*functionColor) (int,String),
int (*functionLock) (int,String),
int (*functionTemp) (int,String));
int callEchoFunction(int device, int function, String value);
//ECHOPHOTONBRIDGE_NAMESPACE_END
#endif
and the .cpp
void addEchoDevice(String deviceName,
int (*functionOnOff) (int,String),
int (*functionPercent) (int,String),
int (*functionColor) (int,String),
int (*functionLock) (int,String),
int (*functionTemp) (int,String))
{
int deviceType = 0;
if (functionOnOff != NULL) deviceType += 1;
if (functionPercent != NULL) deviceType += 2;
if (functionColor != NULL) deviceType += 4;
if (functionLock != NULL) deviceType += 8;
if (functionTemp != NULL) deviceType += 16;
if (devices.length > 0) devices += "|";
devices += deviceName;
devices += deviceType.ToString();
}
int callEchoFunction(int device, int function, String value)
{
}
and the .cpp
void addEchoDevice(String deviceName,
int (*functionOnOff) (int,String),
int (*functionPercent) (int,String),
int (*functionColor) (int,String),
int (*functionLock) (int,String),
int (*functionTemp) (int,String))
{
int deviceType = 0;
if (functionOnOff != NULL) deviceType += 1;
if (functionPercent != NULL) deviceType += 2;
if (functionColor != NULL) deviceType += 4;
if (functionLock != NULL) deviceType += 8;
if (functionTemp != NULL) deviceType += 16;
if (devices.length > 0) devices += "|";
devices += deviceName;
devices += deviceType.ToString();
}
int callEchoFunction(int device, int function, String value)
{
}
try adding this to the header and cpp
#include "Particle.h"
3 Likes