I am trying a version of the security Pi camera project.
#define TIMER1PERIOD (5*60*1000) //5 minutes
class CallbackClass
{
public:
void onTimeout();
}
CallbackClass callback;
Timer timer1(TIMER1PERIOD, &CallbackClass::onTimeout, callback);
bool timer1ended = false;
void setup()
{
timer1ended = false;
timer1.start(); //start the auto trigger 5 minute timer
}
void loop()
{
if (timer1ended) //5 minute timer ended
{
timer1ended = false;
char *const cmd[] = {"",NULL};
execv("/home/pi/bin/pi_camera_script",cmd); // image capture and upload shell script
}
}
// handler for timer1 ended
void onTimeout()
{
timer1ended = true;
}
The purpose of this small sketch is to run the pi_camera_script every 5 minutes. Problem is I do not understand/cannot resolve build errors related to the Timer - see below. Can anyone help?
Processing /workspace/picamera.ino
make -C ../newlib_nano
make[1]: Entering directory '/firmware/newlib_nano'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/firmware/newlib_nano'
make -C ../user
make[1]: Entering directory '/firmware/user'
Building cpp file: /workspace/picamera.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-31/workspace/
arm-unknown-linux-gnueabi-gcc -DPLATFORM_THREADING=0 -DPLATFORM_ID=31 -DPLATFORM_NAME=raspberrypi -DUSBD_VID_SPARK=0x1D50 -DUSBD_PID_DFU=0x607F -DUSBD_PID_CDC=0x607D -DEMBEDDED_TARGET=0 -g3 -O3 -gdwarf-2 -Wno-unused-local-typedefs -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=31 -DPRODUCT_FIRMWARE_VERSION=65535 -DSYSTEM_VERSION_STRING=0.6.0-rc.1 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../services/inc -I../communication/src -I../hal/inc -I../hal/shared -I/workspace/ -I./libraries -I. -MD -MP -MF ../build/target/user/platform-31/workspace/picamera.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLATFORM_NET=gcc -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -DLOG_INCLUDE_SOURCE_INFO -DMODULE_VERSION=0 -DMODULE_FUNCTION=3 -DMODULE_DEPENDENCY=0,0,0 -D_GNU_SOURCE -D_WINSOCK_H -DLOG_MODULE_CATEGORY="\"app\"" -fno-rtti -fcheck-new -std=gnu++11 -c -o ../build/target/user/platform-31/workspace/picamera.o /workspace/picamera.cpp
/workspace/picamera.cpp:21:15: error: expected initializer before 'callback'
{
^
/workspace/picamera.cpp:23:1: error: 'Timer' does not name a type
void onTimeout();
^
/workspace/picamera.cpp: In function 'void setup()':
/workspace/picamera.cpp:31:5: error: 'timer1' was not declared in this scope
^