Compare commits

...

No commits in common. 'master' and 'yigit' have entirely different histories.

41 changed files with 323 additions and 3911 deletions
Split View
  1. +4
    -0
      .gitignore
  2. +12
    -56
      Ev3/main.py
  3. +197
    -0
      MyCity/MyCity/.idea/workspace.xml
  4. +0
    -1
      MyCity/README.md
  5. +14
    -0
      MyCity/gradle.properties
  6. +6
    -0
      MyCity/gradle/wrapper/gradle-wrapper.properties
  7. +1
    -2
      README.md
  8. +1
    -0
      build.gradle
  9. +0
    -173
      bus_stop/main.py
  10. +0
    -4
      bus_stop/main.py.err.log
  11. +0
    -66
      bus_stop/qr_reader/main.py
  12. +0
    -17
      bus_stop/qr_reader/starter.php
  13. +0
    -338
      bus_stop/times.json
  14. +1
    -1
      client_side/app.py
  15. +9
    -0
      client_side/client_side.iml
  16. +37
    -0
      client_side/modules/qr/reader.py
  17. +24
    -45
      client_side/modules/qr/user_data.py
  18. +5
    -0
      master_app/target/maven-archiver/pom.properties
  19. +0
    -24
      robot/listener.py
  20. +0
    -14
      robot/robot.py
  21. +0
    -89
      telnet/main.ino
  22. +0
    -0
      telnet/telnet.ino
  23. +0
    -4
      traffic_analyzer/CMakeLists.2.txt/.idea/serialmonitor_settings.xml
  24. +0
    -6
      traffic_analyzer/CMakeLists.2.txt/.idea/vcs.xml
  25. +0
    -15
      traffic_analyzer/CMakeLists.txt
  26. BIN
      traffic_analyzer/CPUThermometerLib.dll
  27. BIN
      traffic_analyzer/OpenHardwareMonitorLib.dll
  28. +0
    -89
      traffic_analyzer/cmake/ArduinoToolchain.cmake
  29. +0
    -2340
      traffic_analyzer/cmake/Platform/Arduino.cmake
  30. BIN
      traffic_analyzer/debug_data/amb_1.mp4
  31. BIN
      traffic_analyzer/debug_data/amb_2.mp4
  32. BIN
      traffic_analyzer/debug_data/frame_data.pkl
  33. +0
    -211
      traffic_analyzer/light_control.ino
  34. +0
    -1
      traffic_analyzer/light_control/.idea/.name
  35. +0
    -7
      traffic_analyzer/light_control/.idea/misc.xml
  36. +0
    -8
      traffic_analyzer/light_control/.idea/modules.xml
  37. +0
    -4
      traffic_analyzer/light_control/.idea/serialmonitor_settings.xml
  38. +0
    -6
      traffic_analyzer/light_control/.idea/vcs.xml
  39. +0
    -200
      traffic_analyzer/light_control/.idea/workspace.xml
  40. +0
    -190
      traffic_analyzer/light_control/light_control.ino
  41. +12
    -0
      traffic_analyzer/traffic_analyzer.iml

+ 4
- 0
.gitignore View File

@ -65,3 +65,7 @@ fabric.properties
traffic_analyzer/rfcn_resnet101_coco_2018_01_28/
server_side/api/modules/faster_rcnn_resnet101_kitti_2018_01_28/
server_side/api/modules/trainedModels/
backups/
server_side/api/modules/rfcn_resnet101_coco_2018_01_28/
server_side/api/modules/trainedModels/
traffic_analyzer/rfcn_resnet101_coco_2018_01_28/

+ 12
- 56
Ev3/main.py View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3
print("[INFO]: Interpreter started")
from ev3dev.core import *
import ev3dev.ev3 as ev3
print("[INFO]: Imported ev3dev.ev3")
import socket
print("[INFO]: Imported socket")
@ -10,32 +9,12 @@ print("[INFO]: Imported os")
import json
print("[INFO]: Imported json")
state = True
motor1 = ev3.LargeMotor("outA")
motor2 = ev3.LargeMotor("outD")
cam = ev3.MediumMotor('outB')
def move(speed):
if time:
motor1.run_forever(speed_sp=speed)
motor2.run_forever(speed_sp=speed)
cam.run_to_abs_pos(position_sp=0, speed_sp=500)
def stop():
motor1.stop()
motor2.stop()
cam.stop()
HOST = '0.0.0.0'
PORT = 3131
pid=os.fork()
if pid==0: # new process
mjpeg_loc = "/home/robot/mjpg-streamer/"
os.system('{0}mjpg_streamer -i "{0}input_uvc.so -f 15 -y" -o "{0}output_http.so -w {0}www"'.format(mjpeg_loc))
exit()
mjpeg_loc = "/home/robot/mjpeg-streamer/mjpeg-streamer-experimantal/mjpeg-streamer"
os.spawnl(os.P_DETACH, ' -i "./input_uvc.so -f 15 -r 640x480" -o "./output_http.so -w ./www"')
power = PowerSupply()
if power.measured_volts < 7.1:
print("Change the battery.")
exit()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
@ -46,42 +25,19 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
conn, addr = s.accept()
with conn:
print('[INFO]: Connected by', addr)
move(500)
while True:
if cam.speed == 0 and (motor1.speed > 0 and motor2.speed > 0):
if state:
cam.run_to_abs_pos(position_sp=4000, speed_sp=500)
else:
cam.run_to_abs_pos(position_sp=0, speed_sp=500)
state = not state
try:
received = conn.recv(1024)
if not received:
raise BrokenPipeError("Client disconnect")
else:
received = received.decode().strip()[-1]
print(received)
if received == 's':
stop()
elif received == 'm':
move(500)
elif received == 'i':
data = {
"battery_voltage":str(round(power.measured_volts,1)),
"current_drawn":str(round(power.measured_amps,1)),
"lat":"31",
"lng":"39"
}
conn.send((json.dumps(data, ensure_ascii=False)+"\n").encode('gbk'))
elif recieved == '+':
cam.run_timed(time_sp=50, speed_sp=750)
elif recieved == '-':
cam.run_timed(time_sp=50, speed_sp=-750)
data = {
"battery_voltage":power.measured_volts,
"current_drawn":power.measured_amps,
"lat":31,
"lng":39
}
conn.send((json.dumps(data, ensure_ascii=False)+"\n").encode('gbk'))
except BrokenPipeError:
print("[INFO]: Client disconnected")
stop()
break
except KeyboardInterrupt:
stop()
s.close()
s.close()

