websdk增加获取固件版本号的接口
This commit is contained in:
parent
a261eb059f
commit
1de555a689
Binary file not shown.
|
@ -1377,6 +1377,30 @@ namespace ver_2
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ManagerV2::GetDeviceFWVersion(std::string& fwVer, std::string& errInfo)
|
||||
{
|
||||
errInfo = "错误";
|
||||
fwVer.clear();
|
||||
|
||||
if (!m_openDevice)
|
||||
{
|
||||
errInfo = "还未打开设备";
|
||||
return -1;
|
||||
}
|
||||
|
||||
char v[256] = {0};
|
||||
SANE_Status status = sane_control_option(m_devHandle, (SANE_Int)0x8857, SANE_ACTION_GET_VALUE, v, NULL);
|
||||
if (SANE_STATUS_GOOD != status)
|
||||
{
|
||||
errInfo = Utf8ToStdString(sane_strstatus(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwVer = v;
|
||||
errInfo.clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ManagerV2::SetDeviceParam(const std::vector<DeviceParam>& devParams, std::string& errInfo)
|
||||
{
|
||||
errInfo = "错误";
|
||||
|
|
|
@ -191,6 +191,8 @@ namespace ver_2
|
|||
int CloseDevice(std::string& errInfo);
|
||||
// 获取设备序列号
|
||||
int GetDeviceSN(std::string& sn, std::string& errInfo);
|
||||
// 获取设备固件版本号
|
||||
int GetDeviceFWVersion(std::string& fwVer, std::string& errInfo);
|
||||
// 设置设备参数
|
||||
int SetDeviceParam(const std::vector<DeviceParam>& devParams, std::string& errInfo);
|
||||
// 获取设备参数
|
||||
|
|
|
@ -317,6 +317,10 @@ namespace ver_2
|
|||
else if ("get_device_sn" == func)
|
||||
{
|
||||
GetDeviceSN(json);
|
||||
}
|
||||
else if ("get_device_fwversion" == func)
|
||||
{
|
||||
GetDeviceFWVersion(json);
|
||||
}
|
||||
else if ("set_device_param" == func)
|
||||
{
|
||||
|
@ -2472,6 +2476,40 @@ namespace ver_2
|
|||
}
|
||||
}
|
||||
|
||||
void WSUser::GetDeviceFWVersion(cJSON* json)
|
||||
{
|
||||
assert(NULL != json);
|
||||
|
||||
std::string fwVersion;
|
||||
std::string errInfo;
|
||||
int ret = GetManager()->GetDeviceFWVersion(fwVersion, errInfo);
|
||||
|
||||
bool findIden = false;
|
||||
std::string iden = GetJsonStringValue(json, "iden", &findIden);
|
||||
|
||||
cJSON* retJson = cJSON_CreateObject();
|
||||
if (NULL != retJson)
|
||||
{
|
||||
cJSON_AddItemToObject(retJson, "func", cJSON_CreateString("get_device_fwversion"));
|
||||
if (findIden)
|
||||
cJSON_AddItemToObject(retJson, "iden", cJSON_CreateString(iden.c_str()));
|
||||
cJSON_AddItemToObject(retJson, "ret", cJSON_CreateNumber(ret));
|
||||
if (0 != ret)
|
||||
cJSON_AddItemToObject(retJson, "err_info", cJSON_CreateString(StdStringToUtf8(errInfo).c_str()));
|
||||
else
|
||||
cJSON_AddItemToObject(retJson, "fwversion", cJSON_CreateString(StdStringToUtf8(fwVersion).c_str()));
|
||||
|
||||
char* resp = cJSON_Print(retJson);
|
||||
if (NULL != resp)
|
||||
{
|
||||
SendResponse((const HGByte*)resp, (HGUInt)strlen(resp), HGTRUE);
|
||||
free(resp);
|
||||
}
|
||||
|
||||
cJSON_Delete(retJson);
|
||||
}
|
||||
}
|
||||
|
||||
void WSUser::SetDeviceParam(cJSON* json)
|
||||
{
|
||||
assert(NULL != json);
|
||||
|
|
|
@ -58,6 +58,7 @@ namespace ver_2
|
|||
void OpenDevice(cJSON* json);
|
||||
void CloseDevice(cJSON* json);
|
||||
void GetDeviceSN(cJSON* json);
|
||||
void GetDeviceFWVersion(cJSON* json);
|
||||
void SetDeviceParam(cJSON* json);
|
||||
void GetDeviceParam(cJSON* json);
|
||||
void ResetDeviceParam(cJSON* json);
|
||||
|
|
Loading…
Reference in New Issue