123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include "brightnessinfo.h"
- #include "strutil.h"
- #include "CommEntityUtil.hpp"
- void HttpsLogCallBack(const char* logtxt) {
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HttpsLogCallBack")("HttpsLogCallBack: %s.", logtxt);
- }
- int post_camera_brightness_info_list(unsigned int& uposttime, CSimpleStringA& errormsg, brightness_info_t* pinfo, int itimeout, bool bprintdbg)
- {
- int iret = -1;
- IHttpFunc* client = create_http(HttpsLogCallBack);
- BrightnessInfoHTTPReq req;
- req.m_timeOut = itimeout;
- if (bprintdbg) {
- req.m_printDbg = true;
- }
- const char* pData = pinfo->strServerURL.GetData();
- if (pData) {
- req.m_url = pData;
- }
- pData = pinfo->strAPI.GetData();
- if (pData) {
- req.m_url.append(pData);
- }
- Json::Value rootReq;
- pData = pinfo->strTerminalNo.GetData();
- if (pData) {
- rootReq["terminal_no"] = pData;
- }
- pData = pinfo->strAppVersion.GetData();
- if (pData) {
- rootReq["app_version"] = pData;
- }
- for (vector<brightness_item_t*>::iterator it = pinfo->vBrightnessList.begin(); it < pinfo->vBrightnessList.end(); ++it) {
- Json::Value item;
- item["module"] = (*it)->module;
- item["name"] = (*it)->name;
- item["value"] = (*it)->value;
- rootReq["config_list"].append(item);
- }
- Json::StyledWriter sw;
- req.m_reqContent = sw.write(rootReq);
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("m_reqContent is %s.", req.m_reqContent.c_str());
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin http get request, timeout is %d, printdbg flag is %s.", req.m_timeOut, req.m_printDbg ? "true" : "false");
- unsigned int ustarttime = SP::Module::Comm::RVCGetTickCount();
- BrightnessInfoHTTPRet ret;
- PROCESS_LINK_CONTEXT("LR0402208BringnessInfo")
- if (client->Post(req, ret, &nextLink)) {
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
- // ret.m_success ? "success" : "failed", ret.m_returnCode.c_str(), ret.m_code.c_str(), ret.m_errorMsg.c_str(), ret.m_message.c_str());
- uposttime = SP::Module::Comm::RVCGetTickCount() - ustarttime;
- iret = 0;
- }
- else {
- errormsg = CSimpleStringA::Format("post camera brightness info failed, url=%s, syscode=%d, usercode=%s, errmsg=%s", req.m_url.c_str(), ret.m_sysCode, ret.m_userCode.c_str(), ret.m_errMsg.c_str());
- }
- return iret;
- }
|