/trunk/Server/motion/config |
---|
0,0 → 1,0 |
link /etc/motion/motion.conf |
Property changes: |
Added: svn:special |
+* |
\ No newline at end of property |
/trunk/Server/motion/config_settings |
---|
0,0 → 1,7 |
You need to change following in /etc/motion/motion.conf : |
on_picture_save /daten/alarming/motion/motion_cb_picshot %f |
on_motion_detected /daten/alarming/motion/motion_cb_detect |
stream_localhost off |
stream_port 8081 |
/trunk/Server/motion/detect.d/client_alert |
---|
0,0 → 1,48 |
#!/usr/bin/php |
<?php |
# --- PLEASE MODIFY: |
# To which daemon server should the alarm be sent? |
$url = "http://127.0.0.1:8085"; |
# Which targets should be reported? |
$targets = array( |
"1.3.6.1.4.1.37476.2.4.2.0", // Any |
"1.3.6.1.4.1.37476.2.4.2.1002", // Motion, camera |
"1.3.6.1.4.1.37476.1.2.1.1" // PRIVATE: Webcam of Daniel Marschall |
); |
# --- DON'T MODIFY AFTER THIS LINE |
$fields = array(); |
$fields[] = "action=server_alert"; // 1.3.6.1.4.1.37476.2.4.1.2 |
foreach ($targets as $target) { |
// Note: We are not using http_build_query(), because it sends targets[0]=...&targets[1]=..., |
// which is not what we need. We want targets=...&targets=... |
$fields[] = "targets=".urlencode($target); |
} |
$fields_string = implode('&', $fields); |
echo urldecode($fields_string)."\n"; |
$ch = curl_init(); |
curl_setopt($ch, CURLOPT_URL, $url); |
curl_setopt($ch, CURLOPT_POST, true); |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
$result = curl_exec($ch); |
echo $result; |
// Note: We are not using Python to send the alert, because the "import" command is extremely |
// slow, and we need to send an alarm withhin milliseconds! |
/* |
import requests |
d = {"action": "server_alert", "targets": [ |
"...", |
"..." |
]} |
requests.post("http://127.0.0.1:8085", data=d) |
*/ |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/Server/motion/detect.d |
---|
Property changes: |
Added: svn:ignore |
+stop_spotify |
/trunk/Server/motion/motion_cb_detect |
---|
0,0 → 1,16 |
#!/bin/bash |
DIR=$( dirname "$0" ) |
# Only report every 30 seconds |
DETFIL="/tmp/last_motion_detect.ts" |
if [ -f "$DETFIL" ]; then |
if test "`find "$DETFIL" -mmin -0,5`"; then |
# Neuer als 30 Sekunden. Nix machen |
exit |
fi |
fi |
touch "$DETFIL" |
# Execute detect.d/* |
for i in "$DIR"/detect.d/*; do ( "$i" &) ; done |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/Server/motion/motion_cb_picshot |
---|
0,0 → 1,3 |
#!/bin/bash |
rm "$1" |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/Server/motion/motion_start_safe |
---|
0,0 → 1,15 |
#!/usr/bin/php |
<?php |
// Der folgende Code resetted das USB-Gerät, da sonst bei einem Neustart von Motion der Fehler "Cannot open video device" kommen kann |
// https://gist.github.com/x2q/5124616 |
// https://www.raspberrypi.org/forums/viewtopic.php?t=86265https://www.raspberrypi.org/forums/viewtopic.php?t=86265 |
$out = array(); |
exec("lsusb", $out, $ec); |
$cont = implode("\n", $out); |
if (preg_match("@Bus (.{3}) Device (.{3}): ID (.{4}):(.{4}) Logitech, Inc. Webcam C270@ismU", $cont, $m)) { |
system(escapeshellcmd(__DIR__.'/usbreset').' '.escapeshellarg("/dev/bus/usb/".$m[1]."/".$m[2])); |
} |
system("service motion start"); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/Server/motion/motion_stop_safe |
---|
0,0 → 1,5 |
#!/usr/bin/php |
<?php |
system("service motion stop"); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/Server/motion/usbreset |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/Server/motion/usbreset.c |
---|
0,0 → 1,52 |
// https://gist.github.com/x2q/5124616 |
// https://www.raspberrypi.org/forums/viewtopic.php?t=86265https://www.raspberrypi.org/forums/viewtopic.php?t=86265 |
/* usbreset -- send a USB port reset to a USB device |
* |
* Compile using: gcc -o usbreset usbreset.c |
* |
* |
* */ |
#include <stdio.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <errno.h> |
#include <sys/ioctl.h> |
#include <linux/usbdevice_fs.h> |
int main(int argc, char **argv) |
{ |
const char *filename; |
int fd; |
int rc; |
if (argc != 2) { |
fprintf(stderr, "Usage: usbreset device-filename\n"); |
return 1; |
} |
filename = argv[1]; |
fd = open(filename, O_WRONLY); |
if (fd < 0) { |
perror("Error opening output file"); |
return 1; |
} |
printf("Resetting USB device %s\n", filename); |
rc = ioctl(fd, USBDEVFS_RESET, 0); |
if (rc < 0) { |
perror("Error in ioctl"); |
return 1; |
} |
printf("Reset successful\n"); |
close(fd); |
return 0; |
} |