+ 197
- 0
MyCity/MyCity/.idea/workspace.xml View File

@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c15bf79f-06f0-4898-b105-7cb954ab0ad5" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/classes/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DefaultGradleProjectSettings">
<option name="testRunner" value="GRADLE" />
<option name="delegatedBuild" value="true" />
</component>
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="260" />
<option name="y" value="54" />
<option name="width" value="1400" />
<option name="height" value="1000" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane" />
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="AndroidView" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="android.sdk.path" value="$USER_HOME$/Android" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/.." />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="AndroidSdkUpdater" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="c15bf79f-06f0-4898-b105-7cb954ab0ad5" name="Default Changelist" comment="" />
<created>1563823261629</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1563823261629</updated>
<workItem from="1563823265677" duration="852000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="852000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="27" width="1920" height="1053" extended-state="6" />
<layout>
<window_info id="Designer" />
<window_info id="Build Variants" side_tool="true" />
<window_info id="Image Layers" />
<window_info id="Capture Tool" />
<window_info id="UI Designer" />
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.18051118" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Build" visible="true" weight="0.31122994" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Maven" />
<window_info anchor="right" id="Palette" />
<window_info anchor="right" id="Capture Analysis" />
<window_info anchor="right" id="Gradle" />
<window_info anchor="right" id="SciView" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Palette&#9;" />
<window_info anchor="right" id="Theme Preview" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>app</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

+ 0
- 1
MyCity/README.md View File

@ -1 +0,0 @@
MyCity

+ 14
- 0
MyCity/gradle.properties View File

@ -0,0 +1,14 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
GOOGLE_MAPS_API_KEY=AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

+ 6
- 0
MyCity/gradle/wrapper/gradle-wrapper.properties View File

@ -0,0 +1,6 @@
#Wed Mar 13 09:22:39 EET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

+ 1
- 2
README.md View File

@ -1,2 +1 @@
Smart_Management
https://pastebin.com/XKGWpYQK
<h1>Smart_Management</h1>

+ 1
- 0
build.gradle View File

@ -0,0 +1 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

+ 0
- 173
bus_stop/main.py View File

@ -1,173 +0,0 @@
#!/usr/bin/env python3
'''Hello to the world from ev3dev.org'''
import os
import sys
import time
import json
import datetime
import urllib3
import requests
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1,INPUT_2
from ev3dev2.sensor.lego import TouchSensor
from ev3dev2.sensor.lego import UltrasonicSensor
from ev3dev2.sound import Sound
from ev3dev2.button import Button
ON = True
OFF = False
def debug_print(*args, **kwargs):
print(*args, **kwargs, file=sys.stderr)
def reset_console():
print('\x1Bc', end='')
def set_cursor(state):
if state:
print('\x1B[?25h', end='')
else:
print('\x1B[?25l', end='')
def set_font(name):
'''Sets the console font
A full list of fonts can be found with `ls /usr/share/consolefonts`
'''
os.system('setfont ' + name)
def raise_ramp():
print("Raising ramp")
def get_closest_time(times, time):
closest = 0
times = [datetime.datetime.strptime(i,"%H:%M") for i in times]
time = datetime.datetime.strptime(time,"%H:%M")
for i in times:
if i.hour < time.hour or (i.hour == time.hour and i.minute < time.minute):
continue
else:
if closest == 0:
closest = i
continue
if abs(i.hour - time.hour) < abs(closest.hour - time.hour):
closest = i
continue
elif abs(i.hour - time.hour) == abs(closest.hour - time.hour):
if i.minute - time.minute < closest.minute - time.minute:
closest = i
return closest.strftime("%H:%M")
def time_diff(t1, t2):
time1 = datetime.datetime.strptime(t1, "%H:%M")
time2 = datetime.datetime.strptime(t2, "%H:%M")
response = ""
if abs(time2.hour - time1.hour) < 10:
response += "0"
if time2.minute - time1.minute >= 0:
response += str(abs(time2.hour - time1.hour))
else:
response += str(abs(time2.hour - time1.hour) - 1)
response += ":"
if abs(time2.minute - time1.minute) < 10:
response += "0"
response += str(abs(time2.minute - time1.minute))
return response
def raise_ramp(motor1):
motor1.on_for_rotations(SpeedPercent(75), 5)
def main():
start = time.time()
file = open("times.json","r")
time_data = json.loads(file.read())
stop_data = [i for i in time_data.keys()]
debug_print(stop_data)
file.close()
time_start = "10:02"
debug_print('Started Code')
reset_console()
set_cursor(OFF)
set_font('Lat15-Terminus24x12')
alarms = [0,0,0]
stop = "11222"
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
print('AKILLI DURAK')
sound = Sound()
us = UltrasonicSensor(INPUT_2)
us.MODE_US_DIST_CM
btn = Button()
m1 = LargeMotor(OUTPUT_A)
ts = TouchSensor(INPUT_1)
while 1:
if us.distance_centimeters < 15:
sound.speak("Please select a stop")
i = 0
reset_console()
print(stop_data[i%len(stop_data)])
while not btn.enter:
if btn.up:
i += 1
reset_console()
print(stop_data[i%len(stop_data)])
time.sleep(0.1)
if btn.down:
i -= 1
reset_console()
print(stop_data[i%len(stop_data)])
time.sleep(0.1)
closest = datetime.datetime.strptime(time_diff(time_start,get_closest_time(time_data[stop_data[i%len(stop_data)]]["weekday"][:],time_start)),"%H:%M")
difference = datetime.timedelta(hours=closest.hour,minutes=closest.minute).total_seconds()+start
if not difference in alarms:
alarms[i%len(stop_data)] = difference
r = requests.get("https://192.168.44.50:5000/bus?line={}&stop={}".format(stop_data[i%len(stop_data)],stop), verify=False)
print(difference-time.time())
time.sleep(1)
reset_console()
print("AKILLI DURAK")
for i in range(len(alarms)):
if alarms[i] == 0:
continue
else:
if alarms[i]-time.time()<0:
reset_console()
print("Bus no {} has arrived".format(stop_data[i%len(stop_data)]))
sound.speak("Bus no {} has arrived".format(stop_data[i%len(stop_data)]))
sound.speak("Would you like a ramp?")
waiter = time.time()
pressed = True
while time.time()-waiter < 10 and pressed:
if ts.is_pressed:
pressed = False
raise_ramp(m1)
reset_console()
print("AKILLI DURAK")
alarms[i] = 0
if __name__ == '__main__':
main()

