diff --git a/config.json b/config.json new file mode 100644 index 0000000..94c0bde --- /dev/null +++ b/config.json @@ -0,0 +1,14 @@ +{ + "MQTT_SERVER": "", + "MQTT_USE_AUTH": false, + "MQTT_USERNAME": "", + "MQTT_PASSWORD": "", + "MQTT_BASE_TOPIC": "/ledstrip/fixture1", + "FRAME_TIME": 0.05, + "SERIAL_PORTS_MAP": [ + "COM1" + ], + "LED_MAP": [ + 60 + ] +} \ No newline at end of file diff --git a/config_generator.py b/config_generator.py new file mode 100644 index 0000000..0da5035 --- /dev/null +++ b/config_generator.py @@ -0,0 +1,18 @@ +import json +from getpass import getpass + +print("Siwat Light Control Protocol Configuration Generator") +server = input("MQTT Server Hostname / IP Address : ") +username = "" +password = "" +while True: + use_auth = input("Does this server require username and password to login (yes/no) : ") + if use_auth.lower() == "yes": + username = input("Username : ") + password = getpass("Password : ") + break + elif use_auth.lower() == "no": + break + print("Please answer yes / no") +base_topic = input("MQTT Base Topic : ") +frame_time = input("Frame Time (1/refresh rate) : ") diff --git a/install.sh b/install.sh index fb1fbbc..01ffa3b 100644 --- a/install.sh +++ b/install.sh @@ -1,8 +1,16 @@ echo "Installing Dependencies" sudo apt update -sudo apt install python3 python3-pip +sudo apt install -y python3 python3-pip sudo pip3 install siwat-light-control-protocol -sudo mkdir /slcp + +echo "Moving Directory to SLCP" +sudo mv -v ./ /slcp sudo chmod 777 -Rv /slcp -cp -v ./slcp_config.json /slcp/config.json -echo "Adding Service to systemd" \ No newline at end of file + +echo "Creating systemd Service" +sudo chmod +x /slcp/jumpstart.sh +sudo ln -v /slcp/slcp.service /lib/systemd/system/slcp.service +sudo systemctl daemon-reload +sudo systemctl enable slcp.service +echo "Installation Completed!" +echo "Adjust /slcp/config.json then run sudo \"systemctl start slcp.service\"" \ No newline at end of file diff --git a/jumpstart.sh b/jumpstart.sh new file mode 100644 index 0000000..931ac7d --- /dev/null +++ b/jumpstart.sh @@ -0,0 +1,2 @@ +cd /slcp +python -m siwat_remote_light_control_protocol_server \ No newline at end of file diff --git a/slcp.service b/slcp.service index e69de29..6225531 100644 --- a/slcp.service +++ b/slcp.service @@ -0,0 +1,11 @@ +[Unit] +Description=Siwat Light Control Protocol Server +After=multi-user.target + +[Service] +Type=simple +WorkingDirectory=/slcp +ExecStart=/slcp/jumpstart.sh + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/slcp_config.json b/slcp_config.json deleted file mode 100644 index e69de29..0000000