//
// Created by Ht on 2022/10/21.
//

#ifndef IOT_EDGE_VDALNEW_QVDAOUTIL_H
#define IOT_EDGE_VDALNEW_QVDAOUTIL_H

#include <qlibc/qlibc.h>

namespace jedge {

    class JE_API QVDAOUtil {

    public:
        static std::string getBaseFromPoolData(const qlibc::QData& params) {
            return params.getObjFmtString("serial.port");
        }

       static std::string getSerialTypeFromPoolData(const qlibc::QData& params) {
            return params.getObjFmtString("serial.type","ble_mesh");
        }

       static void getSerialNameFromPoolData(const qlibc::QData& params, std::string& serialName) {
           serialName = params.getObjFmtString("serial.port");
        }

       static void getJedpFromPoolData(const qlibc::QData& params, std::string& upJedp, std::string& downJedp) {
            auto cfg = params.getObjFmtString("serial.jedp");
            if(!cfg.empty()) {
                upJedp = StringUtils::getSubStrBefore(cfg, ',', 1);
                downJedp = StringUtils::getSubStrAfter(cfg, ',', -1);
            }
        }
    };
}

#endif //IOT_EDGE_VDALNEW_QVDAOUTIL_H