+ 0
- 4
bus_stop/main.py.err.log View File

@ -1,4 +0,0 @@
Traceback (most recent call last):
File "/home/robot/bus_stop/main.py", line 9, in <module>
import urllib3
ImportError: No module named 'urllib3'

+ 0
- 66
bus_stop/qr_reader/main.py View File

@ -1,66 +0,0 @@
from imutils.video import VideoStream
from pyzbar import pyzbar
import requests
import imutils
import cv2
import urllib3
import socket
import struct
import zlib
import pickle
vs = VideoStream().start()
dates = []
reps = 0
barcodes = None
prevcode = None
host = '10.10.26.141'
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((host, 8485))
connection = client_socket.makefile('wb')
def main():
global vs
global dates
global reps
global barcodes
global prevcode
while True:
try:
while (barcodes == None or barcodes == []):
frame = vs.read()
frame = imutils.resize(frame, width=400)
barcodes = pyzbar.decode(frame)
res, frm = cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
send_data = zlib.compress(pickle.dumps(frm, 0))
size = len(send_data)
client_socket.sendall(struct.pack(">L", size) + data)
barcodes = pyzbar.decode(frame)
# loop over the detected barcodes
for barcode in barcodes:
(x, y, w, h) = barcode.rect
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if (barcodeData != prevcode):
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(frame, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
requests.post('https://' + host + ':5000/reduce', data={'id': barcodeData, 'reduce': 5}, verify=False)
reps += 1
prevcode = barcodeData
barcodes = None
except KeyboardInterrupt:
break
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
main()
print("[INFO] cleaning up...")
cv2.destroyAllWindows()
vs.stop()

+ 0
- 17
bus_stop/qr_reader/starter.php View File

@ -1,17 +0,0 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
system("python /home/pi/Desktop/MyCity/bus_stop/qr_reader/main.py > /dev/null 2>&1 &");
}else{
echo "
<html>
<body>
<button type=\"button\" onclick=\"Http = new XMLHttpRequest();
Http.open(\"POST\",\".\");
Http.send();
\" >Click Me!</button>
</body>
</html>
";
}
?>

+ 0
- 338
bus_stop/times.json View File

@ -1,338 +0,0 @@
{
"188-5": {
"saturday": [],
"weekday": [
"06:20",
"06:35",
"06:35",
"06:50",
"06:50",
"07:05",
"07:17",
"07:20",
"07:29",
"07:35",
"07:41",
"07:50",
"07:53",
"08:05",
"08:05",
"08:20",
"08:20",
"08:35",
"08:35",
"08:50",
"08:50",
"09:05",
"09:05",
"09:25",
"09:25",
"09:45",
"09:45",
"10:05",
"10:05",
"10:25",
"10:25",
"10:45",
"10:45",
"11:05",
"11:05",
"11:25",
"11:25",
"11:45",
"11:45",
"12:05",
"12:05",
"12:25",
"12:25",
"12:45",
"12:45",
"13:05",
"13:05",
"13:25",
"13:25",
"13:45",
"13:45",
"14:05",
"14:05",
"14:25",
"14:25",
"14:45",
"14:45",
"15:05",
"15:05",
"15:25",
"15:25",
"15:45",
"15:45",
"16:05",
"16:05",
"16:25",
"16:25",
"16:45",
"16:45",
"17:05",
"17:05",
"17:25",
"17:25",
"17:45",
"17:45",
"18:05",
"18:05",
"18:25",
"18:25",
"18:45",
"18:45",
"19:05",
"19:05",
"19:35",
"19:35",
"20:05",
"20:05",
"20:35",
"20:35",
"21:05",
"21:05",
"21:35",
"21:35",
"22:05",
"22:05"
]
},
"173-1": {
"saturday": [
"06:49",
"07:19",
"07:49",
"08:20",
"08:50",
"09:19",
"10:19",
"11:20",
"12:19",
"13:18",
"14:18",
"15:19",
"15:49",
"16:19",
"16:49",
"17:19",
"17:49",
"18:24",
"19:03",
"20:03",
"21:05",
"22:05"
],
"weekday": [
"06:29",
"06:49",
"07:09",
"07:29",
"07:49",
"08:10",
"08:35",
"09:14",
"09:54",
"10:34",
"11:15",
"11:55",
"12:35",
"13:14",
"13:54",
"14:34",
"14:54",
"15:14",
"15:34",
"15:54",
"16:14",
"16:34",
"16:54",
"17:15",
"17:35",
"17:55",
"18:15",
"18:35",
"19:03",
"19:33",
"20:03",
"21:05",
"22:05"
]
},
"185-3": {
"saturday": [
"05:55",
"06:04",
"06:13",
"06:22",
"06:31",
"06:39",
"06:47",
"06:55",
"06:56",
"07:03",
"07:05",
"07:11",
"07:14",
"07:19",
"07:23",
"07:27",
"07:33",
"07:36",
"07:43",
"07:53",
"08:03",
"08:13",
"08:23",
"08:33",
"08:43",
"08:53",
"09:02",
"09:11",
"09:20",
"09:29",
"09:38",
"09:47",
"09:56",
"10:05",
"10:14",
"10:23",
"10:32",
"10:41",
"10:50",
"10:59",
"11:08",
"11:17",
"11:26",
"11:35",
"11:45",
"11:55",
"12:05",
"12:15",
"12:25",
"12:35",
"12:45",
"12:55",
"13:05",
"13:15",
"13:25",
"13:35",
"13:45",
"13:55",
"14:05",
"14:15",
"14:25",
"14:35",
"14:45",
"14:55",
"15:05",
"15:15",
"15:25",
"15:35",
"15:45",
"15:55",
"16:05",
"16:15",
"16:25",
"16:35",
"16:45",
"16:55",
"17:05",
"17:15",
"17:25",
"17:35",
"17:45",
"17:55",
"18:05",
"18:15",
"18:25",
"18:35",
"18:45",
"18:55",
"19:05",
"19:15",
"19:25",
"19:35",
"19:45",
"19:55",
"20:01",
"20:06",
"20:11",
"20:17",
"20:21",
"20:28",
"20:31",
"20:39",
"20:46",
"20:51",
"21:03",
"21:15",
"21:16",
"21:29",
"21:44",
"22:03",
"22:26"
],
"weekday": [
"05:51",
"06:00",
"06:09",
"06:18",
"06:27",
"06:36",
"06:44",
"06:50",
"06:52",
"06:59",
"07:00",
"07:07",
"07:08",
"07:14",
"07:17",
"07:21",
"07:26",
"07:28",
"07:36",
"07:46",
"07:56",
"08:06",
"08:16",
"08:26",
"08:36",
"08:46",
"08:55",
"09:05",
"09:15",
"09:25",
"09:35",
"09:44",
"09:53",
"10:03",
"10:12",
"10:21",
"10:30",
"10:39",
"10:48",
"10:57",
"11:06",
"11:15",
"11:24",
"11:34",
"11:43",
"11:52",
"12:01",
"12:10",
"12:19",
"12:28",
"12:37",
"12:46",
"12:55",
"13:05",
"13:15",
"13:25",
"13:35",
"13:45",
"13:55",
"14:05"
]}}

+ 1
- 1
client_side/app.py View File

@ -80,4 +80,4 @@ def send_img(path):
return send_from_directory('interface/UserData', path)
if __name__ == '__main__':
socketio.run(app,host="0.0.0.0",port=4000,debug=True)
socketio.run(app,port=4000,debug=True)

+ 9
- 0
client_side/client_side.iml View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 37
- 0
client_side/modules/qr/reader.py View File

@ -0,0 +1,37 @@
import cv2
from pyzbar import pyzbar
class Read():
instance = 0
sid = 0
def __init__(self,inst):
self.instance = inst
def detect(self):
cam = cv2.VideoCapture(0)
barcodeData_prev = 0
while 1:
ret , img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcode = pyzbar.decode(gray)
if len(barcode) > 0:
barcode = barcode[0]
(x, y, w, h) = barcode.rect
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if barcodeData_prev == 0 or barcodeData_prev != barcodeData:
barcodeData_prev = barcodeData
self.instance.received(barcodeData)
continue
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(img, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 0, 0), 2)
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
cv2.imshow("a", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cam.release()
cv2.destroyAllWindows()

+ 24
- 45
client_side/modules/qr/user_data.py View File

@ -1,64 +1,43 @@
from flask import Flask, jsonify, request, abort,Response
from multiprocessing import Process
from PIL import Image
from io import BytesIO
from imutils.video import VideoStream
import requests
import cv2
import pickle
import base64
import reader
import json
from pyzbar import pyzbar
import subprocess
import urllib3
import imutils
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
app = Flask(__name__)
user = {}
image = None
def im2str(im):
crop_img = Image.fromarray(im, "RGB")
buffered = BytesIO()
crop_img.save(buffered, format="JPEG")
img = base64.b64encode(buffered.getvalue()).decode("ascii")
return img
class Reader():
def __init__(self):
read = reader.Read(self)
p1 = Process(target=read.detect)
p1.start()
def received(self, data):
r = requests.get('https://0.0.0.0:5000/users/{}'.format(data), verify=False)
requests.get('http://0.0.0.0:3000/set', data={'data': r.text})
vs=VideoStream().start()
barcodeData_prev = 0
qr_reader = Reader()
@app.route('/set')
def set_data():
global user
user = json.loads(request.form['data'])
resp = Response("OK")
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp
@app.route('/get')
def get_qr():
global user
global image
global barcodeData_prev
if user == {}:
abort(404)
frame = vs.read()
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcode = pyzbar.decode(gray)
if len(barcode) > 0:
barcode = barcode[0]
(x, y, w, h) = barcode.rect
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if barcodeData_prev == 0 or barcodeData_prev != barcodeData:
barcodeData_prev = barcodeData
r = requests.get('https://192.168.2.203:5000/users/{}'.format(barcodeData), verify=False)
user = json.loads(r.text)
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(img, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 0, 0), 2)
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
else:
user = {}
result = subprocess.check_output(['vcgencmd', 'measure_temp'])
temp = result.split("=")[1][:-2] +"C"
image = im2str(img)
resp = Response(json.dumps({"user":user,"img":image,"temp":temp}))
resp = Response(json.dumps(user))
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp


