FutureSharks / rpi-security

A security system written in python to run on a Raspberry Pi with motion detection and mobile notifications
GNU General Public License v2.0
215 stars 71 forks source link

Configuration error #30

Closed kpiyushkumar closed 6 years ago

kpiyushkumar commented 6 years ago

After running the debug program, I get

Configuration error: Exception('Monitor mode is not enabled for interface mon0 or interface does not exist',)

To setup the wifi adapter, I referred to this link after which I ran the following command: iw phy phy0 interface add mon0 type monitor

My current network arrangement is

iw dev

phy#0 Interface mon0 ifindex 6 wdev 0x3 addr 20:e8:16:00:e2:d5 type monitor txpower 20.00 dBm Interface wlan1 ifindex 4 wdev 0x1 addr 20:e8:16:00:e2:d5 type managed txpower 20.00 dBm

phy#1 Unnamed/non-netdev interface wdev 0x100000002 addr ba:27:eb:3f:78:b9 type P2P-device txpower 31.00 dBm Interface wlan0 ifindex 3 wdev 0x100000001 addr b8:27:eb:3f:78:b9 ssid Wifi type managed channel 6 (2437 MHz), width: 20 MHz, center1: 2437 MHz txpower 31.00 dBm

The wifi adapter I'm using is mt7601u which has monitor mode according to this.

FutureSharks commented 6 years ago

Hi kpiyushkumar, Can you cat these two files from your system please?

/sys/class/net/mon0/type
/sys/class/net/mon0/operstate

Also do you have mon0 in /etc/rpi-security.conf?

kpiyushkumar commented 6 years ago

cat /sys/class/net/mon0/type gives me "803"

cat /sys/class/net/mon0/operstate gives me "down"

Yes I do have mon0 in /etc/rpi-security.conf

FYI I'm using Raspberry Pi 3B which has built in WiFi.

FutureSharks commented 6 years ago

The interface is down, that's the problem. Can you run ifconfig mon0 up?

kpiyushkumar commented 6 years ago

Apologies for the late reply. After running the above command, the operstate turned to "unknown". When I ran the program in debug mode, I got the following error message

2018-03-05 23:12:24 CRITICAL exit_clean.py:22 MainThread Configuration error: KeyError(2,)

1997mohan commented 6 years ago

I'm too getting the same error as kpiyushkumar got pls help

FutureSharks commented 6 years ago

@1997mohan can you also cat these two files from your system please?

/sys/class/net/mon0/type
/sys/class/net/mon0/operstate

Also, what model of wifi adapter are you using?

1997mohan commented 6 years ago

First command executes unknown Second command executes 803

1997mohan commented 6 years ago

RT 5370 WiFi adapter

1997mohan commented 6 years ago

I am using raspberry pi 3 model B which has inbuilt WiFi module but it doesn't support monitor mode so I bought RT 5370 WiFi adapter and I followed this link https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis and I made ifconfig mon0 up and as u said I cat those commands which results in type as 803 and operstate as unknown

FutureSharks commented 6 years ago

OK cool.

803 and unknown are fine.

Can you try this?

# python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
import logging
import rpisec

rpis = rpisec.RpisSecurity('/etc/rpi-security.conf', '/var/lib/rpi-security/data.yaml')
camera = rpisec.RpisCamera(rpis.photo_size, rpis.gif_size, rpis.motion_size,
            rpis.camera_vflip, rpis.camera_hflip, rpis.motion_detection_setting,
            rpis.camera_capture_length, rpis.camera_mode)

And paste me the error?

1997mohan commented 6 years ago

(cv) pi@raspberrypi:~ $ sudo systemctl daemon-reload (cv) pi@raspberrypi:~ $ sudo systemctl enable rpi-security.service (cv) pi@raspberrypi:~ $ sudo systemctl start rpi-security.service (cv) pi@raspberrypi:~ $ sudo su root@raspberrypi:/home/pi# /usr/local/bin/rpi-security.py -d 2018-03-13 06:05:53 DEBUG rpis_security.py:69 MainThread Data file read: /var/lib/rpi-security/data.yaml 2018-03-13 06:05:53 CRITICAL exit_clean.py:22 MainThread Configuration error: KeyError(2,) root@raspberrypi:/home/pi#

1997mohan commented 6 years ago

(cv) pi@raspberrypi:~ $ python Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124] on linux Type "help", "copyright", "credits" or "license" for more information.

import logging import rpisec Traceback (most recent call last): File "", line 1, in ImportError: No module named 'rpisec'

FutureSharks commented 6 years ago

Hi @1997mohan

2 things.

First, you can't start it like /usr/local/bin/rpi-security.py -d without first adding the mon0 interface manually. So try like this:

root@raspberrypi:~# iw phy phy0 interface add mon0 type monitor
root@raspberrypi:~# ifconfig mon0 up
root@raspberrypi:~# rpi-security.py -d

Second, it looks like in your second example you are using a virtualenv called cv? Also you are not running it as root.

1997mohan commented 6 years ago

superb man, now all threads are working fine but it fails to send the photo and gif. i think the resolution u have given is too high i'm using raspberry pi noir camera v 2.1. is there any possibilities to reduce the resolution or what is the problem arising can u explain?

FutureSharks commented 6 years ago

Cool.

Yes, the resolution can be too high and it can also crash the RPI when it runs out of memory. Try changing the values here: https://github.com/FutureSharks/rpi-security/blob/master/etc/rpi-security.conf#L33-L40

FutureSharks commented 6 years ago

Hey, I updated the readme with some missing packages: https://github.com/FutureSharks/rpi-security/commit/506738fcdd23585b3663a28404bd2a8235bb050d

Could you retest?