Skip to content

Commit

Permalink
Add Dropbox, GPS, Wiper (#13)
Browse files Browse the repository at this point in the history
* Start major code refactor

add constantS

replace Camera class objects with PiCamera

fix missing imports

create a camera package

remove relative imports from main.py

fix capture.py import

remove relative imports

update requirements.txt

add more requirements

fix camera imports

refactor main.py

minor fixes

minor fixes

remove thread_active from app_server

Fix bug with load_scheduler data function

Fix viewConfig endpoint

fix camera errors

Start major code refactor

add constantS

replace Camera class objects with PiCamera

fix missing imports

create a camera package

remove relative imports from main.py

fix capture.py import

remove relative imports

add more requirements

fix camera imports

refactor main.py

minor fixes

remove thread_active from app_server

Fix bug with load_scheduler data function

Fix viewConfig endpoint

fix camera errors

Fix sensor class

Add utils for camera to get camera name

Fix issue: JSON parsing of camera config in viewConfig

Add clearSchedule endpoint

Fix json load for clearSchedule

add shutter speed to capture_video

fix json load for clearSchedule

logging debug messages to capture images

add debug logs to camera thread

add more debug logs to capture_images

fix shutter speed spelling

add exception handling for sensor not connected

add error handling to sensors

wrap sensor in try catch

wrap sensor in try catch

change resolution to int tuple in Scheduler.py

convert datetime to string for video filename

add update route to the server

Start major code refactor

add constantS

replace Camera class objects with PiCamera

fix missing imports

create a camera package

fix capture.py import

remove relative imports

add more requirements

refactor main.py

minor fixes

Start major code refactor

add constantS

replace Camera class objects with PiCamera

fix missing imports

create a camera package

remove relative imports from main.py

fix capture.py import

remove relative imports

add more requirements

fix camera imports

refactor main.py

minor fixes

remove thread_active from app_server

Fix bug with load_scheduler data function

Fix viewConfig endpoint

Fix sensor class

Add utils for camera to get camera name

add shutter speed to capture_video

logging debug messages to capture images

add debug logs to camera thread

add more debug logs to capture_images

fix shutter speed spelling

add error handling to sensors

wrap sensor in try catch

wrap sensor in try catch

change resolution to int tuple in Scheduler.py

convert datetime to string for video filename

fix start recording in testPhotoMem

add sleep to capture continuous

Start major code refactor

replace Camera class objects with PiCamera

fix missing imports

create a camera package

fix capture.py import

remove relative imports

update requirements.txt

add more requirements

fix camera imports

refactor main.py

minor fixes

minor fixes

Start major code refactor

add constantS

replace Camera class objects with PiCamera

fix missing imports

create a camera package

remove relative imports from main.py

fix capture.py import

remove relative imports

add more requirements

fix camera imports

refactor main.py

minor fixes

remove thread_active from app_server

Fix viewConfig endpoint

Fix sensor class

Add utils for camera to get camera name

Fix issue: JSON parsing of camera config in viewConfig

add shutter speed to capture_video

fix json load for clearSchedule

logging debug messages to capture images

add debug logs to camera thread

add more debug logs to capture_images

fix shutter speed spelling

add error handling to sensors

wrap sensor in try catch

wrap sensor in try catch

change resolution to int tuple in Scheduler.py

convert datetime to string for video filename

add update route to the server

fix start recording in testPhotoMem

Start major code refactor

replace Camera class objects with PiCamera

fix missing imports

create a camera package

fix capture.py import

remove relative imports

update requirements.txt

add more requirements

refactor main.py

minor fixes

Fix viewConfig endpoint

fix camera errors

Start major code refactor

add constantS

replace Camera class objects with PiCamera

fix missing imports

create a camera package

remove relative imports from main.py

fix capture.py import

remove relative imports

add more requirements

fix camera imports

refactor main.py

minor fixes

remove thread_active from app_server

Fix viewConfig endpoint

Fix sensor class

Add utils for camera to get camera name

Fix issue: JSON parsing of camera config in viewConfig

add shutter speed to capture_video

fix json load for clearSchedule

logging debug messages to capture images

add debug logs to camera thread

add more debug logs to capture_images

fix shutter speed spelling

add error handling to sensors

wrap sensor in try catch

wrap sensor in try catch

change resolution to int tuple in Scheduler.py

convert datetime to string for video filename

add update route to the server

add sleep to capture continuous

fix shutter speed in capture_video

* add witty pi commands to clear schedule

* Add wiper code

* Add wiper run on each slot start with wiper as on

* Add GPS code

* Fix wiper module imports

* Add pwm mode on pin enable

* migrate to subprocess

* Fix gps update

* Integrate uploader and GPS

* Fix upload import

* Dropbox from environment

* Fix resolving fields for wiper and uplaod from schedule

* Add dropbox handlers in socket
:

* Make auth static methods

* Fix socket connection request, make non-static

* Add logging for auth url

* Add user details response email

* Fix wiper_status variable

* Fix sensor loading logic

* Fix GPS object creation

* Add logging for upload

* Add auth check dropbox

* Remove redundant data argument

* Add optimisation for upload, add wiper code with correct angle

* Fix sensor error handling

* Add dropbox auth error handling

* Integrate subsea light sensor

* Remove object from Subsealight class

* add error handling for get user

* Add handler for dropbox credential file creation

* Add update script for users

Co-authored-by: Manya Agarwal <manya18ag@gmail.com>
  • Loading branch information
utkarsh867 and manyaagarwal authored Mar 15, 2021
1 parent 85697b2 commit 55c6199
Show file tree
Hide file tree
Showing 55 changed files with 1,602 additions and 1,852 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
!ngrok
!.github
!.github/**
!scripts
!scripts
!etc/
!etc/**
66 changes: 66 additions & 0 deletions etc/dhcpcd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0
inteface wlan0
static ip_address=192.168.5.1/24
nohook wpa_supplicant

interface eth0
static ip_address=192.168.8.106/24
static routers=192.168.8.1
static domain_name_server=8.8.8.8
4 changes: 4 additions & 0 deletions etc/dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface=wlan0
dhcp-range=192.168.5.2,192.168.5.20,255.255.255.0,24h
domain=wlan
address=/gw.wlan/192.168.5.1
81 changes: 0 additions & 81 deletions openoceancamera/Camera.py

This file was deleted.

73 changes: 39 additions & 34 deletions openoceancamera/Scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,71 @@


class Scheduler(object):
def __init__(self, data):
self.time_now = datetime.now()
self.schedule_data = []
self.load_scheduler_data(data)

def update_current_time(self):
self.time_now = datetime.now()
def __init__(self):
self.schedule_data = []

def should_start(self):
for i in range(len(self.schedule_data)):
if (
self.schedule_data[i]["start"]
<= self.time_now
<= datetime.now()
<= self.schedule_data[i]["stop"]
):
return i
return -1

def get_slot(self, index):
return self.schedule_data[index]

def load_scheduler_data(self, data):
for i in range(len(data)):
frame = {
"start": None,
"stop": None,
}
frame["start"] = datetime.strptime(data[i]["start"], "%Y-%m-%d-%H:%M:%S")
frame["stop"] = datetime.strptime(data[i]["stop"], "%Y-%m-%d-%H:%M:%S")
self.schedule_data = []
for slot in data:
frame = {}
frame["start"] = datetime.strptime(slot["start"], "%Y-%m-%d-%H:%M:%S")
frame["stop"] = datetime.strptime(slot["stop"], "%Y-%m-%d-%H:%M:%S")
frame["iso"] = slot.get("iso", 0)
frame["frequency"] = slot.get("frequency", 10)
frame["shutter_speed"] = slot.get("shutter_speed", 0)
frame["video"] = slot.get("video")
frame["upload"] = slot.get("upload", False)
frame["light"] = slot.get("light", 0)
frame["wiper"] = slot.get("wiper", False)
frame["exposure_mode"] = slot.get("exposure_mode", "auto")
frame["exposure_compensation"] = slot.get("exposure_compensation", 0)
frame["framerate"] = slot.get("framerate", 0)
resolution = slot.get("resolution", {"x": 1920, "y": 1080})
frame["resolution"]= (resolution["x"], resolution["y"])
self.schedule_data.append(frame.copy())

def next_future_timeslot(self):
future_slots = []
# Get the future slots
for slot in self.schedule_data:
if slot["start"] >= datetime.now():
future_slots.append(slot)
# Sorts the slots in case they may not be
future_slots = sorted(future_slots, key=lambda x: x["start"])
if len(future_slots):
return future_slots[0]
else:
return None

def time_to_nearest_schedule(self):
self.update_current_time()
possible_slots = []

# Get the future slots
for slot in self.schedule_data:
if slot["start"] >= self.time_now:
if slot["start"] >= datetime.now():
possible_slots.append(slot)

# Sorts the slots in case they may not be
possible_slots = sorted(possible_slots, key=lambda x: x["start"])

print(f"The time now is: {self.time_now}")
print(f"The time now is: {datetime.now()}")
print(f"The future slots are: {possible_slots}")

# Take the difference between the most recent slot's start time and time now
delta = possible_slots[0]["start"] - self.time_now
delta = possible_slots[0]["start"] - datetime.now()
print(f"The time difference is: {delta}")
# Returns an integer value for the time difference in seconds
return int(delta.total_seconds())

def next_future_timeslot(self):
self.update_current_time()

future_slots = []
# Get the future slots
for slot in self.schedule_data:
if slot["start"] >= self.time_now:
future_slots.append(slot)
# Sorts the slots in case they may not be
future_slots = sorted(future_slots, key=lambda x: x["start"])
if len(future_slots):
return future_slots[0]
else:
return None
5 changes: 0 additions & 5 deletions openoceancamera/TSL2561/.categories

This file was deleted.

74 changes: 0 additions & 74 deletions openoceancamera/TSL2561/Arduino/TSL2561.ino

This file was deleted.

Loading

0 comments on commit 55c6199

Please sign in to comment.