+ 5
- 0
master_app/target/maven-archiver/pom.properties View File

@ -0,0 +1,5 @@
#Generated by Maven
#Mon Jul 08 11:26:41 EET 2019
groupId=me.yigitcolakoglu
artifactId=master_app
version=1.0-SNAPSHOT

+ 0
- 24
robot/listener.py View File

@ -1,24 +0,0 @@
from urllib.request import urlopen, Request
from urllib.parse import urlencode
import cv2
import json
AI_IP = '192.168.2.252'
cam = cv.VideoCapture('http://10.42.0.151:8080/?action=stream')
while True:
ret, img = cam.read()
img = cv2.resize(img, (1280, 960))
url = 'https://{}:5001/ai'.format(AI_IP)
_, buffer = cv2.imencode('.jpg', img)
post_fields = {'img': base64.b64encode(buffer).decode('ascii'), "type": "damage"}
request = Request(url, urlencode(post_fields).encode())
output_dict = json.loads(json.loads(urlopen(request, context=context).read()))
cv2.imshow('Image', img)
cv2.waitKey(0)

+ 0
- 14
robot/robot.py View File

@ -1,14 +0,0 @@
import os
path = '/home/robot/image/'
prev_files = []
files = []
# r=root, d=directories, f = files
for r, d, f in os.walk(path):
for file in f:
if '.jpg' in file:
files.append(os.path.join(r, file))
for f in files:
print(f)

