@echo off
REM ============================================================
REM  T04 - ERRORI di connessione
REM  Tre casi, tutti attesi -201 "Macchina non connessa":
REM    a) IP inesistente
REM    b) porta errata
REM    c) credenziali errate
REM  NOTA: il Connect fa una LIST su /PRG/. Se il controllo usa
REM  una cartella programmi DIVERSA da /PRG/, anche con IP/cred
REM  corretti la connessione FALLISCE (criticita C6: ProgramDirectory
REM  e' hardcoded "/PRG/", nessun flag CLI per cambiarla).
REM ============================================================
setlocal
call "%~dp0config.bat"
if not exist "%RESULTS%" mkdir "%RESULTS%"
set LOG=%RESULTS%\t04_errori_connessione.log
echo === T04 ERRORI CONNESSIONE === > "%LOG%"

echo. >> "%LOG%"
echo ----- a) IP inesistente 10.255.255.1 ----- >> "%LOG%"
"%EXE%" -manufacturer=mitsubishi -azione=Scarica -ip=10.255.255.1 -porta=%PORT% -username=%USER% -password=%PASS% -path=%PROGNUM% -pathprogramma="%RESULTS%\dl_a.txt" >> "%LOG%" 2>&1
echo EXITCODE_a=%ERRORLEVEL% >> "%LOG%"

echo. >> "%LOG%"
echo ----- b) porta errata 9999 ----- >> "%LOG%"
"%EXE%" -manufacturer=mitsubishi -azione=Scarica -ip=%IP% -porta=9999 -username=%USER% -password=%PASS% -path=%PROGNUM% -pathprogramma="%RESULTS%\dl_b.txt" >> "%LOG%" 2>&1
echo EXITCODE_b=%ERRORLEVEL% >> "%LOG%"

echo. >> "%LOG%"
echo ----- c) credenziali errate ----- >> "%LOG%"
"%EXE%" -manufacturer=mitsubishi -azione=Scarica -ip=%IP% -porta=%PORT% -username=NOUSER -password=NOPASS -path=%PROGNUM% -pathprogramma="%RESULTS%\dl_c.txt" >> "%LOG%" 2>&1
echo EXITCODE_c=%ERRORLEVEL% >> "%LOG%"

echo Log: %LOG%
type "%LOG%"
endlocal
