-
Untitled document
11/15/2014 at 13:55 • 0 commentsUntitled document =
==========================
/* sleep makes | minds weak */
==========================
todo:
#setup owncloud
#setup motion
Create home feature list
#shrink divs (doors,lights,power,etc…)
crearte moteino to rpi comunication
Usercake
Dual login Usercake and owncloud
Collapse Car home etc
Make divs fit on watch
make change password form in settings
#solder resistors between pin and FOB
add button press action
add button gifs
measure current input
connect local servers to web - ngInx load balancing
get OBD-pi python working
setup stats database to sync with owncloud (air, fuel, updates, temps, pressures, miles, etc...)
communicate server and moteino body sensors/actors (*motor sensors come from OBD-Pi)
vehical lane departure #1 cause of accidents
combine home and car servers
case 1:
user enters wifi zone around car -- car disarms
user can start car and access interior features
user leaves wifi zone around car -- car arms
case 2:
user taps NFC tag with NFC device (iphone, android, wearables)
tag command is executed (arm, disarm, start motor, etc...)
case 3:
user access car from any device with web browser
user can execute commands (arm, disarm, start motor, etc...)
user can view car history, change passwords, set access times, etc…
features:
#vehical lane departure #1 cause of accidents
sensor feedback
arm/disarm
horn
trunk
motor start
OBD-II
gps
camera
audio glass break
tow/hood tilt detect
battery disconnect alarm
rf transmitter
internet routing
home/business interface
#####################
#####################
#####################
#### ------ !!! gedanken !!! ------ #####
####-----HHHC(solid butane)CHHH------##
####-----if dipole < some_small_numbr------####
####-------- pressure * volume ~ constant * temperature-------####
####-------------- echo answer(constant == previous_constant) ---------------####
####------------------------if constant != 0 echo null!!!
####-----
#####################
#####################
#####################
/////////////////////////////////////////////////////////////////
///////////////////////////motion////////////////////////////////
/////////////////////////////////////////////////////////////////
apt-get -y update;apt-get install apache2 php5 mysql-server php5-mysql php5-json php5-gd php5-sqlite curl libcurl3 libcurl4-openssl-dev php5-curl php5-gd php5-cgi php-pear php5-dev build-essential libpcre3-dev php5 libapache2-mod-php5 php-apc motion libjpeg62 upstart libmysqlclient-dev;
pecl install apc;service apache2 restart;
#move owncloud
a2enmod rewrite;a2enmod headers;
sudo openssl genrsa -des3 -out server.key 1024; sudo openssl rsa -in server.key -out server.key.insecure;sudo openssl req -new -key server.key -out server.csr;sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt;sudo cp server.crt /etc/ssl/certs;sudo cp server.key /etc/ssl/private;sudo a2enmod ssl;sudo a2ensite default-ssl;service apache2 restart;
chown -R www-data:www-data /var/www/owncloud/;
#move: log into owncloud and make motion folder
#move: www
mysql -u root -p;
create database __fi;use __fi;
CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time text);
create table tokens(token text);insert into tokens values('--!!MATCHED!!--');
#mv .htaccess /var/www/owncloud/.htaccess;
#mv config.php /var/www/owncloud/config/config.php;chmod 777 /var/www/owncloud/config/config.php;
mv nph-mjprox /usr/lib/cgi-bin;chmod 777 /usr/lib/cgi-bin/nph-mjprox;
mv php.ini /etc/php5/apache2/php.ini;
mv 000-default /etc/apache2/sites-enabled/000-default;
mv motion /etc/motion/motion;chmod 777 /etc/motion/motion;
mv motion.conf /etc/motion/motion.conf;
mv motion.default /etc/default/motion;
mv apc.ini /etc/php5/cgi/conf.d/apc.ini
mv motioncontrol /etc/init.d/motioncontrol;chmod 777 /etc/init.d/motioncontrol;
update-rc.d motioncontrol defaults
#make owncloud motion folder
//////////////////////////////////////////////////////////////////////////
######nano /etc/default/motion;
#start_motion_daemon=yes
#nano /etc/php5/apache2/php.ini;
# upload_max_filesize to 1024M
# post_max_size to 1200M
# put extension=apc.so to Dynamic Extensions
#nano /etc/apache2/sites-enabled/000-default;
# AllowOverride All
##########
wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz;
tar zxvf motion-mmal.tar.gz;
chmod 777 motion
./motion-mmal -n -c motion-mmalcam.conf
libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev #libavutil51 #libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev php5-cgi libapache2-mod-fcgid;;
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
apt-get -y update; apt-get -y safe-upgrade; apt-get -y install rfkill zd1211-firmware hostapd hostap-utils iw dnsmasq apache2 mysql-server php5 php5-mysql php5-cgi libapache2-mod-fcgid;
nano /etc/network/interfaces;
auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0
ifdown wlan0; ifup wlan0;
nano /etc/hostapd/hostapd.conf;
interface=wlan0
driver=nl80211
ssid=test
channel=1
wpa=2
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=TKIP CCMP
service hostapd restart;
nano /etc/dnsmasq.conf;
# Never forward plain names (without a dot or domain part)
domain-needed
# Only listen for DHCP on wlan0
interface=wlan0
# Create a dhcp range on your /24 wlan0 network with 12 hour lease time
dhcp-range=192.168.1.5,192.168.1.254,255.255.255.0,12h
# Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave.
#dhcp-option=252,"\n"
service dnsmasq restart;
echo 1 > /proc/sys/net/ipv4/ip_forward;
iptables -t nat -A POSTROUTING -j MASQUERADE;
nano /etc/init.d/pipoint;
#!/bin/sh
# Configure Wifi Access Point.
#
### BEGIN INIT INFO
# Provides: WifiAP
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog $time
# Should-Start: $network $named slapd autofs ypbind nscd nslcd
# Should-Stop: $network $named slapd autofs ypbind nscd nslcd
# Default-Start: 2
# Default-Stop:
# Short-Description: Wifi Access Point configuration
# Description: Sets forwarding, starts hostap, enables NAT in iptables
### END INIT INFO
# turn on forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# enable NAT
iptables -t nat -A POSTROUTING -j MASQUERADE
# start the access point
hostapd -B /etc/hostapd/hostapd.conf
chmod +x /etc/init.d/pipoint;update-rc.d pipoint start 99 2;
============================
apt-get -y update; apt-get -y upgrade; apt-get -y install rfkill zd1211-firmware hostapd hostap-utils iw dnsmasq mysql-server libmysqlclient-dev apache2 upstart php5 php5-mysql python-dev;
--breaking stuff??---> libapache2-mod-python; reboot;
add www-data to /etc/sudoers
mysql -u root -p
create database __fi;use __fi;
create table actions(date date, time time, action text, pin int);
insert into actions values(current_date(),now(),'armed',3);
insert into actions values(current_date(),now(),'disarmed',5);
insert into actions values(current_date(),now(),'motor stopped',7);
insert into actions values(current_date(),now(),'horn on',8);
insert into actions values(current_date(),now(),'trunk closed',10);
insert into actions values(current_date(),now(),'trunk window closed',11);
=============================
plug in
see wi__@192.168.1.1
sudo cp /etc/network/interfaces.date /etc/network/interfaces
user option 1:
scan nfc
download app, pass serial to connect
user option 2:
my__#
select internet router
input password
send http://192.168.1.1?ssid=pwd to my__#
sudo ifdown wlan0
sudo ifup wlan0
sudo cp hostapd.date /etc/hostapd/hostapd.conf
sudo cp pipoint.date /etc/init.d/pipoint
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
sudo hostapd -B /etc/hostapd/hostapd.conf
sudo service dnsmasq restart
sudo updaterc.d pipoint start 99 2
from image:
sudo passwd root
su root
connect to router
copy over cgi folder
cp /cgi/default /etc/apache2/sites-available/default;
cp /cgi/interfaces /etc/network/interfaces;
cp /cgi/dnsmasq.conf /etc/dnsmasq.conf;
cp /cgi/hostapd.conf /etc/hostapd/hostapd.conf;
cp /cgi/ap_startup.conf /etc/init/ap_startup.conf;
cp /cgi/readdb /;
make; cp cgictest.cgi /usr/lib/cgi-bin;
mysql -u root
create database doordb;
use doordb;
CREATE TABLE event_history(Id INT,Date DATE,Time TIME,Device TEXT,State INT);
INSERT INTO event_history values(1,CURRENT_DATE(),NOW(),'door',1);
CREATE TABLE devices(ip text,deadbolt int,light int,gargage int);
INSERT INTO devices values("192.168.1.1",-1,127,127);
chmod 775 readdb
/etc/rc.local.../readdb &>/dev/null &
ifdown wlan0; ifup wlan0
sudo reboot
service dnsmasq restart
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
iptables -t nat -A POSTROUTING -j MASQUERADE
hostapd -B /etc/hostapd/hostapd.conf
addentry(cgiQueryString);
void addentry (char command[100])
{
fprintf(cgiOut, "<h1>COMMAND: %s</h1>\n",command)
}
sudo gcc getstate.c -l bcm2835 -o readdb -std=c99 `mysql_config --cflags --libs`
CFLAGS=-g -Wall -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g
CC=gcc
AR=ar
RANLIB=ranlib
LIBS=-L./ -lcgic -L/usr/lib/arm-linux-gnueabihf -lmysqlclient -lpthread -lz -lm -lrt -ldl
all: libcgic.a cgictest.cgi capture
install: libcgic.a
cp libcgic.a /usr/local/lib
cp cgic.h /usr/local/include
@echo libcgic.a is in /usr/local/lib. cgic.h is in /usr/local/include.
libcgic.a: cgic.o cgic.h
rm -f libcgic.a
$(AR) rc libcgic.a cgic.o
$(RANLIB) libcgic.a
#mingw32 and cygwin users: replace .cgi with .exe
cgictest.cgi: cgictest.o libcgic.a
gcc cgictest.o -o cgictest.cgi ${LIBS}
capture: capture.o libcgic.a
gcc capture.o -o capture ${LIBS}
clean:
rm -f *.o *.a cgictest.cgi capture
#include <my_global.h>
#include <mysql.h>
#include <string.h>
#include <stdio.h>
void finish_with_error(MYSQL *con)
{
fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
}
int main(int argc, char **argv)
{
MYSQL *con = mysql_init(NULL);
if (con == NULL)
{
fprintf(stderr, "%s\n", mysql_error(con));
exit(1);
}
if (mysql_real_connect(con, "localhost", "physiphile", "lamepasswd",
"doordb", 0, NULL, 0) == NULL)
{
finish_with_error(con);
}
if (mysql_query(con, "DROP TABLE IF EXISTS event_history")) {
finish_with_error(con);
}
if (mysql_query(con, "
select Id from event_history order by Id desc limit 1;
")) {
finish_with_error(con);
}
char door[100] = "physidoor";
printf(buffer);
printf("fifth character of name is %c\n", door[4]);
//printf("last character of name is %c\n", name[strlen(name) - 1]);
mysql_close(con);
exit(0);
}
sudo nano /etc/rc.local
#....
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/readdb &>/dev/null &
exit 0
<form action="http://192.168.1.108/cgi-bin/cgictest.cgi" method="get" target="_blank">
<input type="hidden" name="device" value="door">
<input type="hidden" name="state" value="close">
<input type="submit" value="Submit"></form>
fprintf(cgiOut, "<form method=\"GET\" enctype\"multipart/form-data\ action=\"http:\/\/192.168.1.108/\cgi-bin/\cgitest.cgi\">\n");
fprintf(cgiOut, "<input type=\"hidden\" name=\"device\" value=\"door\">\n");
fprintf(cgiOut, "<input type=\"hidden\" name=\"state\" value=\"open\">\n");
fprintf(cgiOut, "<input type=\"submit\" value=\"label\"></form>\n");
<form method=\"POST\" enctype\"multipart/form-data\ action=\"script">
<input type=\"submit\" name=\"saveenvirnoments\" value=\"label\"></form>
edit interfaces
static, address, netmask
edit hostapd.conf
interface=wlan0
driver=nl80211
ssid=wipy
channel=1
edit dnsmasq
domain-needed
interface=wlan0
dhcp-range=192.168.1.50,192.168.1.254,255.255.255.0,12h
=======================
<directory>AddHandler mod_python .py
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
from subprocess import call
call(["cp","/etc/network/interfaces.ORIG","/etc/network/interfaces"])
call(["sudo","reboot"])
========================install raspbian
sudo apt-get update;sudo apt-get install libapache2-mod-python libncurses5-dev gawk bison cvs flex
4 4 2014
gperf texinfo automake libtool apache2 motion php5 php5-mysql mysql-server python-mysqldb libmysqlclient-dev
create database
install usercrake with local database settings
delete www/* and replace with __fi
(ctrl+F5) create first user
create 'Member' permission
add member and remove new member from account.php permission
add member permission to logout
create table history (user TEXT, date DATE, time TIME);
<div id='video_java'>
<applet code='com.charliemouse.cambozola.Viewer' archive='cambozola.jar' style='height:400px;width:100%'>
<param name='url' value='/cgi-bin/nph-mjprox?".$ranstr."'>
</applet>
</div>
crosstool-ng
ffmpeg
gcc -Wall -std=c99 -O3 -o nph-mjprox nph-mjprox.c -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -L./ -L/usr/lib/arm-linux-gnueabihf -lmysqlclient -lpthread -lz -lm -lrt -ldl; rm /usr/lib/cgi-bin/nph-mjprox; cp nph-mjprox /usr/lib/cgi-bin/nph-mjprox
sudo apt-get update;sudo apt-get install libncurses5-dev gawk bison cvs flex gperf texinfo automake libtool apache2 motion php5 php5-mysql mysql-server python-mysqldb libmysqlclient-dev
sudo aptitude install rfkill zd1211firmware hostapd hostaputils iw dnsmasq
plug in
see wi__@192.168.1.1
sudo cp /etc/network/interfaces.date /etc/network/interfaces
user option 1:
scan nfc
download app, pass serial to connect
user option 2:
my__#
select internet router
input password
send http://192.168.1.1?ssid=pwd to my__#
sudo ifdown wlan0
sudo ifup wlan0
sudo cp hostapd.date /etc/hostapd/hostapd.conf
sudo cp pipoint.date /etc/init.d/pipoint
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
sudo hostapd -B /etc/hostapd/hostapd.conf
sudo service dnsmasq restart
sudo updaterc.d pipoint start 99 2
from image:
sudo passwd root
su root
connect to router
apt-get update; apt-get upgrade; apt-get install rfkill zd1211-firmware hostapd hostap-utils iw dnsmasq mysql-server libmysqlclient-dev apache2 upstart php5 php5-mysql;
copy over cgi folder
cp /cgi/default /etc/apache2/sites-available/default;
cp /cgi/interfaces /etc/network/interfaces;
cp /cgi/dnsmasq.conf /etc/dnsmasq.conf;
cp /cgi/hostapd.conf /etc/hostapd/hostapd.conf;
cp /cgi/ap_startup.conf /etc/init/ap_startup.conf;
cp /cgi/readdb /;
make; cp cgictest.cgi /usr/lib/cgi-bin;
mysql -u root
create database doordb; use doordb;
CREATE TABLE devices(ip text,deadbolt int,light int,garage int);
INSERT INTO devices values("127.0.0.1",-1,127,-1);
CREATE TABLE event_history(Id INT,Date DATE,Time TIME,Device TEXT,State INT);
INSERT INTO event_history values(1,CURRENT_DATE(),NOW(),'door',1);
chmod 775 readdb
/etc/rc.local.../cgi/readdb &>/dev/null &
ifdown wlan0; ifup wlan0
sudo reboot
service dnsmasq restart
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
iptables -t nat -A POSTROUTING -j MASQUERADE
hostapd -B /etc/hostapd/hostapd.conf
addentry(cgiQueryString);
void addentry (char command[100])
{
fprintf(cgiOut, "<h1>COMMAND: %s</h1>\n",command)
}
sudo gcc getstate.c -l bcm2835 -o readdb -std=c99 `mysql_config --cflags --libs`
CFLAGS=-g -Wall -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g
CC=gcc
AR=ar
RANLIB=ranlib
LIBS=-L./ -lcgic -L/usr/lib/arm-linux-gnueabihf -lmysqlclient -lpthread -lz -lm -lrt -ldl
all: libcgic.a cgictest.cgi capture
install: libcgic.a
cp libcgic.a /usr/local/lib
cp cgic.h /usr/local/include
@echo libcgic.a is in /usr/local/lib. cgic.h is in /usr/local/include.
libcgic.a: cgic.o cgic.h
rm -f libcgic.a
$(AR) rc libcgic.a cgic.o
$(RANLIB) libcgic.a
#mingw32 and cygwin users: replace .cgi with .exe
cgictest.cgi: cgictest.o libcgic.a
gcc cgictest.o -o cgictest.cgi ${LIBS}
capture: capture.o libcgic.a
gcc capture.o -o capture ${LIBS}
clean:
rm -f *.o *.a cgictest.cgi capture
#include <my_global.h>
#include <mysql.h>
#include <string.h>
#include <stdio.h>
void finish_with_error(MYSQL *con)
{
fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
}
int main(int argc, char **argv)
{
MYSQL *con = mysql_init(NULL);
if (con == NULL)
{
fprintf(stderr, "%s\n", mysql_error(con));
exit(1);
}
if (mysql_real_connect(con, "localhost", "physiphile", "lamepasswd",
"doordb", 0, NULL, 0) == NULL)
{
finish_with_error(con);
}
if (mysql_query(con, "DROP TABLE IF EXISTS event_history")) {
finish_with_error(con);
}
if (mysql_query(con, "
select Id from event_history order by Id desc limit 1;
")) {
finish_with_error(con);
}
char door[100] = "physidoor";
printf(buffer);
printf("fifth character of name is %c\n", door[4]);
//printf("last character of name is %c\n", name[strlen(name) - 1]);
mysql_close(con);
exit(0);
}
sudo nano /etc/rc.local
#....
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/readdb &>/dev/null &
exit 0
<form action="http://192.168.1.108/cgi-bin/cgictest.cgi" method="get" target="_blank">
<input type="hidden" name="device" value="door">
<input type="hidden" name="state" value="close">
<input type="submit" value="Submit"></form>
fprintf(cgiOut, "<form method=\"GET\" enctype\"multipart/form-data\ action=\"http:\/\/192.168.1.108/\cgi-bin/\cgitest.cgi\">\n");
fprintf(cgiOut, "<input type=\"hidden\" name=\"device\" value=\"door\">\n");
fprintf(cgiOut, "<input type=\"hidden\" name=\"state\" value=\"open\">\n");
fprintf(cgiOut, "<input type=\"submit\" value=\"label\"></form>\n");
<form method=\"POST\" enctype\"multipart/form-data\ action=\"script">
<input type=\"submit\" name=\"saveenvirnoments\" value=\"label\"></form>
edit interfaces
static, address, netmask
edit hostapd.conf
interface=wlan0
driver=nl80211
ssid=wipy
channel=1
edit dnsmasq
domain-needed
interface=wlan0
dhcp-range=192.168.1.50,192.168.1.254,255.255.255.0,12h
<?php
$conn = mysql_connect('localhost','root','lamepasswd');
$db = mysql_select_db('doordb');
$publicip="192.168.1.148";
$requestedip=mysql_real_escape_string(trim($_POST['name']));
/////////////////////////////////////////////
/////someone is asking for local devices/////
/////////////////////////////////////////////
$devices = array();
$query=mysql_query("select * from devices");
while ($row = mysql_fetch_assoc($query)) {
$devices = array(
"ip"=>$row['ip'],
"garage"=>$row['garage'],
"deadbolt"=>$row['deadbolt'],
"light"=>$row['light']);
echo json_encode(array("Devices " => $devices));
//echo json_encode(array("Devices " => $devices));
}
/////////////////////////////////////////////
/*
if ($requestedip==""){
$devices = array();
$query=mysql_query("select * from devices");
$deadbolt = mysql_result($query, 0, 'deadbolt');
$light = mysql_result($query, 0, 'light');
$garage = mysql_result($query, 0, 'garage');
$devices = array('deadbolt'=>$deadbolt,'light'=>$light,'garage'=>$garage);
echo json_encode(array("Devices " => $devices));
}
*/
?>
////////////////////////////////////////////////////////////////////////
apt-get install apache2 php5 php5-json php5-gd php5-sqlite curl libcurl3 libcurl4-openssl-dev php5-curl php5-gd php5-cgi php-pear php5-dev build-essential libpcre3-dev php5 libapache2-mod-php5 php-apc gparted;