+ 0
- 89
telnet/main.ino View File

@ -1,89 +0,0 @@
#include "Arduino.h"
#include "Esp.h"
#include "ESP8266WiFi.h"
const char* ssid = "AirTies_Air5343";
const char* password = "yigit007";
const int pins[2][3] = {{5,4,16},{2,14,0}};
WiFiServer listenServer(31);
WiFiServer broadcastServer(69);
int lights[2] = {0,2};
void setup() {
Serial.begin(115200);
pinMode(12,OUTPUT);
delay(1000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(12,HIGH);
delay(150);
Serial.println("Connecting..");
digitalWrite(12,LOW);
delay(150);
}
Serial.print("Connected to WiFi. IP:");
Serial.println(WiFi.localIP());
for(int i = 0; i<2;i++){
for(int j = 0; j<3; j++){
pinMode(pins[i][j],OUTPUT);
}
}
listenServer.begin();
broadcastServer.begin();
digitalWrite(12,HIGH);
}
void loop() {
WiFiClient listener = listenServer.available();
WiFiClient sender = broadcastServer.available();
String message = "";
if (listener) {
while (listener.connected()) {
if(!sender){
Serial.println("Waiting sender");
sender = broadcastServer.available();
}
message = "";
while (listener.available()>0) {
char c = listener.read();
message += c;
}
if(message != ""){
lights[0] =message.charAt(0)-'0';
lights[1] = message.charAt(2)-'0';
Serial.println(lights[0]);
Serial.println(lights[1]);
for(int i = 0; i<2;i++){
for(int j = 0; j<3; j++){
if(j == lights[i]){
digitalWrite(pins[i][j],HIGH);
continue;
}
digitalWrite(pins[i][j],LOW);
}
}
Serial.println(message);
Serial.print("Connected:");
Serial.println(sender.connected());
Serial.print("Available:");
Serial.println(sender.available());
if(sender && sender.connected()){
Serial.println("Bookmark 1");
sender.println(message);
}
}
delay(10);
}
sender.stop();https://www.hackthebox.eu/login
listener.stop();
}
}

telnet/main/main.ino → telnet/telnet.ino View File


+ 0
- 4
traffic_analyzer/CMakeLists.2.txt/.idea/serialmonitor_settings.xml View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SerialMonitorSettings" BaudRate="9600" LineEndingsIndex="0" />
</project>

+ 0
- 6
traffic_analyzer/CMakeLists.2.txt/.idea/vcs.xml View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

+ 0
- 15
traffic_analyzer/CMakeLists.txt View File

@ -1,15 +0,0 @@
cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/ArduinoToolchain.cmake)
set(PROJECT_NAME light_control)
project(${PROJECT_NAME})
set(${CMAKE_PROJECT_NAME}_SKETCH light_control.ino)
#### Uncomment below additional settings as needed.
# set(${CMAKE_PROJECT_NAME}_BOARD mega)
# set(${CMAKE_PROJECT_NAME}_PORT /dev/ttyACM0)
# set(mega.build.mcu atmega2560)
# set(mega.upload.protocol wiring)
# set(mega.upload.speed 115200)
generate_arduino_firmware(${CMAKE_PROJECT_NAME})

BIN
traffic_analyzer/CPUThermometerLib.dll View File


BIN
traffic_analyzer/OpenHardwareMonitorLib.dll View File


+ 0
- 89
traffic_analyzer/cmake/ArduinoToolchain.cmake View File

