Hello, for the purpose of my study I need to have the AudioMoths start at a specific date a couple of days after I place them. I understand that this will be implemented in a future update, but unfortunately I do not have the time to wait for that one. I'm therefore trying to hardcode the starting date into the firmware. I'm currently trying to make it so that when the default switch is triggered it will wait for the set date and then start recording. However, it just starts recording normally. I suspect it has something to do with the configured start date of the recorder (1970) but I'm not sure. If someone would point out where my code is going wrong I would greatly appreciate it!
PS: when I try to flash the firmware it always crashes once, then I have to restart it in boot mode, after which it does work. Is there a fix for this?
Here is my piece of code:
if (switchPosition != *previousSwitchPosition) {
if (switchPosition == AM_SWITCH_DEFAULT) {
time_t current_time;
struct tm * timeinfo;
/* These are the values of my planned recording time */
int target_year = 2019, target_month = 12, target_day = 12;
int target_hour = 14, target_minute = 50, target_second = 0;
/* Get the current time */
time ( ¤t_time );
timeinfo = localtime(¤t_time);
timeinfo->tm_year = target_year;
timeinfo->tm_mon = target_month;
timeinfo->tm_mday = target_day;
timeinfo->tm_hour = target_hour;
timeinfo->tm_min = target_minute;
timeinfo->tm_sec = target_second;
/*This converts it to something that difftime can work with */
time_t scheduled_time = mktime ( timeinfo );
*timeOfNextRecording = current_time + difftime(scheduled_time, current_time );
*durationOfNextRecording = 60;
} else {
/* Determine starting time and duration of next recording */
scheduleRecording(currentTime, timeOfNextRecording, durationOfNextRecording);
}
}
Kind regards,
Yannick
top of page
To test this feature, visit your live site.
Hardcode starting date
Hardcode starting date
17 comments
Like
17 Comments
bottom of page
Great. Thanks for letting us know.