Skip to content

Commit

Permalink
Current implementation missed motion events on GK-200MP2-B
Browse files Browse the repository at this point in the history
On my camera IN_MODIFY would do the trick. I also added IN_ATTRIB to be able to trigger a motion event with "touch".
  • Loading branch information
flreinhard committed Dec 19, 2023
1 parent 4b85364 commit c43ef3f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/mqtt/mqtt-sonoff/src/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ static void handle_events(int fd)

event = (const struct inotify_event *) ptr;

/* Print event type. */

if (event->mask & IN_CREATE) {
/* Handle "File created", "Metadata change, e.g. Timestamp" and "File modified" evets */
if (event->mask & (IN_CREATE|IN_MODIFY|IN_ATTRIB)) {
/* Don't handle directories */
if ((event->mask & IN_ISDIR) != IN_ISDIR) {
/* Print the name of the file. */
/* Filename (event->name) length is gt 0 */
if (event->len) {
if (debug) fprintf(stderr, "IN_CREATE: %s\n", event->name);
if (strcmp(NOTI_FILE, event->name) == 0)
/* Is it the file to watch? */
if (strcmp(NOTI_FILE, event->name) == 0) {
if (debug) fprintf(stderr, "inotify: evt %08x on %s\n", event->mask, event->name);
handle_inotify_motion_start();
}
}
Expand All @@ -117,7 +118,7 @@ static void *inotify_thread(void *arg)
}

/* Add watch to the directory. */
wd = inotify_add_watch(fd, TMP_DIR, IN_CREATE);
wd = inotify_add_watch(fd, TMP_DIR, IN_CREATE|IN_MODIFY|IN_ATTRIB);
if (wd == -1) {
fprintf(stderr, "Cannot watch '%s': %s\n", TMP_DIR, strerror(errno));
return NULL;
Expand Down

0 comments on commit c43ef3f

Please sign in to comment.