@ -1,89 +0,0 @@
#=============================================================================#
# Author: Tomasz Bogdal (QueezyTheGreat)
# Home: https://github.com/queezythegreat/arduino-cmake
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#=============================================================================#
set(CMAKE_SYSTEM_NAME Arduino)
set(CMAKE_C_COMPILER avr-gcc)
set(CMAKE_CXX_COMPILER avr-g++)
# Add current directory to CMake Module path automatically
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
endif()
#=============================================================================#
# System Paths #
#=============================================================================#
if(UNIX)
include(Platform/UnixPaths)
if(APPLE)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications
/Applications
/Developer/Applications
/sw # Fink
/opt/local) # MacPorts
endif()
elseif(WIN32)
include(Platform/WindowsPaths)
endif()
#=============================================================================#
# Detect Arduino SDK #
#=============================================================================#
if(NOT ARDUINO_SDK_PATH)
set(ARDUINO_PATHS)
foreach(DETECT_VERSION_MAJOR 1)
foreach(DETECT_VERSION_MINOR RANGE 5 0)
list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR})
foreach(DETECT_VERSION_PATCH RANGE 3 0)
list(APPEND ARDUINO_PATHS arduino-${DETECT_VERSION_MAJOR}.${DETECT_VERSION_MINOR}.${DETECT_VERSION_PATCH})
endforeach()
endforeach()
endforeach()
foreach(VERSION RANGE 23 19)
list(APPEND ARDUINO_PATHS arduino-00${VERSION})
endforeach()
if(UNIX)
file(GLOB SDK_PATH_HINTS /usr/share/arduino*
/opt/local/arduino*
/opt/arduino*
/usr/local/share/arduino*)
elseif(WIN32)
set(SDK_PATH_HINTS "C:\\Program Files\\Arduino"
"C:\\Program Files (x86)\\Arduino"
)
endif()
list(SORT SDK_PATH_HINTS)
list(REVERSE SDK_PATH_HINTS)
endif()
find_path(ARDUINO_SDK_PATH
NAMES lib/version.txt
PATH_SUFFIXES share/arduino
Arduino.app/Contents/Resources/Java/
Arduino.app/Contents/Java/
${ARDUINO_PATHS}
HINTS ${SDK_PATH_HINTS}
DOC "Arduino SDK path.")
if(ARDUINO_SDK_PATH)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils)
else()
message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
endif()
set(ARDUINO_CPUMENU)
if(ARDUINO_CPU)
set(ARDUINO_CPUMENU ".menu.cpu.${ARDUINO_CPU}")
endif(ARDUINO_CPU)

+ 0
- 2340
traffic_analyzer/cmake/Platform/Arduino.cmake
File diff suppressed because it is too large
View File


BIN
traffic_analyzer/debug_data/amb_1.mp4 View File


BIN
traffic_analyzer/debug_data/amb_2.mp4 View File


BIN
traffic_analyzer/debug_data/frame_data.pkl View File


+ 0
- 211
traffic_analyzer/light_control.ino View File

@ -1,211 +0,0 @@
#include <Arduino.h>
/*
WiFiTelnetToSerial - Example Transparent UART to Telnet Server for esp8266
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
This file is part of the ESP8266WiFi library for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <ESP8266WiFi.h>
#include <algorithm> // std::min
#ifndef STASSID
#define STASSID "ZyXEL5500bT5"
#define STAPSK "eBusgxczl5"
#endif
/*
SWAP_PINS:
0: use Serial1 for logging (legacy example)
1: configure Hardware Serial port on RX:GPIO13 TX:GPIO15
and use SoftwareSerial for logging on
standard Serial pins RX:GPIO3 and TX:GPIO1
*/
#define SWAP_PINS 0
/*
SERIAL_LOOPBACK
0: normal serial operations
1: RX-TX are internally connected (loopback)
*/
#define SERIAL_LOOPBACK 0
#define BAUD_SERIAL 115200
#define BAUD_LOGGER 115200
#define RXBUFFERSIZE 1024
////////////////////////////////////////////////////////////
#if SERIAL_LOOPBACK
#undef BAUD_SERIAL
#define BAUD_SERIAL 3000000
#include <esp8266_peri.h>
#endif
#if SWAP_PINS
#include <SoftwareSerial.h>
SoftwareSerial* logger = nullptr;
#else
#define logger (&Serial1)
#endif
#define STACK_PROTECTOR 512 // bytes
//how many clients should be able to telnet to this ESP8266
#define MAX_SRV_CLIENTS 2
const char* ssid = STASSID;
const char* password = STAPSK;
const int port = 23;
WiFiServer server(port);
WiFiClient serverClients[MAX_SRV_CLIENTS];
void setup() {
Serial.begin(BAUD_SERIAL);
Serial.setRxBufferSize(RXBUFFERSIZE);
#if SWAP_PINS
Serial.swap();
// Hardware serial is now on RX:GPIO13 TX:GPIO15
// use SoftwareSerial on regular RX(3)/TX(1) for logging
logger = new SoftwareSerial(3, 1);
logger->begin(BAUD_LOGGER);
logger->println("\n\nUsing SoftwareSerial for logging");
#else
logger->begin(BAUD_LOGGER);
logger->println("\n\nUsing Serial1 for logging");
#endif
logger->println(ESP.getFullVersion());
logger->printf("Serial baud: %d (8n1: %d KB/s)\n", BAUD_SERIAL, BAUD_SERIAL * 8 / 10 / 1024);
logger->printf("Serial receive buffer size: %d bytes\n", RXBUFFERSIZE);
#if SERIAL_LOOPBACK
USC0(0) |= (1 << UCLBE); // incomplete HardwareSerial API
logger->println("Serial Internal Loopback enabled");
#endif
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
logger->print("\nConnecting to ");
logger->println(ssid);
while (WiFi.status() != WL_CONNECTED) {
logger->print('.');
delay(500);
}
logger->println();
logger->print("connected, address=");
logger->println(WiFi.localIP());
//start server
server.begin();
server.setNoDelay(true);
logger->print("Ready! Use 'telnet ");
logger->print(WiFi.localIP());
logger->printf(" %d' to connect\n", port);
}
void loop() {
//check if there are any new clients
if (server.hasClient()) {
//find free/disconnected spot
int i;
for (i = 0; i < MAX_SRV_CLIENTS; i++)
if (!serverClients[i]) { // equivalent to !serverClients[i].connected()
serverClients[i] = server.available();
logger->print("New client: index ");
logger->print(i);
break;
}
//no free/disconnected spot so reject
if (i == MAX_SRV_CLIENTS) {
server.available().println("busy");
// hints: server.available() is a WiFiClient with short-term scope
// when out of scope, a WiFiClient will
// - flush() - all data will be sent
// - stop() - automatically too
logger->printf("server is busy with %d active connections\n", MAX_SRV_CLIENTS);
}
}
//check TCP clients for data
#if 1
// Incredibly, this code is faster than the bufferred one below - #4620 is needed
// loopback/3000000baud average 348KB/s
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
while (serverClients[i].available() && Serial.availableForWrite() > 0) {
// working char by char is not very efficient
Serial.write(serverClients[i].read());
}
#else
// loopback/3000000baud average: 312KB/s
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
while (serverClients[i].available() && Serial.availableForWrite() > 0) {
size_t maxToSerial = std::min(serverClients[i].available(), Serial.availableForWrite());
maxToSerial = std::min(maxToSerial, (size_t)STACK_PROTECTOR);
uint8_t buf[maxToSerial];
size_t tcp_got = serverClients[i].read(buf, maxToSerial);
size_t serial_sent = Serial.write(buf, tcp_got);
if (serial_sent != maxToSerial) {
logger->printf("len mismatch: available:%zd tcp-read:%zd serial-write:%zd\n", maxToSerial, tcp_got, serial_sent);
}
}
#endif
// determine maximum output size "fair TCP use"
// client.availableForWrite() returns 0 when !client.connected()
size_t maxToTcp = 0;
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
if (serverClients[i]) {
size_t afw = serverClients[i].availableForWrite();
if (afw) {
if (!maxToTcp) {
maxToTcp = afw;
} else {
maxToTcp = std::min(maxToTcp, afw);
}
} else {
// warn but ignore congested clients
logger->println("one client is congested");
}
}
//check UART for data
size_t len = std::min((size_t)Serial.available(), maxToTcp);
len = std::min(len, (size_t)STACK_PROTECTOR);
if (len) {
uint8_t sbuf[len];
size_t serial_got = Serial.readBytes(sbuf, len);
// push UART data to all connected telnet clients
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
// if client.availableForWrite() was 0 (congested)
// and increased since then,
// ensure write space is sufficient:
if (serverClients[i].availableForWrite() >= serial_got) {
size_t tcp_sent = serverClients[i].write(sbuf, serial_got);
if (tcp_sent != len) {
logger->printf("len mismatch: available:%zd serial-read:%zd tcp-write:%zd\n", len, serial_got, tcp_sent);
}
}
}
}

