start /min "Pegasus" "c:\Program Files (x86)\Pegasus Astro\Unity Platform\server\Peg.Server.exe"
timeout 10

curl -X PUT "http://localhost:32000/Server/Start"
timeout 5

curl -s -X GET "http://localhost:32000/Server/DeviceManager/Connected" | jq.exe -r ".data[0].uniqueKey" > id.txt
for /f "delims=" %%x in (id.txt) do set UID=%%x

IF [%UID%] == [null] GOTO NoDevice

curl -X OPTIONS "http://localhost:32000/Driver/PPBAdvance/Start?DriverUniqueKey=%UID%"
curl -X PUT "http://localhost:32000/Driver/PPBAdvance/Power/Hub/Off?DriverUniqueKey=%UID%"
curl -X PUT "http://localhost:32000/Driver/PPBAdvance/Power/Variable/Off?DriverUniqueKey=%UID%"
curl -X PUT "http://localhost:32000/Driver/PPBAdvance/Dew/1/Off?DriverUniqueKey=%UID%"
curl -X PUT "http://localhost:32000/Driver/PPBAdvance/Dew/2/Off?DriverUniqueKey=%UID%"
curl -X POST "http://localhost:32000/Driver/PPBAdvance/Dew/Auto/Off?DriverUniqueKey=%UID%"


timeout 5
telegraf.exe --config with_ppba.conf
exit /b


:NoDevice

timeout 5
telegraf.exe --config without_ppba.conf
exit /b