/*
 * Copyright (C) 2019 by Multi-Tech Systems
 *
 * This file is part of libmts-io.
 *
 * libmts-io is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * libmts-io is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libmts-io.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef MTS_IO_ME910C1WWRADIO_H_
#define MTS_IO_ME910C1WWRADIO_H_

#include <mts/MTS_IO_ME910Radio.h>

namespace MTS {
    namespace IO {

        class ME910C1WWRadio : public ME910Radio {

            public:
                static const std::string MODEL_NAME;

                ME910C1WWRadio(const std::string& sPort);
                virtual ~ME910C1WWRadio(){};
                ICellularRadio::CODE setActiveFirmware(const Json::Value& jArgs);
                ICellularRadio::CODE getActiveFirmware(std::string& sFwId);

                virtual CODE updateFumo(const Json::Value& jArgs, UpdateCb& stepCb);

            protected:

                CODE doGetFirmwareNumbers(std::string &sFirmware, std::string &sFirmwareBuild);

            private:
                static const std::string KEY_FUMO_PDPID;     //!< PDP context id (default 3)
                static const std::string KEY_FUMO_PDPTYPE;   //!< PDP context type (default IPV4V6)
                static const std::string KEY_FUMO_APN;       //!< APN (default empty)
                static const std::string KEY_FUMO_ADDRESS;   //!< FTP server address
                static const std::string KEY_FUMO_DIR;       //!< Directory
                static const std::string KEY_FUMO_FILE;      //!< Name of the upgrade file
                static const std::string KEY_FUMO_USER;      //!< Username
                static const std::string KEY_FUMO_PASSWORD;  //!< Password
                static const std::string KEY_FUMO_DRYRUN;    //!< If set, do not apply the downloaded firmware

                CODE doFumoPerform(const Json::Value &jConfig, UpdateCb& stepCb);
                CODE doFumoReadConfig(const Json::Value& jArgs, Json::Value &jConfig);
                CODE doFumoSetup(const Json::Value &jConfig, UpdateCb& stepCb);
                CODE doFumoFtp(const Json::Value &jConfig, UpdateCb& stepCb);
                CODE doFumoCleanup(const Json::Value &jConfig, UpdateCb& stepCb);
                CODE doFumoApplyFirmware(const Json::Value &jConfig, UpdateCb& stepCb);
                CODE doFumoWaitNewFirmware(const Json::Value &jConfig, UpdateCb& stepCb);

                std::string m_sFw;
                std::string m_sFwBuild;
        };
    }
}

#endif /* MTS_IO_ME910C1WWRADIO_H_ */