+ 0
- 1
traffic_analyzer/light_control/.idea/.name View File

@ -1 +0,0 @@
untitled_0

+ 0
- 7
traffic_analyzer/light_control/.idea/misc.xml View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

+ 0
- 8
traffic_analyzer/light_control/.idea/modules.xml View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/light_control.iml" filepath="$PROJECT_DIR$/.idea/light_control.iml" />
</modules>
</component>
</project>

+ 0
- 4
traffic_analyzer/light_control/.idea/serialmonitor_settings.xml View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SerialMonitorSettings" BaudRate="9600" LineEndingsIndex="0" />
</project>

+ 0
- 6
traffic_analyzer/light_control/.idea/vcs.xml View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

+ 0
- 200
traffic_analyzer/light_control/.idea/workspace.xml View File

@ -1,200 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
<generated>
<config projectName="untitled_0" targetName="untitled_0" />
<config projectName="untitled_0" targetName="uno_CORE" />
<config projectName="untitled_0" targetName="untitled_0-size" />
</generated>
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="49f3af82-9ae9-47e3-bda3-caf0b729cc16" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../master_app/pom.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../sender.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sender.py" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/light_control.ino">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2079">
<caret column="20" selection-start-column="20" selection-end-column="20" />
<folding>
<element signature="e#1644#1716#0" expanded="true" />
<element signature="e#1739#1800#0" expanded="true" />
<element signature="e#2225#2475#0" expanded="true" />
<element signature="e#2817#2929#0" expanded="true" />
<element signature="e#4794#5445#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/light_control.ino" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="260" />
<option name="y" value="47" />
<option name="width" value="1400" />
<option name="height" value="987" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="untitled_0" type="b2602c69:ProjectViewProjectNode" />
<item name="light_control" type="47feb1d3:ProjectViewModuleNode" />
</path>
<path>
<item name="untitled_0" type="b2602c69:ProjectViewProjectNode" />
<item name="light_control" type="47feb1d3:ProjectViewModuleNode" />
<item name="light_control" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="CMake Application.untitled_0">
<configuration name="uno_CORE" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="untitled_0" TARGET_NAME="uno_CORE" CONFIG_NAME="Debug">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="untitled_0-size" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="untitled_0" TARGET_NAME="untitled_0-size" CONFIG_NAME="Debug">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="untitled_0" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="untitled_0" TARGET_NAME="untitled_0" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="untitled_0" RUN_TARGET_NAME="untitled_0">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="CMake Application.uno_CORE" />
<item itemvalue="CMake Application.untitled_0" />
<item itemvalue="CMake Application.untitled_0-size" />
</list>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="49f3af82-9ae9-47e3-bda3-caf0b729cc16" name="Default Changelist" comment="" />
<created>1558953945551</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1558953945551</updated>
<workItem from="1558953946800" duration="81000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="81000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1920" height="1031" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.18036287" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Serial Monitor" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="CMake" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="make" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/light_control.ino">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2079">
<caret column="20" selection-start-column="20" selection-end-column="20" />
<folding>
<element signature="e#1644#1716#0" expanded="true" />
<element signature="e#1739#1800#0" expanded="true" />
<element signature="e#2225#2475#0" expanded="true" />
<element signature="e#2817#2929#0" expanded="true" />
<element signature="e#4794#5445#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

+ 0
- 190
traffic_analyzer/light_control/light_control.ino View File

