Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current implementation missed motion events on GK-200MP2-B #159

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/mqtt/mqtt-sonoff/src/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ 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 +119,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