Scripting firmware upgrade MTC

Home Forums General Scripting firmware upgrade MTC

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31554
    Melanie Badura
    Participant

    Hello,

    so I’m trying to write a script to the firmware upgrade. The frimware_pre_upgrade gives me a success, so that’s working, but when I do the firmware_check, I get a header as a result and the at firmware_upgrade it, just fails. I’m out of ideas, I tried to do the same thing as the GUI does, but no dice.

    Here is my command to do the firmware_check. I also tried it without Content-Disposition, I get the same header as result.
    $(curl -s -k -X POST -H "Content-Type: application/octet-stream" "Content-Disposition: form-data; name="archivo"; filename="conduit_5.2.1_upgrade-signed.bin"" "${ADDRESS}/api/command/firmware_check?token=${TOKEN}")

    That’s the result I get

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     <head>
      <title>411 - Length Required</title>
     </head>
     <body>
      <h1>411 - Length Required</h1>
     </body>
    </html>
    

    And here is my firmware_upgrade command, but I guess the failure is already at the firmware_check.

    $(curl -s -k -X POST -H "Content-Type: application/octet-stream" -d '{info: {fileName: "conduit_5.2.1_upgrade-signed.bin", fileSize: 112302080}}' "${ADDRESS}/api/command/firmware_upgrade?token=${TOKEN}")

    It’be really nice, if someone could help me with that.

    #31557
    Darshan Maiya
    Blocked

    Here is the script I generally use to commission and upgrade units

    #! /bin/bash
    #check commissioning mode
    ##script tested using ubuntu
    set -e
    
    curl -k "https://192.168.2.1/api/commissioning" 
    
    ##set username 
    aas_ID=$(curl -k -X POST -H "Content-Type: json/apaas_IDplication" -d '{"username":"admin", "aasID": "", "aasAnswer":""}' https://192.168.2.1:443/api/commissioning | jq -r '.result.aasID' )
    ##set password
    curl -k -X POST -H "Content-Type: json/application" -d '{"username":"admin", "aasID":"'"$aas_ID"'", "aasAnswer":"Admin123"}' https://192.168.2.1:443/api/commissioning
    ##confirm password
    curl -k -X POST -H "Content-Type: json/application" -d '{"username":"admin", "aasID":"'"$aas_ID"'", "aasAnswer":"Admin123"}' https://192.168.2.1:443/api/commissioning
    
    ##log in and save token 
    token=$(curl -k "https://192.168.2.1/api/login?username=admin&password=Admin123"| jq -r '.result.token' )
    
    curl -k -X POST -H "Content-Type: json/application" -d '{"info":{"fileName":"conduit_5.3.0_upgrade-signed.bin","fileSize":81674240}}' https://192.168.2.1/api/command/firmware_pre_upgrade?token=$token
    curl -i -k -b /tmp/headers --http1.0 -F file=@conduit_5.3.0_upgrade-signed.bin "https://192.168.2.1/api/command/firmware_check?token=$token"
    curl -k -X POST -H "Content-Type: json/application" -d '' https://192.168.2.1/api/command/firmware_upgrade?token=$token
    
    sleep 12m
    
    token1=$(curl -k "https://192.168.2.1/api/login?username=admin&password=Admin123"| jq -r '.result.token' )
    
    #factory reset back to comissioning mode
    curl -k -X POST -d "" https://192.168.2.1/api/command/restore_defaults?token=$token1
    #31559
    Jeff Hatch
    Keymaster

    Hello Melanie,

    Here is a script to do what you are trying to do with curl that was tested against Ubuntu:

    #! /bin/bash
    #check commissioning mode
    ##script tested using ubuntu
    set -e
     
    curl -k "https://192.168.2.1/api/commissioning"
     
    ##set username
    aas_ID=$(curl -k -X POST -H "Content-Type: json/apaas_IDplication" -d '{"username":"admin", "aasID": "", "aasAnswer":""}' https://192.168.2.1:443/api/commissioning | jq -r '.result.aasID' )
    ##set password
    curl -k -X POST -H "Content-Type: json/application" -d '{"username":"admin", "aasID":"'"$aas_ID"'", "aasAnswer":"Admin123"}' https://192.168.2.1:443/api/commissioning
    ##confirm password
    curl -k -X POST -H "Content-Type: json/application" -d '{"username":"admin", "aasID":"'"$aas_ID"'", "aasAnswer":"Admin123"}' https://192.168.2.1:443/api/commissioning
     
    ##log in and save token
    token=$(curl -k "https://192.168.2.1/api/login?username=admin&password=Admin123"| jq -r '.result.token' )
     
    curl -k -X POST -H "Content-Type: json/application" -d '{"info":{"fileName":"conduit_5.3.0_upgrade-signed.bin","fileSize":81674240}}' https://192.168.2.1/api/command/firmware_pre_upgrade?token=$token
    curl -i -k -b /tmp/headers --http1.0 -F file=@conduit_5.3.0_upgrade-signed.bin "https://192.168.2.1/api/command/firmware_check?token=$token"
    curl -k -X POST -H "Content-Type: json/application" -d '' https://192.168.2.1/api/command/firmware_upgrade?token=$token
     
    sleep 12m
     
    token1=$(curl -k "https://192.168.2.1/api/login?username=admin&password=Admin123"| jq -r '.result.token' )
     
    #factory reset back to comissioning mode
    curl -k -X POST -d "" https://192.168.2.1/api/command/restore_defaults?token=$token1
    

    I think that the -d option with the JSON data is what may make the difference. Among other things there is a “filesize” field for the size of the upgrade file.

    Thank You,

    Jeff

    #31561
    Melanie Badura
    Participant

    Hello Darshan and Jeff,

    thanks for this! I changed some things, but now it’s working fine.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.