@ -1,190 +0,0 @@
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <algorithm> // std::min
#ifndef STASSID
#define STASSID "ZyXEL5500bT5"
#define STAPSK "eBusgxczl5"
#endif
/*
SWAP_PINS:
0: use Serial1 for logging (legacy example)
1: configure Hardware Serial port on RX:GPIO13 TX:GPIO15
and use SoftwareSerial for logging on
standard Serial pins RX:GPIO3 and TX:GPIO1
*/
#define SWAP_PINS 0
/*
SERIAL_LOOPBACK
0: normal serial operations
1: RX-TX are internally connected (loopback)
*/
#define SERIAL_LOOPBACK 0
#define BAUD_SERIAL 115200
#define BAUD_LOGGER 115200
#define RXBUFFERSIZE 1024
////////////////////////////////////////////////////////////
#if SERIAL_LOOPBACK
#undef BAUD_SERIAL
#define BAUD_SERIAL 3000000
#include <esp8266_peri.h>
#endif
#if SWAP_PINS
#include <SoftwareSerial.h>
SoftwareSerial* logger = nullptr;
#else
#define logger (&Serial1)
#endif
#define STACK_PROTECTOR 512 // bytes
//how many clients should be able to telnet to this ESP8266
#define MAX_SRV_CLIENTS 2
const char* ssid = STASSID;
const char* password = STAPSK;
const int port = 23;
WiFiServer server(port);
WiFiClient serverClients[MAX_SRV_CLIENTS];
void setup() {
Serial.begin(BAUD_SERIAL);
Serial.setRxBufferSize(RXBUFFERSIZE);
#if SWAP_PINS
Serial.swap();
// Hardware serial is now on RX:GPIO13 TX:GPIO15
// use SoftwareSerial on regular RX(3)/TX(1) for logging
logger = new SoftwareSerial(3, 1);
logger->begin(BAUD_LOGGER);
logger->println("\n\nUsing SoftwareSerial for logging");
#else
logger->begin(BAUD_LOGGER);
logger->println("\n\nUsing Serial1 for logging");
#endif
logger->println(ESP.getFullVersion());
logger->printf("Serial baud: %d (8n1: %d KB/s)\n", BAUD_SERIAL, BAUD_SERIAL * 8 / 10 / 1024);
logger->printf("Serial receive buffer size: %d bytes\n", RXBUFFERSIZE);
#if SERIAL_LOOPBACK
USC0(0) |= (1 << UCLBE); // incomplete HardwareSerial API
logger->println("Serial Internal Loopback enabled");
#endif
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
logger->print("\nConnecting to ");
logger->println(ssid);
while (WiFi.status() != WL_CONNECTED) {
logger->print('.');
delay(500);
}
logger->println();
logger->print("connected, address=");
logger->println(WiFi.localIP());
//start server
server.begin();
server.setNoDelay(true);
logger->print("Ready! Use 'telnet ");
logger->print(WiFi.localIP());
logger->printf(" %d' to connect\n", port);
}
void loop() {
//check if there are any new clients
if (server.hasClient()) {
//find free/disconnected spot
int i;
for (i = 0; i < MAX_SRV_CLIENTS; i++)
if (!serverClients[i]) { // equivalent to !serverClients[i].connected()
serverClients[i] = server.available();
logger->print("New client: index ");
logger->print(i);
break;
}
//no free/disconnected spot so reject
if (i == MAX_SRV_CLIENTS) {
server.available().println("busy");
// hints: server.available() is a WiFiClient with short-term scope
// when out of scope, a WiFiClient will
// - flush() - all data will be sent
// - stop() - automatically too
logger->printf("server is busy with %d active connections\n", MAX_SRV_CLIENTS);
}
}
//check TCP clients for data
#if 1
// Incredibly, this code is faster than the bufferred one below - #4620 is needed
// loopback/3000000baud average 348KB/s
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
while (serverClients[i].available() && Serial.availableForWrite() > 0) {
// working char by char is not very efficient
Serial.write(serverClients[i].read());
}
#else
// loopback/3000000baud average: 312KB/s
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
while (serverClients[i].available() && Serial.availableForWrite() > 0) {
size_t maxToSerial = std::min(serverClients[i].available(), Serial.availableForWrite());
maxToSerial = std::min(maxToSerial, (size_t)STACK_PROTECTOR);
uint8_t buf[maxToSerial];
size_t tcp_got = serverClients[i].read(buf, maxToSerial);
size_t serial_sent = Serial.write(buf, tcp_got);
if (serial_sent != maxToSerial) {
logger->printf("len mismatch: available:%zd tcp-read:%zd serial-write:%zd\n", maxToSerial, tcp_got, serial_sent);
}
}
#endif
// determine maximum output size "fair TCP use"
// client.availableForWrite() returns 0 when !client.connected()
size_t maxToTcp = 0;
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
if (serverClients[i]) {
size_t afw = serverClients[i].availableForWrite();
if (afw) {
if (!maxToTcp) {
maxToTcp = afw;
} else {
maxToTcp = std::min(maxToTcp, afw);
}
} else {
// warn but ignore congested clients
logger->println("one client is congested");
}
}
//check UART for data
size_t len = std::min((size_t)Serial.available(), maxToTcp);
len = std::min(len, (size_t)STACK_PROTECTOR);
if (len) {
uint8_t sbuf[len];
size_t serial_got = Serial.readBytes(sbuf, len);
// push UART data to all connected telnet clients
for (int i = 0; i < MAX_SRV_CLIENTS; i++)
// if client.availableForWrite() was 0 (congested)
// and increased since then,
// ensure write space is sufficient:
if (serverClients[i].availableForWrite() >= serial_got) {
size_t tcp_sent = serverClients[i].write(sbuf, serial_got);
if (tcp_sent != len) {
logger->printf("len mismatch: available:%zd serial-read:%zd tcp-write:%zd\n", len, serial_got, tcp_sent);
}
}
}
}

+ 12
- 0
traffic_analyzer/traffic_analyzer.iml View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="renderExternalDocumentation" value="true" />
</component>
</module>

Loading…
Cancel
Save