diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88dc5c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.import/ +SCREENSHOTS/*.import +.git +export_presets.cfg \ No newline at end of file diff --git a/ArduinoWiFi.apk b/ArduinoWiFi.apk new file mode 100644 index 0000000..45de0c5 Binary files /dev/null and b/ArduinoWiFi.apk differ diff --git a/app_icon.png b/app_icon.png deleted file mode 100644 index 77db9f0..0000000 Binary files a/app_icon.png and /dev/null differ diff --git a/app_icon.png.import b/app_icon.png.import deleted file mode 100644 index 242022f..0000000 --- a/app_icon.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/app_icon.png-f349b850a0f29361cfbcb17623f8bdde.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://app_icon.png" -dest_files=[ "res://.import/app_icon.png-f349b850a0f29361cfbcb17623f8bdde.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/avatar.png b/avatar.png deleted file mode 100644 index a6e263a..0000000 Binary files a/avatar.png and /dev/null differ diff --git a/readme.md b/readme.md index 6df8737..6e17867 100644 --- a/readme.md +++ b/readme.md @@ -5,8 +5,11 @@ ## Descrizione -Codice sorgente relativo all'app "Arduino WiFi" realizzata con Godot Engine. +L'app permette di interfacciarsi facilmente al proprio modulo WiFi ESP8266 semplicemente inserendo l'inidirizzo IP relativo al webserver che si sta hostando con il modulo. +Video dimostrativo: +https://www.youtube.com/watch?v=eF6DH4lLp3U&feature=youtu.be -L'app permette di interfacciarsi facilmente al proprio modulo WiFi ESP8266 semplicemente inserendo l'inidirizzo IP relativo al webserver che si sta hostando con il modulo. +- [Codice Sorgente](https://github.com/fenix-hub/arduino-esp8266/tree/source-code) +- [Versione Android (questa)](https://github.com/fenix-hub/arduino-esp8266/tree/android-apk) -[video](https://www.youtube.com/watch?v=eF6DH4lLp3U) +![gd](https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Godot_logo.svg/1200px-Godot_logo.svg.png) ![ard](https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/Arduino_Logo.svg/1280px-Arduino_Logo.svg.png) \ No newline at end of file diff --git a/resources/fonts/ARLRDBD.TTF b/resources/fonts/ARLRDBD.TTF deleted file mode 100644 index 20b92a2..0000000 Binary files a/resources/fonts/ARLRDBD.TTF and /dev/null differ diff --git a/resources/fonts/new_dynamicfont.tres b/resources/fonts/new_dynamicfont.tres deleted file mode 100644 index 0d3dda9..0000000 --- a/resources/fonts/new_dynamicfont.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="DynamicFont" load_steps=2 format=2] - -[ext_resource path="res://resources/fonts/ARLRDBD.TTF" type="DynamicFontData" id=1] - -[resource] -size = 40 -font_data = ExtResource( 1 ) diff --git a/resources/imgs/720px-Arduino_Logo.svg.png b/resources/imgs/720px-Arduino_Logo.svg.png deleted file mode 100644 index 7acc485..0000000 Binary files a/resources/imgs/720px-Arduino_Logo.svg.png and /dev/null differ diff --git a/resources/imgs/Background(2).png b/resources/imgs/Background(2).png deleted file mode 100644 index 766e00d..0000000 Binary files a/resources/imgs/Background(2).png and /dev/null differ diff --git a/resources/imgs/Background(2).png.import b/resources/imgs/Background(2).png.import deleted file mode 100644 index 8354e0e..0000000 --- a/resources/imgs/Background(2).png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/Background(2).png-91d0c2361767282ec8bc16b9377f73a6.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resources/imgs/Background(2).png" -dest_files=[ "res://.import/Background(2).png-91d0c2361767282ec8bc16b9377f73a6.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/resources/imgs/Path 0.png b/resources/imgs/Path 0.png deleted file mode 100644 index 4ab6b4b..0000000 Binary files a/resources/imgs/Path 0.png and /dev/null differ diff --git a/resources/imgs/Path 0.png.import b/resources/imgs/Path 0.png.import deleted file mode 100644 index de55267..0000000 --- a/resources/imgs/Path 0.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/Path 0.png-63a9f13826e93352212e39e47ec8cf07.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resources/imgs/Path 0.png" -dest_files=[ "res://.import/Path 0.png-63a9f13826e93352212e39e47ec8cf07.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=false -svg/scale=1.0 diff --git a/resources/imgs/arduino-1-logo-png-transparent.png b/resources/imgs/arduino-1-logo-png-transparent.png deleted file mode 100644 index f58ba7a..0000000 Binary files a/resources/imgs/arduino-1-logo-png-transparent.png and /dev/null differ diff --git a/resources/imgs/arduino-1-logo-png-transparent.png.import b/resources/imgs/arduino-1-logo-png-transparent.png.import deleted file mode 100644 index 25e7cf8..0000000 --- a/resources/imgs/arduino-1-logo-png-transparent.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/arduino-1-logo-png-transparent.png-0402b99fc0d8c9f598b1cf407869351f.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resources/imgs/arduino-1-logo-png-transparent.png" -dest_files=[ "res://.import/arduino-1-logo-png-transparent.png-0402b99fc0d8c9f598b1cf407869351f.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=false -svg/scale=1.0 diff --git a/resources/imgs/arduino_logo.png b/resources/imgs/arduino_logo.png deleted file mode 100644 index 6cef9ea..0000000 Binary files a/resources/imgs/arduino_logo.png and /dev/null differ diff --git a/resources/imgs/arduino_logo.png.import b/resources/imgs/arduino_logo.png.import deleted file mode 100644 index 380f816..0000000 --- a/resources/imgs/arduino_logo.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/arduino_logo.png-e2eb37aeb6b54ce88099d3603f4099e2.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resources/imgs/arduino_logo.png" -dest_files=[ "res://.import/arduino_logo.png-e2eb37aeb6b54ce88099d3603f4099e2.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/resources/imgs/home-icon.png b/resources/imgs/home-icon.png deleted file mode 100644 index 635f8e3..0000000 Binary files a/resources/imgs/home-icon.png and /dev/null differ diff --git a/resources/imgs/home-icon.png.import b/resources/imgs/home-icon.png.import deleted file mode 100644 index a160a2c..0000000 --- a/resources/imgs/home-icon.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/home-icon.png-0fd180a3a0330a5eb5dd17a506619387.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resources/imgs/home-icon.png" -dest_files=[ "res://.import/home-icon.png-0fd180a3a0330a5eb5dd17a506619387.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/resources/imgs/logo.svg b/resources/imgs/logo.svg deleted file mode 100644 index ff09daf..0000000 --- a/resources/imgs/logo.svg +++ /dev/null @@ -1,2 +0,0 @@ - -image/svg+xml diff --git a/scenes/HTTPManager.tscn b/scenes/HTTPManager.tscn deleted file mode 100644 index 25097d7..0000000 --- a/scenes/HTTPManager.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://scenes/scripts/http_manager.gd" type="Script" id=1] - -[node name="HTTPManager" type="Node"] -script = ExtResource( 1 ) - -[node name="HTTPRequest" type="HTTPRequest" parent="."] - -[node name="HTTPCommand" type="HTTPRequest" parent="."] -[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"] -[connection signal="request_completed" from="HTTPCommand" to="." method="_on_HTTPCommand_request_completed"] diff --git a/scenes/MainScene.tscn b/scenes/MainScene.tscn deleted file mode 100644 index ad30d98..0000000 --- a/scenes/MainScene.tscn +++ /dev/null @@ -1,895 +0,0 @@ -[gd_scene load_steps=33 format=2] - -[ext_resource path="res://scenes/scripts/MainScene.gd" type="Script" id=1] -[ext_resource path="res://resources/imgs/arduino_logo.png" type="Texture" id=2] -[ext_resource path="res://resources/fonts/new_dynamicfont.tres" type="DynamicFont" id=3] -[ext_resource path="res://resources/fonts/ARLRDBD.TTF" type="DynamicFontData" id=4] -[ext_resource path="res://resources/imgs/Path 0.png" type="Texture" id=5] -[ext_resource path="res://scenes/scripts/status_icon.gd" type="Script" id=6] -[ext_resource path="res://scenes/scripts/moisture.gd" type="Script" id=7] -[ext_resource path="res://scenes/scripts/Tree.gd" type="Script" id=8] -[ext_resource path="res://scenes/scripts/Debug.gd" type="Script" id=9] -[ext_resource path="res://scenes/scripts/Log.gd" type="Script" id=10] -[ext_resource path="res://resources/imgs/Background(2).png" type="Texture" id=11] - -[sub_resource type="DynamicFont" id=1] -size = 30 -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=2] -size = 30 -font_data = ExtResource( 4 ) - -[sub_resource type="AtlasTexture" id=3] -flags = 4 -atlas = ExtResource( 5 ) -region = Rect2( 0, 0, 256, 256 ) -margin = Rect2( 20, 0, 20, 0 ) -filter_clip = true - -[sub_resource type="DynamicFont" id=4] -size = 30 -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=5] -size = 20 -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=6] -size = 20 -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=7] -size = 30 -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=8] -size = 20 -font_data = ExtResource( 4 ) - -[sub_resource type="StyleBoxFlat" id=9] -content_margin_left = 6.0 -content_margin_right = 5.0 -content_margin_top = 5.0 -content_margin_bottom = 5.0 -bg_color = Color( 0.195185, 0.195185, 0.216309, 1 ) -border_width_left = 2 -border_width_top = 2 -border_width_right = 2 -border_width_bottom = 2 -border_color = Color( 0.145098, 0.145098, 0.164706, 1 ) - -[sub_resource type="DynamicFont" id=10] -size = 20 -outline_color = Color( 1, 0.501961, 0, 1 ) -font_data = ExtResource( 4 ) - -[sub_resource type="DynamicFont" id=11] -size = 30 -outline_color = Color( 1, 0.501961, 0, 1 ) -font_data = ExtResource( 4 ) - -[sub_resource type="StyleBoxFlat" id=12] -content_margin_top = 5.0 -content_margin_bottom = 5.0 -bg_color = Color( 1, 1, 1, 1 ) - -[sub_resource type="StyleBoxFlat" id=13] -content_margin_top = 5.0 -content_margin_bottom = 5.0 -bg_color = Color( 0, 0.72549, 0.74902, 1 ) -border_width_top = 1 -border_color = Color( 0, 0.658824, 0.682353, 1 ) - -[sub_resource type="StyleBoxFlat" id=14] -bg_color = Color( 0, 0.592157, 0.611765, 1 ) -border_width_left = 5 -border_width_top = 5 -border_width_right = 5 -border_width_bottom = 5 -border_color = Color( 0.0142822, 0.442841, 0.457031, 1 ) -border_blend = true -corner_detail = 10 - -[sub_resource type="DynamicFont" id=15] -size = 36 -font_data = ExtResource( 4 ) - -[sub_resource type="StyleBoxFlat" id=16] -content_margin_top = 5.0 -content_margin_bottom = 5.0 -bg_color = Color( 0.806152, 0.0535336, 0.234792, 1 ) -border_width_top = 1 -border_color = Color( 0.682353, 0, 0.172549, 1 ) - -[sub_resource type="StyleBoxFlat" id=17] -bg_color = Color( 0.67451, 0, 0.164706, 1 ) -border_width_left = 5 -border_width_top = 5 -border_width_right = 5 -border_width_bottom = 5 -border_color = Color( 0.458824, 0.0156863, 0.137255, 1 ) -border_blend = true -corner_detail = 10 - -[sub_resource type="StyleBoxFlat" id=18] -content_margin_top = 5.0 -content_margin_bottom = 5.0 -bg_color = Color( 0.74902, 0, 0.180392, 1 ) -border_width_top = 1 -border_color = Color( 0.682353, 0, 0.176471, 1 ) - -[sub_resource type="DynamicFont" id=19] -size = 40 -font_data = ExtResource( 4 ) - -[sub_resource type="Animation" id=20] -length = 0.2 -tracks/0/type = "value" -tracks/0/path = NodePath("Filter:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ true ] -} -tracks/1/type = "value" -tracks/1/path = NodePath("Filter:modulate") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.2 ), -"transitions": PoolRealArray( 0.420448, 1 ), -"update": 0, -"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Menu:rect_position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.2 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ Vector2( -450, 0 ), Vector2( 0, 0 ) ] -} -tracks/3/type = "value" -tracks/3/path = NodePath("Menu:visible") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ true ] -} - -[sub_resource type="Animation" id=21] -length = 0.2 -tracks/0/type = "value" -tracks/0/path = NodePath("Filter:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0.2 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ false ] -} -tracks/1/type = "value" -tracks/1/path = NodePath("Filter:modulate") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.2 ), -"transitions": PoolRealArray( 0.659754, 1.03527 ), -"update": 0, -"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Menu:rect_position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.2 ), -"transitions": PoolRealArray( 1, 1 ), -"update": 0, -"values": [ Vector2( 0, 0 ), Vector2( -450, 0 ) ] -} -tracks/3/type = "value" -tracks/3/path = NodePath("Menu:visible") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0.2 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ false ] -} - -[node name="MainScene" type="Node"] -script = ExtResource( 1 ) - -[node name="Background" type="ColorRect" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -color = Color( 0, 0.592157, 0.611765, 1 ) - -[node name="Logo" type="TextureRect" parent="."] -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -margin_left = -50.0 -margin_top = -68.0 -margin_right = 50.0 -texture = ExtResource( 2 ) -expand = true - -[node name="DeviceChoice" type="Control" parent="."] -editor/display_folded = true -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="Label2" type="Label" parent="DeviceChoice"] -anchor_top = 0.098 -anchor_right = 1.0 -anchor_bottom = 0.144 -margin_top = -0.352005 -margin_bottom = -0.455994 -custom_fonts/font = ExtResource( 3 ) -text = "Webserver Connection" -align = 1 - -[node name="VBoxContainer" type="VBoxContainer" parent="DeviceChoice"] -anchor_left = 0.083 -anchor_top = 0.199 -anchor_right = 0.918 -anchor_bottom = 0.674 -margin_left = 0.191998 -margin_top = 0.223984 -margin_right = 0.231995 -margin_bottom = -2.17603 -custom_constants/separation = 5 -alignment = 1 - -[node name="Label" type="Label" parent="DeviceChoice/VBoxContainer"] -margin_right = 481.0 -margin_bottom = 47.0 -custom_fonts/font = ExtResource( 3 ) -text = "Webserver IP:" - -[node name="webserver_ip" type="LineEdit" parent="DeviceChoice/VBoxContainer"] -margin_top = 52.0 -margin_right = 481.0 -margin_bottom = 109.0 -custom_fonts/font = ExtResource( 3 ) -clear_button_enabled = true - -[node name="Label2" type="Label" parent="DeviceChoice/VBoxContainer"] -margin_top = 114.0 -margin_right = 481.0 -margin_bottom = 161.0 -custom_fonts/font = ExtResource( 3 ) -text = "Assign a name:" - -[node name="webserver_name" type="LineEdit" parent="DeviceChoice/VBoxContainer"] -margin_top = 166.0 -margin_right = 481.0 -margin_bottom = 223.0 -custom_fonts/font = ExtResource( 3 ) -clear_button_enabled = true - -[node name="Label4" type="Label" parent="DeviceChoice/VBoxContainer"] -margin_top = 228.0 -margin_right = 481.0 -margin_bottom = 242.0 - -[node name="HBoxContainer2" type="HBoxContainer" parent="DeviceChoice/VBoxContainer"] -margin_top = 247.0 -margin_right = 481.0 -margin_bottom = 289.0 -size_flags_vertical = 0 -alignment = 1 - -[node name="connect" type="Button" parent="DeviceChoice/VBoxContainer/HBoxContainer2"] -margin_left = 19.0 -margin_right = 219.0 -margin_bottom = 42.0 -grow_horizontal = 0 -grow_vertical = 0 -rect_min_size = Vector2( 200, 0 ) -focus_mode = 0 -size_flags_horizontal = 6 -size_flags_vertical = 6 -custom_fonts/font = SubResource( 1 ) -text = "connect" -clip_text = true - -[node name="disconnect" type="Button" parent="DeviceChoice/VBoxContainer/HBoxContainer2"] -margin_left = 261.0 -margin_right = 461.0 -margin_bottom = 42.0 -grow_horizontal = 0 -grow_vertical = 0 -rect_min_size = Vector2( 200, 0 ) -size_flags_horizontal = 6 -size_flags_vertical = 6 -custom_fonts/font = SubResource( 2 ) -text = "disconnect" -clip_text = true - -[node name="Space" type="Label" parent="DeviceChoice/VBoxContainer"] -margin_top = 294.0 -margin_right = 481.0 -margin_bottom = 391.0 -custom_fonts/font = ExtResource( 3 ) -text = " -" - -[node name="HBoxContainer" type="HBoxContainer" parent="DeviceChoice/VBoxContainer"] -margin_top = 396.0 -margin_right = 481.0 -margin_bottom = 443.0 -alignment = 1 - -[node name="Label3" type="Label" parent="DeviceChoice/VBoxContainer/HBoxContainer"] -margin_left = 77.0 -margin_right = 360.0 -margin_bottom = 47.0 -size_flags_horizontal = 4 -custom_fonts/font = ExtResource( 3 ) -text = "Device Status:" -align = 1 - -[node name="status2" type="TextureRect" parent="DeviceChoice/VBoxContainer/HBoxContainer"] -margin_left = 364.0 -margin_right = 404.0 -margin_bottom = 47.0 -rect_min_size = Vector2( 40, 40 ) -rect_clip_content = true -size_flags_horizontal = 4 -size_flags_vertical = 7 -texture = SubResource( 3 ) -expand = true -stretch_mode = 6 -script = ExtResource( 6 ) - -[node name="state_message" type="Label" parent="DeviceChoice/VBoxContainer"] -margin_left = 27.0 -margin_top = 448.0 -margin_right = 454.0 -margin_bottom = 484.0 -size_flags_horizontal = 4 -custom_fonts/font = SubResource( 4 ) -text = "no webserver to connect to..." - -[node name="DeviceManager" type="Control" parent="."] -editor/display_folded = true -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="Label" type="Label" parent="DeviceManager"] -anchor_top = 0.098 -anchor_right = 1.0 -anchor_bottom = 0.144 -margin_top = -0.352005 -margin_bottom = -0.456009 -custom_fonts/font = ExtResource( 3 ) -text = "Webserver Manager" -align = 1 - -[node name="HBoxContainer" type="HBoxContainer" parent="DeviceManager"] -anchor_top = 0.156 -anchor_right = 1.0 -anchor_bottom = 0.195 -margin_left = 73.0 -margin_top = 0.255997 -margin_right = -73.0 -margin_bottom = 0.319992 -alignment = 1 - -[node name="w_name" type="LineEdit" parent="DeviceManager/HBoxContainer"] -margin_right = 184.0 -margin_bottom = 39.0 -custom_fonts/font = SubResource( 5 ) -text = "webserver_name" -align = 1 -editable = false -expand_to_text_length = true -context_menu_enabled = false - -[node name="Label2" type="Label" parent="DeviceManager/HBoxContainer"] -margin_left = 188.0 -margin_top = 7.0 -margin_right = 194.0 -margin_bottom = 31.0 -custom_fonts/font = SubResource( 6 ) -text = ":" -align = 1 -valign = 1 - -[node name="w_ip" type="LineEdit" parent="DeviceManager/HBoxContainer"] -margin_left = 198.0 -margin_right = 346.0 -margin_bottom = 39.0 -custom_fonts/font = SubResource( 5 ) -text = "webserver_ip" -align = 1 -editable = false -expand_to_text_length = true -context_menu_enabled = false - -[node name="status" type="TextureRect" parent="DeviceManager/HBoxContainer"] -margin_left = 350.0 -margin_right = 430.0 -margin_bottom = 39.0 -rect_min_size = Vector2( 80, 0 ) -rect_clip_content = true -size_flags_vertical = 7 -texture = SubResource( 3 ) -expand = true -stretch_mode = 6 -script = ExtResource( 6 ) - -[node name="VBoxContainer" type="VBoxContainer" parent="DeviceManager"] -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -margin_top = -194.0 -margin_bottom = -76.0 -custom_constants/separation = 20 -alignment = 1 - -[node name="HBoxContainer2" type="HBoxContainer" parent="DeviceManager/VBoxContainer"] -margin_right = 576.0 -margin_bottom = 57.0 -size_flags_horizontal = 7 -alignment = 1 - -[node name="moisture" type="LineEdit" parent="DeviceManager/VBoxContainer/HBoxContainer2"] -margin_left = 150.0 -margin_right = 280.0 -margin_bottom = 57.0 -size_flags_horizontal = 4 -custom_fonts/font = ExtResource( 3 ) -text = "---" -align = 1 -editable = false -expand_to_text_length = true -script = ExtResource( 7 ) - -[node name="moisture_btn" type="CheckBox" parent="DeviceManager/VBoxContainer/HBoxContainer2"] -margin_left = 284.0 -margin_right = 426.0 -margin_bottom = 57.0 -size_flags_horizontal = 4 -custom_fonts/font = SubResource( 7 ) -text = "Umidità" - -[node name="HBoxContainer3" type="HBoxContainer" parent="DeviceManager/VBoxContainer"] -margin_top = 77.0 -margin_right = 576.0 -margin_bottom = 121.0 -size_flags_horizontal = 7 -alignment = 1 - -[node name="led1" type="CheckButton" parent="DeviceManager/VBoxContainer/HBoxContainer3"] -margin_left = 125.0 -margin_right = 286.0 -margin_bottom = 44.0 -size_flags_horizontal = 4 -custom_fonts/font = SubResource( 7 ) -text = "Led 1" - -[node name="led2" type="CheckButton" parent="DeviceManager/VBoxContainer/HBoxContainer3"] -margin_left = 290.0 -margin_right = 451.0 -margin_bottom = 44.0 -size_flags_horizontal = 4 -custom_fonts/font = SubResource( 7 ) -text = "Led 2" - -[node name="WebServerList" type="Control" parent="."] -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="Label" type="Label" parent="WebServerList"] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -158.0 -margin_top = -412.0 -margin_right = 165.0 -margin_bottom = -365.0 -custom_fonts/font = ExtResource( 3 ) -text = "Webserver List" -align = 1 - -[node name="HBoxContainer" type="HBoxContainer" parent="WebServerList"] -editor/display_folded = true -anchor_top = 0.176 -anchor_right = 1.0 -anchor_bottom = 0.199 -margin_left = 48.0 -margin_top = -0.224014 -margin_right = -47.0 -margin_bottom = 0.223984 -grow_horizontal = 2 -alignment = 1 - -[node name="Label" type="Label" parent="WebServerList/HBoxContainer"] -margin_right = 131.0 -margin_bottom = 24.0 -size_flags_horizontal = 6 -custom_fonts/font = SubResource( 8 ) -text = "Webserver ip" -align = 1 -valign = 1 - -[node name="sep" type="Label" parent="WebServerList/HBoxContainer"] -margin_left = 135.0 -margin_right = 141.0 -margin_bottom = 24.0 -size_flags_horizontal = 6 -custom_fonts/font = SubResource( 8 ) -text = "|" -align = 1 -valign = 1 - -[node name="Label2" type="Label" parent="WebServerList/HBoxContainer"] -margin_left = 145.0 -margin_right = 312.0 -margin_bottom = 24.0 -size_flags_horizontal = 6 -custom_fonts/font = SubResource( 8 ) -text = "Webserver name" -align = 1 -valign = 1 - -[node name="sep2" type="Label" parent="WebServerList/HBoxContainer"] -margin_left = 316.0 -margin_right = 322.0 -margin_bottom = 24.0 -size_flags_horizontal = 6 -custom_fonts/font = SubResource( 8 ) -text = "|" -align = 1 -valign = 1 - -[node name="Label3" type="Label" parent="WebServerList/HBoxContainer"] -margin_left = 326.0 -margin_right = 481.0 -margin_bottom = 24.0 -size_flags_horizontal = 6 -custom_fonts/font = SubResource( 8 ) -text = "Last connection" -align = 1 -valign = 1 - -[node name="Tree" type="Tree" parent="WebServerList"] -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -margin_left = 50.0 -margin_top = -302.0 -margin_right = -50.0 -margin_bottom = 368.0 -size_flags_horizontal = 6 -columns = 3 -hide_root = true -select_mode = 1 -script = ExtResource( 8 ) - -[node name="Debug" type="Control" parent="."] -editor/display_folded = true -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 -script = ExtResource( 9 ) - -[node name="Label2" type="Label" parent="Debug"] -anchor_top = 0.098 -anchor_right = 1.0 -anchor_bottom = 0.144 -margin_top = -0.352005 -margin_bottom = -0.456009 -custom_fonts/font = ExtResource( 3 ) -text = "Webserver Debug" -align = 1 - -[node name="RichTextLabel" type="RichTextLabel" parent="Debug"] -anchor_left = 0.057 -anchor_top = 0.156 -anchor_right = 0.943 -anchor_bottom = 0.908 -margin_left = 0.167999 -margin_top = 0.255997 -margin_right = -0.16803 -margin_bottom = 0.207947 -custom_styles/normal = SubResource( 9 ) -custom_fonts/normal_font = SubResource( 10 ) -bbcode_enabled = true -scroll_following = true - -[node name="Log" type="Control" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -script = ExtResource( 10 ) - -[node name="Label2" type="Label" parent="Log"] -anchor_top = 0.098 -anchor_right = 1.0 -anchor_bottom = 0.144 -margin_top = -0.352005 -margin_bottom = -0.456009 -custom_fonts/font = ExtResource( 3 ) -text = "Webserver Log" -align = 1 - -[node name="RichTextLabel" type="RichTextLabel" parent="Log"] -anchor_left = 0.057 -anchor_top = 0.156 -anchor_right = 0.943 -anchor_bottom = 0.908 -margin_left = 0.167999 -margin_top = 0.255997 -margin_right = -0.16803 -margin_bottom = 0.207947 -custom_styles/normal = SubResource( 9 ) -custom_fonts/normal_font = SubResource( 10 ) -bbcode_enabled = true -scroll_following = true - -[node name="Guide" type="Control" parent="."] -editor/display_folded = true -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="Label2" type="Label" parent="Guide"] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -158.0 -margin_top = -412.0 -margin_right = 165.0 -margin_bottom = -365.0 -custom_fonts/font = ExtResource( 3 ) -text = "Guide" -align = 1 - -[node name="RichTextLabel" type="RichTextLabel" parent="Guide"] -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -margin_left = 33.0 -margin_top = -352.0 -margin_right = -33.0 -margin_bottom = 418.0 -custom_styles/normal = SubResource( 9 ) -custom_fonts/normal_font = SubResource( 11 ) -bbcode_enabled = true -bbcode_text = "[color=#ff8000]- Webserver Connection:[/color] -Connect to an ESP8266 Webserver using the ip given by your local wifi or hotspot. You can also give your webserver an alias-name with which the app will save it. - -[color=#ff8000]- Webserver Manager:[/color] -Control and manage your ESP8266 throught Webserver client calls, based on the services your ESP offers. - -[color=#ff8000]- Webserver Debug:[/color] -A debug interface of your ESP. Get text based informations about your ESP status, functions and interactions. - -[color=#ff8000]- Webserver List:[/color] -List of all the Webservers you accessed to. They are stored with the alias you gave them, their IP and the date-time of your last connection. You can also fast-connect to them simply clicking on them and going to the Webserver Connection page." -text = "- Webserver Connection: -Connect to an ESP8266 Webserver using the ip given by your local wifi or hotspot. You can also give your webserver an alias-name with which the app will save it. - -- Webserver Manager: -Control and manage your ESP8266 throught Webserver client calls, based on the services your ESP offers. - -- Webserver Debug: -A debug interface of your ESP. Get text based informations about your ESP status, functions and interactions. - -- Webserver List: -List of all the Webservers you accessed to. They are stored with the alias you gave them, their IP and the date-time of your last connection. You can also fast-connect to them simply clicking on them and going to the Webserver Connection page." - -[node name="Filter" type="ColorRect" parent="."] -visible = false -show_behind_parent = true -anchor_right = 1.0 -anchor_bottom = 1.0 -color = Color( 0, 0, 0, 0.705882 ) - -[node name="Menu" type="Control" parent="."] -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 - -[node name="Background" type="ColorRect" parent="Menu"] -show_behind_parent = true -anchor_bottom = 1.0 -margin_right = 460.0 -color = Color( 0.113725, 0.105882, 0.133333, 1 ) - -[node name="MenuContainer" type="VBoxContainer" parent="Menu"] -anchor_bottom = 1.0 -margin_right = 460.0 -margin_bottom = 5.0 -custom_constants/separation = 0 -alignment = 1 - -[node name="Label2" type="Label" parent="Menu/MenuContainer"] -margin_top = 25.0 -margin_right = 460.0 -margin_bottom = 82.0 -size_flags_horizontal = 11 -custom_styles/normal = SubResource( 12 ) -custom_fonts/font = ExtResource( 3 ) -custom_colors/font_color = Color( 0.113725, 0.105882, 0.133333, 1 ) -text = "HOME" -align = 1 -valign = 1 - -[node name="ChangeIP" type="Button" parent="Menu/MenuContainer"] -margin_top = 82.0 -margin_right = 460.0 -margin_bottom = 135.0 -focus_mode = 0 -custom_styles/hover = SubResource( 13 ) -custom_styles/pressed = SubResource( 14 ) -custom_styles/normal = SubResource( 13 ) -custom_fonts/font = SubResource( 15 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Webserver Connection" - -[node name="Webserver" type="Button" parent="Menu/MenuContainer"] -margin_top = 135.0 -margin_right = 460.0 -margin_bottom = 188.0 -focus_mode = 0 -custom_styles/hover = SubResource( 13 ) -custom_styles/pressed = SubResource( 14 ) -custom_styles/normal = SubResource( 13 ) -custom_fonts/font = SubResource( 15 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Webserver Manager" - -[node name="Debug" type="Button" parent="Menu/MenuContainer"] -margin_top = 188.0 -margin_right = 460.0 -margin_bottom = 241.0 -focus_mode = 0 -custom_styles/hover = SubResource( 13 ) -custom_styles/pressed = SubResource( 14 ) -custom_styles/normal = SubResource( 13 ) -custom_fonts/font = SubResource( 15 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Webserver Debug" - -[node name="Log" type="Button" parent="Menu/MenuContainer"] -margin_top = 241.0 -margin_right = 460.0 -margin_bottom = 294.0 -custom_styles/hover = SubResource( 13 ) -custom_styles/pressed = SubResource( 14 ) -custom_styles/normal = SubResource( 13 ) -custom_fonts/font = SubResource( 15 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Webserver Log" - -[node name="WebserverList" type="Button" parent="Menu/MenuContainer"] -margin_top = 294.0 -margin_right = 460.0 -margin_bottom = 347.0 -custom_styles/hover = SubResource( 13 ) -custom_styles/pressed = SubResource( 14 ) -custom_styles/normal = SubResource( 13 ) -custom_fonts/font = SubResource( 15 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Webserver List" - -[node name="Guide" type="Button" parent="Menu/MenuContainer"] -margin_top = 347.0 -margin_right = 460.0 -margin_bottom = 400.0 -custom_styles/hover = SubResource( 13 ) -custom_styles/pressed = SubResource( 14 ) -custom_styles/normal = SubResource( 13 ) -custom_fonts/font = SubResource( 15 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Guide" - -[node name="spacer" type="Label" parent="Menu/MenuContainer"] -margin_top = 400.0 -margin_right = 460.0 -margin_bottom = 947.0 -custom_fonts/font = ExtResource( 3 ) -custom_colors/font_color = Color( 0.113725, 0.105882, 0.133333, 1 ) -text = " - - - - - - - - - -" -align = 1 - -[node name="Exit" type="Button" parent="Menu/MenuContainer"] -margin_top = 947.0 -margin_right = 460.0 -margin_bottom = 1004.0 -focus_mode = 0 -custom_styles/hover = SubResource( 16 ) -custom_styles/pressed = SubResource( 17 ) -custom_styles/normal = SubResource( 18 ) -custom_fonts/font = SubResource( 19 ) -custom_colors/font_color = Color( 1, 1, 1, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -text = "Quit" - -[node name="Overlay" type="Control" parent="."] -editor/display_folded = true -anchor_right = 1.0 -anchor_bottom = 1.0 -mouse_filter = 2 - -[node name="MenuButton" type="TextureButton" parent="Overlay"] -anchor_left = 1.0 -anchor_right = 1.0 -margin_left = -76.0 -margin_top = 10.0 -margin_right = -16.0 -margin_bottom = 70.0 -texture_normal = ExtResource( 11 ) -expand = true - -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] -anims/menu_in = SubResource( 20 ) -anims/menu_out = SubResource( 21 ) -[connection signal="pressed" from="DeviceChoice/VBoxContainer/HBoxContainer2/connect" to="." method="_on_connect_pressed"] -[connection signal="pressed" from="DeviceChoice/VBoxContainer/HBoxContainer2/disconnect" to="." method="_on_disconnect_pressed"] -[connection signal="toggled" from="DeviceManager/VBoxContainer/HBoxContainer2/moisture_btn" to="." method="_on_moisture_btn_toggled"] -[connection signal="toggled" from="DeviceManager/VBoxContainer/HBoxContainer3/led1" to="." method="_on_led1_toggled"] -[connection signal="item_activated" from="WebServerList/Tree" to="." method="_on_Tree_item_activated"] -[connection signal="item_selected" from="WebServerList/Tree" to="." method="_on_Tree_item_selected"] -[connection signal="pressed" from="Menu/MenuContainer/ChangeIP" to="." method="_on_ChangeIP_pressed"] -[connection signal="pressed" from="Menu/MenuContainer/Webserver" to="." method="_on_Webserver_pressed"] -[connection signal="pressed" from="Menu/MenuContainer/Debug" to="." method="_on_Debug_pressed"] -[connection signal="pressed" from="Menu/MenuContainer/Log" to="." method="_on_Log_pressed"] -[connection signal="pressed" from="Menu/MenuContainer/WebserverList" to="." method="_on_WebserverList_pressed"] -[connection signal="pressed" from="Menu/MenuContainer/Guide" to="." method="_on_Guide_pressed"] -[connection signal="pressed" from="Menu/MenuContainer/Exit" to="." method="_on_Exit_pressed"] -[connection signal="pressed" from="Overlay/MenuButton" to="." method="_on_MenuButton_pressed"] diff --git a/scenes/scripts/Debug.gd b/scenes/scripts/Debug.gd deleted file mode 100644 index e7d8f86..0000000 --- a/scenes/scripts/Debug.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Control - -func _ready(): - HTTPManager.connect("debug_signal",self,"debug_print") - -func debug_print(body : String, color : String) -> void: - $RichTextLabel.append_bbcode("[color="+color+"] - "+body+"[/color]\n") - print(body) \ No newline at end of file diff --git a/scenes/scripts/Log.gd b/scenes/scripts/Log.gd deleted file mode 100644 index 0a1e309..0000000 --- a/scenes/scripts/Log.gd +++ /dev/null @@ -1,18 +0,0 @@ -extends Control - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - -# Called when the node enters the scene tree for the first time. -func _ready(): - HTTPManager.connect("log_signal",self,"log_save") - webserver_data.load_data(webserver_data.log_file) - $RichTextLabel.append_bbcode(webserver_data.log_) - -func log_save(message : String): - var time = OS.get_datetime() - var stamp : String = str(time.day)+"-"+str(time.month)+"-"+str(time.year)+" "+str(time.hour)+":"+str(time.minute)+" ["+webserver_data.webserver_ip+"] - " - var content = (stamp+" "+message) - $RichTextLabel.append_bbcode(content+"\n") - webserver_data.save_data(webserver_data.log_file,content) diff --git a/scenes/scripts/MainScene.gd b/scenes/scripts/MainScene.gd deleted file mode 100644 index 6bfde5f..0000000 --- a/scenes/scripts/MainScene.gd +++ /dev/null @@ -1,177 +0,0 @@ -extends Node - -var menu : bool = true #the switch sets it false -onready var debug_web : Node = $Debug -onready var status1 : Node = $DeviceChoice/VBoxContainer/HBoxContainer/status2 -onready var status2 : Node = $DeviceManager/HBoxContainer/status - - -func _ready() -> void: - HTTPManager.connect("update_status_signal",self,"update_status") - - webserver_data.load_data(webserver_data.data_file) - switch_child($DeviceChoice) - $DeviceChoice/VBoxContainer/HBoxContainer2/disconnect.disabled = true - webserver_data.webserver_state = "disconnected" - update_status(webserver_data.webserver_state) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass - -func manage_menu() -> void: - menu=!menu - match (menu): - false: - $AnimationPlayer.play("menu_out") - true: - $AnimationPlayer.play("menu_in") - -func _on_MenuButton_pressed(): - manage_menu() - -func switch_child(child : Node) -> void: - for ch in get_children(): - if ch.get_class()=="Control" and ch.get_name() != "Overlay" and ch.get_name() != "Menu": - if ch != child : - ch.visible=false - else: - ch.visible=true - - manage_menu() - - -func _on_Webserver_pressed(): - switch_child($DeviceManager) - - -func _on_ChangeIP_pressed(): - switch_child($DeviceChoice) - - -func _on_Exit_pressed(): - get_tree().set_auto_accept_quit(true) - get_tree().quit() - -func _on_disconnect_pressed(): - - webserver_data.webserver_state = "disconnected" - update_status(webserver_data.webserver_state) - HTTPManager.Request.cancel_request() - $DeviceChoice/VBoxContainer/HBoxContainer2/connect.disabled = false - $DeviceChoice/VBoxContainer/HBoxContainer2/disconnect.disabled = true - - -func _on_connect_pressed(): - var ip : String = $DeviceChoice/VBoxContainer/webserver_ip.get_text() - var nam : String = $DeviceChoice/VBoxContainer/webserver_name.get_text() - if ip!="" and nam!="": - webserver_data.webserver_state = "pending" - - update_status(webserver_data.webserver_state) - - $DeviceChoice/VBoxContainer/HBoxContainer2/connect.disabled = true - $DeviceChoice/VBoxContainer/HBoxContainer2/disconnect.disabled = false - webserver_data.current_webserver(ip,nam) - - webserver_data.save_data(webserver_data.data_file,"") - - $DeviceManager/HBoxContainer/w_ip.set_text(ip) - $DeviceManager/HBoxContainer/w_name.set_text(nam) - - HTTPManager.httprequest("request","") - - -func _on_WebserverList_pressed(): - switch_child($WebServerList) - $WebServerList/Tree.load_webserver_list() - - -func _on_Guide_pressed(): - switch_child($Guide) - -func _on_Debug_pressed(): - switch_child(debug_web) - -func _on_Tree_item_selected(): - var webserver : TreeItem = $WebServerList/Tree.get_selected() - $DeviceChoice/VBoxContainer/webserver_ip.set_text(webserver.get_text(0)) - $DeviceChoice/VBoxContainer/webserver_name.set_text(webserver.get_text(1)) - -#func _on_HTTPRequest_request_completed(result, response_code, headers, body): -# if webserver_data.webserver_state == "connected" or webserver_data.webserver_state == "pending": -# debug_web.debug_print("Richiesta http eseguita...","green") -# debug_web.debug_print("Result code to http request: "+str(result),"yellow") -# debug_web.debug_print("Response code to http request: "+str(response_code),"yellow") -# -# http_response = str(body.get_string_from_utf8()) -# $HTTPRequest.cancel_request() -# -# if body_request == "": -# update_status(http_response) -# webserver_data.webserver_state = http_response -# else: -# update_moisture(str(http_response)) -# debug_web.debug_print("Aggiorno umidità: "+http_response,"orange") -# HTTPManager.httprequest("moisture") -# else: -# debug_web.debug_print("Disconnesso dal Webserver, impossibile completare richieste","red") - -#func httprequest(body_r : String) -> void: -# if webserver_data.webserver_state == "connected" or webserver_data.webserver_state == "pending": -# var http_request : String = webserver_data.webserver_ip+"/"+body_r -# body_request = body_r -# debug_web.debug_print("Richiesta http: " + str(http_request),"green") -# var err = $HTTPRequest.request("http://"+http_request,["Cache-Control: no-cache"],false,0,"") -# debug_web.debug_print("Risposta http: " + str(err),"yellow") -# if err > 1: -# webserver_data.webserver_state = "error" -# update_status(webserver_data.webserver_state) -# else: -# debug_web.debug_print("Disconnesso dal Webserver, impossibile eseguire richieste","red") - -func update_status(http_r : String) -> void: - status1.match_icon_status(str(http_r)) - status2.match_icon_status(str(http_r)) - match(http_r): - "connected": - debug_web.debug_print("Connesso al server","green") - HTTPManager.emit_signal("log_signal","Connesso al server") - $DeviceChoice/VBoxContainer/state_message.text = "Connected to Webserver!" - "error": - debug_web.debug_print("Errore nella connessione","red") - $DeviceChoice/VBoxContainer/state_message.text = "Can't connect to Webserver!" - HTTPManager.emit_signal("log_signal","Errore nella connessione") - "disconnected": - debug_web.debug_print("Disconnesso dal server","gray") - $DeviceChoice/VBoxContainer/state_message.text = "No webserver to connect to." - HTTPManager.emit_signal("log_signal","Disconnesso dal server") - "pending": - debug_web.debug_print("Provo a connettermi al server...","orange") - $DeviceChoice/VBoxContainer/state_message.text = "Connecting to the webserver..." - HTTPManager.emit_signal("log_signal","Provo a connettermi al server...") - - - -func _on_moisture_btn_toggled(button_pressed): - if (button_pressed): - HTTPManager.button_moisture = true - HTTPManager.httprequest("request","moisture") - debug_web.debug_print("Attivato aggiornamento umidità","cyan") - HTTPManager.emit_signal("log_signal","Led 1 acceso") - else: - HTTPManager.button_moisture = false - $DeviceManager/VBoxContainer/HBoxContainer2/moisture.text = "---" - HTTPManager.Request.cancel_request() - debug_web.debug_print("Disattivato aggiornamento umidità","gray") - HTTPManager.emit_signal("log_signal","Led 1 spento") - -func _on_led1_toggled(button_pressed): - HTTPManager.httprequest("command","toggleled1") - -#func _on_HTTPCommand_request_completed(result, response_code, headers, body): -# HTTPManager.httprequest("moisture") - - -func _on_Log_pressed(): - switch_child($Log) diff --git a/scenes/scripts/Tree.gd b/scenes/scripts/Tree.gd deleted file mode 100644 index 405dba3..0000000 --- a/scenes/scripts/Tree.gd +++ /dev/null @@ -1,28 +0,0 @@ -extends Tree - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass - -func load_webserver_list(): - clear() - - var root = create_item() - root.set_text(0,"Webserver Ip") - root.set_text(1,"Webserver Name") - root.set_text(2,"Last Connection") - - - for webserver in webserver_data.data: - var nod = create_item() - nod.set_text(0,webserver_data.data[webserver].webserver_ip) - nod.set_text_align(0,1) - nod.set_text(1,webserver_data.data[webserver].webserver_name) - nod.set_text_align(1,1) - nod.set_text(2,webserver_data.data[webserver].last_connection) - nod.set_text_align(2,1) - diff --git a/scenes/scripts/http_manager.gd b/scenes/scripts/http_manager.gd deleted file mode 100644 index f716e7d..0000000 --- a/scenes/scripts/http_manager.gd +++ /dev/null @@ -1,70 +0,0 @@ -extends Node - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - -signal debug_signal(message,color) -signal update_status_signal(status) -signal update_moisture(val) -signal log_signal(message) - -onready var Request : Node = $HTTPRequest -onready var Command : Node = $HTTPCommand - -var body_request : String = "" -var button_moisture : bool -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - -func httprequest(type : String, body_r : String) -> void: - if webserver_data.webserver_state == "connected" or webserver_data.webserver_state == "pending": - var http_request : String = webserver_data.webserver_ip+"/"+body_r - body_request = body_r - emit_signal("debug_signal","Richiesta http: " + str(http_request) + " (tipo: "+type+")","green") - var err : int - match(type): - "request": - err = Request.request("http://"+http_request,["Cache-Control: no-cache"],false,0,"") - - "command": - Request.cancel_request() - match(body_r): - "toggleled1": - emit_signal("debug_signal","Accensione/Spegnimento Led1","arancione") - err = Command.request("http://"+http_request,["Cache-Control: no-cache"],false,0,"") - - emit_signal("debug_signal","Risposta http: " + str(err),"yellow") - if err > 1: - webserver_data.webserver_state = "error" - emit_signal("update_status_signal",(webserver_data.webserver_state)) - else: - emit_signal("debug_signal","Disconnesso dal Webserver, impossibile eseguire richieste","red") - -func _on_HTTPRequest_request_completed(result, response_code, headers, body): - if webserver_data.webserver_state == "connected" or webserver_data.webserver_state == "pending": - emit_signal("debug_signal","Richiesta http eseguita...","green") - emit_signal("debug_signal","Result code to http request: "+str(result),"yellow") - emit_signal("debug_signal","Response code to http request: "+str(response_code),"yellow") - - var http_response = str(body.get_string_from_utf8()) - Request.cancel_request() - - if body_request == "": - emit_signal("update_status_signal",http_response) - webserver_data.webserver_state = http_response - - else: - emit_signal("update_moisture",str(http_response)) - - emit_signal("log_signal","Moisture = "+http_response) - - emit_signal("debug_signal","Aggiorno umidità: "+http_response,"orange") - httprequest("request","moisture") - else: - emit_signal("debug_signal","Disconnesso dal Webserver, impossibile completare richieste","red") - -func _on_HTTPCommand_request_completed(result, response_code, headers, body): - if button_moisture: - httprequest("request","moisture") \ No newline at end of file diff --git a/scenes/scripts/moisture.gd b/scenes/scripts/moisture.gd deleted file mode 100644 index 0928f3a..0000000 --- a/scenes/scripts/moisture.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends LineEdit - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - -# Called when the node enters the scene tree for the first time. -func _ready(): - HTTPManager.connect("update_moisture",self,"update_moisture") - -func update_moisture(val : String) -> void: - set_text(val) diff --git a/scenes/scripts/status_icon.gd b/scenes/scripts/status_icon.gd deleted file mode 100644 index 3d29fe1..0000000 --- a/scenes/scripts/status_icon.gd +++ /dev/null @@ -1,14 +0,0 @@ -extends TextureRect - -var icons : Dictionary = {"connected":Vector2(256,0),"error":Vector2(0,0),"pending":Vector2(0,256),"disconnected":Vector2(256,256)} - - -func _ready(): - match_icon_status("disconnected") - -func match_icon_status(status : String) -> void: - set_icon(icons[status]) - update() - -func set_icon(icon : Vector2) -> void: - get_texture().set_region(Rect2(icon,Vector2(256,256))) \ No newline at end of file diff --git a/scenes/scripts/webserver_data.gd b/scenes/scripts/webserver_data.gd deleted file mode 100644 index 0647a5f..0000000 --- a/scenes/scripts/webserver_data.gd +++ /dev/null @@ -1,94 +0,0 @@ -extends Node - -var webserver_ip : String = "" setget set_webserver_ip, get_webserver_ip -var webserver_name : String = "" setget set_webserver_name, get_webserver_name -var data_file : String = "user://webservers.json" -var log_file : String = "user://log.txt" -var data : Dictionary = {} setget set_data,get_data -var webserver_state : String = "" setget set_webserver_state, get_webserver_state -var log_ : String = "" -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - - - -# setget part # -------------------------------------------------------------------------------------------------------- - -func set_webserver_ip(ip : String) -> void: - webserver_ip = ip - -func get_webserver_ip() -> String: - return webserver_ip - -func set_webserver_name(name_n : String) -> void: - webserver_name = name_n - -func get_webserver_name() -> String: - return webserver_name - -func set_data_file(path : String) -> void: - data_file = path - -func get_data_file() -> String: - return data_file - -func set_data(d : Dictionary) -> void: - data = d - -func get_data() -> Dictionary: - return data - -func set_webserver_state(state : String) -> void: - webserver_state = state - -func get_webserver_state() -> String: - return webserver_state - -# save / load file part # ------------------------------------------------------------------------------------------------- - -func save_data(path_file : String, message : String) -> void: - var file = File.new() - if file.file_exists(path_file): - file.open(path_file,File.READ_WRITE) - else: - file.open(path_file,File.WRITE) - - match(path_file): - data_file: - file.store_line(JSON.print(create_data())) - log_file: - file.store_line(message) - - file.close() - -func create_data() -> Dictionary: - var time = OS.get_datetime() - - data[webserver_ip] = ( { - "webserver_ip": webserver_ip, - "webserver_name": webserver_name, - "last_connection": str(time.day)+"-"+str(time.month)+"-"+str(time.year)+" "+str(time.hour)+":"+str(time.minute) - } ) - - return data - -func load_data(path_file : String) -> void : - var file : File = File.new() - if file.open(path_file,File.READ) != OK: - return - else: - match(path_file): - data_file: - set_data(JSON.parse(file.get_as_text()).result) - log_file: - log_ = file.get_as_text() - print(log_) - - - file.close() - -func current_webserver(wip : String , wnam : String) -> void : - webserver_ip = wip - webserver_name = wnam \ No newline at end of file