diff --git a/README.md b/README.md index 98489ce..50d7a7d 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,56 @@ +1. [Mabasej team project](#mabasej_team) +2. [App](#app) + 1. [Installation from apk](#install) +4. [Server](#server) + 1. [Install .img (RPI) server+web+computer_vision](#image-install) + 2. [Install script (DietPi, work in progress) server](#script-install) + 3. [Install manually (work in progress)](#manual-install) + 4. [Server filesystem](#server-filesystem) + 5. [filesystem.json](#filesystem) + 6. [settings.json](#settings) + # Mabasej_Team We are working on system, that will help tourists in cities to get information about city more easily. +| Part of project | State | Available for easy install | Comments | +| :-------------- | :---- | :------------------------: | :------: | +| Server | Working | 🟢 | Fully working if config is correct | +| Computer Vision Plugin | Working | 🟢 | | +| Web | Demo Working | 🟠 | | +| Android app | Working | 🟢 | 🟠manual server ip🟠 | -## Hardware -- Raspberry PI (for now tested only on rpi4. Works on rpi zero too, but it will be slow if more devices are connected) -- External/Internal WiFi antena -## Software -- python 3.9.2 compatible server with basic web interface -- Kotlin based mobile app +# App +Is programmed in android studio (kotlin) +It is based on simple interface with only few buttons, but lot of informations: +- Home- *Shows contents of the server that the user is connected to* +- Explore- *Shows all servers in list with small description and photo.* *User can acces map locations of server or all informations about server* +- Map- *Map that contains pins from all servers and user can open server info from here.* *Also it is possible to start navigation with google maps from here* +- Chat- *Users connected to same server can chat here* +- Settings- *Simple settings for theme and hidden debug menu* ## Install -Wikispot is in testing stages, but it is possible to install it using our .img file (link coming soon) based on DietPi or custom script. +Requirements: +- Android 6 and newer +- [WikiSpot.apk](https://github.com/Tucan444/Mabasej_Team/releases/tag/V1.0) + +Steps: + +1. Download `wikispot.apk` to your mobile and install it. (you will probablly need to enable installing apps from your browser) +2. After instalation open app and go to settings. +3. Click on the top right corner and debug menu should show up. +4. Change ip to your server ip and chose `CHANGE URL` +5. Chose `Home` menu and you should see your server. + +⚠️ Because of android limitations we were not able to do automatic connection, but we are working on workaround ⚠️ + + + +# Server +Wikispot is in testing stages, but it is possible to install it using our [.img file](https://github.com/Tucan444/Mabasej_Team/releases/tag/V1.0) based on DietPi or custom script. | Device | Server compatible | Instalation | | :-------------------- | :------------------------------------------------------------------------------------------ | :-----------: | -| Ubuntu (I7, 16GB ram) | :heavy_check_mark: WORKING (Only server) | Manual/script | +| Ubuntu (I7, 16GB ram) | :heavy_check_mark: WORKING (Only server automated setup) | Manual/script | | RPI 4b (2GB) | :heavy_check_mark: WORKING | .img/script | | RPI 400 (4GB) | :grey_question: Untested. Should work. | .img/script | | RPI 3b+ | :grey_question: Untested. Should work. | .img/script | @@ -23,17 +59,18 @@ Wikispot is in testing stages, but it is possible to install it using our .img f | RPI | :question: Untested. | :x: | -### Fresh istall (.img) Only RPI +## image install + login credentials > login: dietpi -> password: WikiSpot2021 +> password: WikiSpot requirements: -1. WikiSpot image file (download: *soon*) +1. [WikiSpot image file](https://github.com/Tucan444/Mabasej_Team/releases/tag/V1.0) 2. MicroSd card (recommended: >=16GB, :exclamation: ALL DATA STORED ON SD CARD WILL BE FORMATED :exclamation:) -3. BalenaEtcher (or another sd card flasher) *link:* https://www.balena.io/etcher/ +3. [BalenaEtcher](https://www.balena.io/etcher/) (or another sd card flasher) *link:* https://www.balena.io/etcher/ 4. SD card reader @@ -54,15 +91,16 @@ Install: 8. Done you can start using WikiSpot and edit contents of WikiSpot with our app (*coming soon*) -### Script install +## Script install *coming soon* -### Manual install +## Manual install *coming soon* ## Server filesystem +Tree view of server ``` └── test_directory @@ -85,6 +123,7 @@ Install: ### filesystem +File: `filesystem.json` ``` { @@ -120,7 +159,8 @@ and add record for file into `files` list in `filesystem.json`. :exclamation:do ``` -### settings.json +### settings +File: `settings.json` ``` { diff --git a/new new files/files/Jedálny lístok.pdf b/new new files/files/Jedálny lístok.pdf new file mode 100644 index 0000000..b2f9a3b Binary files /dev/null and b/new new files/files/Jedálny lístok.pdf differ diff --git a/new new files/files/Podrobnosti.txt b/new new files/files/Podrobnosti.txt new file mode 100644 index 0000000..d01f545 --- /dev/null +++ b/new new files/files/Podrobnosti.txt @@ -0,0 +1,22 @@ +Vybavenie + +Šatňa - áno +Vlastné parkovisko - áno +Televízor - áno + +Pre rodiny s deťmi + +Detské stoličky - áno +detský kútik - áno + +Služby + +Čapované pivo - áno +Organizovanie spoločenských podujatí – áno +Koktail bar - áno + +Kontakt + +Adresa: Dlhá 58 , 095 01 Senica +Telefón: +421 +Email: restauracia.kojda@gmail.com \ No newline at end of file diff --git a/new new files/files/restaurant_in.jpg b/new new files/files/restaurant_in.jpg new file mode 100644 index 0000000..9442184 Binary files /dev/null and b/new new files/files/restaurant_in.jpg differ diff --git a/new new files/files/restaurant_out.jpg b/new new files/files/restaurant_out.jpg new file mode 100644 index 0000000..a3b1ab2 Binary files /dev/null and b/new new files/files/restaurant_out.jpg differ diff --git a/new new files/files1/Cenník.pdf b/new new files/files1/Cenník.pdf new file mode 100644 index 0000000..f5fb310 Binary files /dev/null and b/new new files/files1/Cenník.pdf differ diff --git a/new new files/files1/Podrobnosti.txt b/new new files/files1/Podrobnosti.txt new file mode 100644 index 0000000..e857edd --- /dev/null +++ b/new new files/files1/Podrobnosti.txt @@ -0,0 +1,17 @@ +Otváracie hodiny: +PON-PIA: 09:00 - 17:00 +SOB: zatvorené +NED: 10:00-16:00 + +13:00-13:30 (obedná prestávka) + +- Predaj doplnkového tovaru +- Výmena peňazí +- Telekomunikačné služby +- predplatné novín a časopisov + +Kontakt + +Adresa: Športovcov 7212, 017 01 Považská Bystrica +Telefón: 0918 221 189 +email: slovenska.posta@gmail.com \ No newline at end of file diff --git a/new new files/files1/post_out.jpg b/new new files/files1/post_out.jpg new file mode 100644 index 0000000..9d67469 Binary files /dev/null and b/new new files/files1/post_out.jpg differ diff --git a/new new files/files1/posta_in.jpg b/new new files/files1/posta_in.jpg new file mode 100644 index 0000000..213a646 Binary files /dev/null and b/new new files/files1/posta_in.jpg differ diff --git a/new new files/files2/Bazény a cenník.pdf b/new new files/files2/Bazény a cenník.pdf new file mode 100644 index 0000000..d315fc7 Binary files /dev/null and b/new new files/files2/Bazény a cenník.pdf differ diff --git a/new new files/files2/Služby a kontakt.txt b/new new files/files2/Služby a kontakt.txt new file mode 100644 index 0000000..2f7eba0 --- /dev/null +++ b/new new files/files2/Služby a kontakt.txt @@ -0,0 +1,23 @@ +Služby + +- Plavecký bazén +- Relaxačný bazén +- Detský bazén + +Sauna + +- fínska +- ruská +- turecká +- bylinková +- infra sauna + + +- Masáže + +Kontakt + +Adresa: Mládežnícka 12, +017 01 Považská Bystrica + +Telefón: 032/221 52 97 \ No newline at end of file diff --git a/new new files/files2/plavaren_in.jpg b/new new files/files2/plavaren_in.jpg new file mode 100644 index 0000000..4e98241 Binary files /dev/null and b/new new files/files2/plavaren_in.jpg differ diff --git a/new new files/files2/plavaren_out.jpg b/new new files/files2/plavaren_out.jpg new file mode 100644 index 0000000..651e261 Binary files /dev/null and b/new new files/files2/plavaren_out.jpg differ diff --git a/new new files/files3/Cenník.pdf b/new new files/files3/Cenník.pdf new file mode 100644 index 0000000..27c6121 Binary files /dev/null and b/new new files/files3/Cenník.pdf differ diff --git a/new new files/files3/Náhľad.pdf b/new new files/files3/Náhľad.pdf new file mode 100644 index 0000000..68fbe1c Binary files /dev/null and b/new new files/files3/Náhľad.pdf differ diff --git a/new new files/files3/muzeum_in.jpg b/new new files/files3/muzeum_in.jpg new file mode 100644 index 0000000..7d330f4 Binary files /dev/null and b/new new files/files3/muzeum_in.jpg differ diff --git a/new new files/files3/muzeum_out.jpg b/new new files/files3/muzeum_out.jpg new file mode 100644 index 0000000..adf6ee0 Binary files /dev/null and b/new new files/files3/muzeum_out.jpg differ diff --git a/new new files/files4/Podrobnosti.txt b/new new files/files4/Podrobnosti.txt new file mode 100644 index 0000000..d1526f6 --- /dev/null +++ b/new new files/files4/Podrobnosti.txt @@ -0,0 +1,18 @@ +Služby na stanici: + +- Bezplatné parkovanie +- Poistenie na počkanie +- Predaj cestovných lístkov +- Predaj miesteniek +- Rezervácie +- Predaj žrebov Niké + +Kontakt + +Adresa: Zámostie, 017 01 Považská Bystrica + +Telefón +Slovensko: 18 188 +Zo zahraničia: +421 24 28 54 182 + +info@slovakrail.sk \ No newline at end of file diff --git a/new new files/files4/Zľavy.pdf b/new new files/files4/Zľavy.pdf new file mode 100644 index 0000000..81b0ac2 Binary files /dev/null and b/new new files/files4/Zľavy.pdf differ diff --git a/new new files/files4/zeleznicna_stanica_in.jpg b/new new files/files4/zeleznicna_stanica_in.jpg new file mode 100644 index 0000000..4bac6ff Binary files /dev/null and b/new new files/files4/zeleznicna_stanica_in.jpg differ diff --git a/new new files/files4/zeleznicna_stanica_out.jpg b/new new files/files4/zeleznicna_stanica_out.jpg new file mode 100644 index 0000000..c6e891f Binary files /dev/null and b/new new files/files4/zeleznicna_stanica_out.jpg differ diff --git a/new new files/filesystem.json b/new new files/filesystem.json new file mode 100644 index 0000000..7225978 --- /dev/null +++ b/new new files/filesystem.json @@ -0,0 +1,24 @@ +{ + "ID": 0, + "location": "49.14178021389778,18.353783098441415", + "description": { + "title": "Reštaurácia pod slivkou", + "description_s": "Otvorené", + "description_l": "Otváracie hodiny:\nPON-PIA: 09:00 - 22:00\nSOB: zatvorené\nNED: 14:00-21:00", + "photo_s": "restaurant_out.jpg", + "photo_b": "restaurant_in.jpg", + "email": "restauracia.podslivkou@gmail.com", + "phone_number": "0928229120" + }, + "files": [ + { + "name": "Podrobnosti", + "format": ".txt", + "description": "Vybavenie, služby a kontakt" + }, { + "name": "Jedálny lístok", + "format": ".pdf", + "description": "" + } + ] +} diff --git a/new new files/filesystem1.json b/new new files/filesystem1.json new file mode 100644 index 0000000..323552f --- /dev/null +++ b/new new files/filesystem1.json @@ -0,0 +1,24 @@ +{ + "ID": 1, + "location": "49.095721799569304, 18.47399399775766", + "description": { + "title": "Slovenská pošta", + "description_s": "Otvorené", + "description_l": "Otváracie hodiny:\nPON-PIA: 09:00 - 17:00\nSOB: zatvorené\nNED: 10:00-16:00", + "photo_s": "post_out.jpg", + "photo_b": "post_in.jpg", + "email": "slovenska.posta@gmail.com", + "phone_number": "0918221189" + }, + "files1": [ + { + "name": "Podrobnosti", + "format": ".txt", + "description": "" + }, { + "name": "Cenník", + "format": ".pdf", + "description": "" + } + ] +} diff --git a/new new files/filesystem2.json b/new new files/filesystem2.json new file mode 100644 index 0000000..d3e0199 --- /dev/null +++ b/new new files/filesystem2.json @@ -0,0 +1,24 @@ +{ + "ID": 2, + "location": "49.14437583832675, 18.466946907073503", + "description": { + "title": "Mestská plaváreň", + "description_s": "Otvorené", + "description_l": "Otvorené nonstop\nOtváracie doby sa počas sviatkov môžu líšiť", + "photo_s": "plavaren_out.jpg", + "photo_b": "plavaren_in.jpg", + "email": "", + "phone_number": "0322215297" + }, + "files2": [ + { + "name": "Služby a kontakt", + "format": ".txt", + "description": "" + }, { + "name": "Fotogaléria a cenník", + "format": ".pdf", + "description": "" + } + ] +} diff --git a/new new files/filesystem3.json b/new new files/filesystem3.json new file mode 100644 index 0000000..c04f35d --- /dev/null +++ b/new new files/filesystem3.json @@ -0,0 +1,24 @@ +{ + "ID": 3, + "location": "49.10101907820781, 18.440001048091226", + "description": { + "title": "Považsko Bystrické Múzeum", + "description_s": "Otvorené", + "description_l": "Otváracie hodiny:\nUT-PIA: 08:00 - 16:00", + "photo_s": "muzeum_out.jpg", + "photo_b": "muzeum_in.jpg", + "email": "pbmuzeum@gmail.com", + "phone_number": "0971294689" + }, + "files3": [ + { + "name": "Cenník", + "format": ".pdf", + "description": "" + }, { + "name": "Náhľad", + "format": ".pdf", + "description": "Nahľiadnite do expozície múzea" + } + ] +} diff --git a/new new files/filesystem4.json b/new new files/filesystem4.json new file mode 100644 index 0000000..3979635 --- /dev/null +++ b/new new files/filesystem4.json @@ -0,0 +1,24 @@ +{ + "ID": 4, + "location": "49.12230758939453, 18.43195784744756", + "description": { + "title": "Železničná stanica", + "description_s": "Otvorené", + "description_l": "Otváracie hodiny:\nnonstop", + "photo_s": "zeleznicna_stanica_out.jpg", + "photo_b": "zeleznicna_stanica_in.jpg", + "email": "info@slovakrail.sk", + "phone_number": "" + }, + "files4": [ + { + "name": "Podrobnosti", + "format": ".txt", + "description": "" + }, { + "name": "Zľavy", + "format": ".pdf", + "description": "" + } + ] +} diff --git a/server/cache/1/test.jpg b/server/cache/1/test.jpg deleted file mode 100644 index 7777c36..0000000 Binary files a/server/cache/1/test.jpg and /dev/null differ diff --git a/server/main.py b/server/main.py index 743d05d..243c395 100644 --- a/server/main.py +++ b/server/main.py @@ -58,8 +58,6 @@ IP = get_my_ip() ID = filesystem["ID"] location = filesystem["location"] time_to_save = settings["time_to_save"] -settings["location"] -settings["ID"] app = FastAPI() # init of FastAPI origins = ["*", ] @@ -90,7 +88,14 @@ if ID not in heartbeat_table["ID"]: heartbeat_table["location"].append(location) heartbeat_table["file_system"].append(filesystem) heartbeat_table["last_heartbeat"].append(time_to_heartbeat) +else: + index_server_run = heartbeat_table["ID"].index(ID) + heartbeat_table["IP"][index_server_run] = IP + heartbeat_table["location"][index_server_run] = location + heartbeat_table["file_system"][index_server_run] = filesystem + heartbeat_table["last_heartbeat"][index_server_run] = time_to_heartbeat +heartbeat_table["my_ip"] = IP class ServerTable(BaseModel): # table of content for heartbeat request ID: list @@ -98,6 +103,7 @@ class ServerTable(BaseModel): # table of content for heartbeat request location: list file_system: list last_heartbeat: list + my_ip: str class Sensor(BaseModel): @@ -117,7 +123,8 @@ def read_root(): @app.post("/heartbeat") def heartbeat(s_table: ServerTable, request: Request): - log.message(f"server requested heartbeat {request.client.host}:{request.client.port}") + global heartbeat_table + log.message(f"server requested heartbeat {s_table.my_ip}:{request.client.port}") log.debug(f"Recieved server table: {s_table}") try: @@ -133,8 +140,8 @@ def heartbeat(s_table: ServerTable, request: Request): elif server_id == ID: log.debug(f"Updated my heartbeat from {s_table.last_heartbeat[position]} to {time_to_heartbeat}") heartbeat_table["last_heartbeat"][heartbeat_table["ID"].index(ID)] = time_to_heartbeat - else: - log.message(f"Heartbeat from new server:\n ID: {server_id} IP: {request.client}") + elif server_id not in heartbeat_table["ID"]: + log.message(f"Heartbeat from new server:\n ID: {server_id} IP: {s_table.my_ip}") heartbeat_table["ID"].append(int(s_table.ID[position])) heartbeat_table["IP"].append(s_table.IP[position]) heartbeat_table["location"].append(s_table.location[position]) @@ -143,10 +150,12 @@ def heartbeat(s_table: ServerTable, request: Request): log.debug(f"Created {server_id}`s heartbeat: {s_table.last_heartbeat[position]}") except Exception as error: log.error(f"heartbeat > {error}") - - if heartbeat_table["ID"][heartbeat_table["IP"].index(request.client.host)] in offline: - offline.remove(heartbeat_table["ID"][heartbeat_table["IP"].index(request.client.host)]) - log.warning(f"{request.client.host} gone online") + try: + if heartbeat_table["ID"][heartbeat_table["IP"].index(s_table.my_ip)] in offline: + offline.remove(heartbeat_table["ID"][heartbeat_table["IP"].index(s_table.my_ip)]) + log.warning(f"{s_table.my_ip} gone online") + except Exception as error: + log.error(f"heartbeat > {error}") return heartbeat_table, {"ID": ID, "file_system": filesystem, "location": location} @@ -170,7 +179,6 @@ def get_sensors(IDx: int, request: Request): @app.get("/files/{IDx}/{file}") def get_file(IDx: int, file: str, request: Request): log.debug(f"""{request.client} requested {file} from {"this server" if IDx == ID else f"id {IDx}"}""") - server_ip = heartbeat_table["IP"][heartbeat_table["ID"].index(IDx)] if IDx == ID: if os.path.isfile(f"files/{file}"): return FileResponse(f"files/{file}") @@ -181,6 +189,7 @@ def get_file(IDx: int, file: str, request: Request): log.warning(f"{request.client} tried to access id ({IDx}) that does not exist.") return f"ERROR: {IDx} does not exist." else: + server_ip = heartbeat_table["IP"][heartbeat_table["ID"].index(IDx)] if os.path.isdir(f"cache/{IDx}"): if os.path.isfile(f"cache/{IDx}/{file}"): with open(f"cache/{IDx}/{file}", "rb") as compared_file: @@ -213,7 +222,7 @@ def get_file(IDx: int, file: str, request: Request): @app.post("/{IDx}/update_sensor") def update_sensors(data: Sensor, request: Request, IDx: int): global sensors - if IDx == ID: + if IDx == ID or IDx == -1: if data.name in sensors: if not data.value: log.message(f"{request.client.host} removed sensor {data.name}") @@ -225,10 +234,12 @@ def update_sensors(data: Sensor, request: Request, IDx: int): log.warning(f"{request.client} created new sensor.\n SENSOR: {data}") sensors[data.name] = data.value return f"Successfuly made new sensor" - else: + elif IDx in heartbeat_table["ID"]: r = requests.post(f"""http://{heartbeat_table["IP"][heartbeat_table["ID"].index(IDx)]}:8000/{IDx}/update_sensor""", json={"name": data.name, "value": data.value}) return r.text + else: + return f"ERROR: server {IDx} does not exist." @app.get("/compare/{file}") diff --git a/websites/.vscode/launch.json b/website/.vscode/launch.json similarity index 100% rename from websites/.vscode/launch.json rename to website/.vscode/launch.json diff --git a/website/BUTTON-d-5.png b/website/BUTTON-d-5.png new file mode 100644 index 0000000..37adbc6 Binary files /dev/null and b/website/BUTTON-d-5.png differ diff --git a/website/GitHub-Mark-64px.png b/website/GitHub-Mark-64px.png new file mode 100644 index 0000000..182a1a3 Binary files /dev/null and b/website/GitHub-Mark-64px.png differ diff --git a/website/GitHub-Mark-Light-32px.png b/website/GitHub-Mark-Light-32px.png new file mode 100644 index 0000000..628da97 Binary files /dev/null and b/website/GitHub-Mark-Light-32px.png differ diff --git a/website/GitHub-Mark-Light-64px.png b/website/GitHub-Mark-Light-64px.png new file mode 100644 index 0000000..73db1f6 Binary files /dev/null and b/website/GitHub-Mark-Light-64px.png differ diff --git a/website/WikiSpot.html b/website/WikiSpot.html new file mode 100644 index 0000000..c27921b --- /dev/null +++ b/website/WikiSpot.html @@ -0,0 +1,39 @@ + + +
+