Initializing the SDK
Init
API Description
This API is used to start and initialize the SDK.
Precautions
- Before calling this API, change the name of the HwmSdk.exe file in the HwmSdk folder to your desired name.
- You must call this API successfully and receive the callback result before calling other APIs.
- Each time the initialization API is called, the SDK is restarted, and all the previous settings and operations are cleared.
- This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.
Method Definition
1
|
HWM_SDK_AGENT_API hwmsdk::HwmErrCode Init(HwmInitInfo *initInfo); |
Callback Function
1
|
virtual void OnInitResult(hwmsdk::HwmErrCode ret, const char* reason, HwmSdkInfo *sdkInfo) {}; |
Parameter Description
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
exePath |
Mandatory for the x64 platform |
char[] |
SDK startup path, that is, the absolute path of the .exe file in the HwmSdk folder of the SDK package. Before calling this API, change the name of the HwmSdk.exe file in the HwmSdk folder of the SDK package to your desired name. Assume that the path of the HwmSdk folder is D:\MyApp\SDK\HwmSdk\ and the name of the .exe file is MySdk.exe. Then set this parameter to D:\MyApp\SDK\HwmSdk\MySdk.exe. UTF-8 encoding is required. |
logPath |
Yes |
char[] |
SDK log path. If this parameter is not set, the default path is used. UTF-8 encoding is required. |
userDataPath |
Yes |
char[] |
SDK user data path. If this parameter is not set, the default path is used. UTF-8 encoding is required. |
appId |
Yes |
char[] |
App ID. For details about how to request an app ID, see Requesting an App ID in Developer Guide. |
notify |
Yes |
HwmAgentNotify |
Notification object, which is the object of the class inherited from the base class HwmAgentNotify. |
callback |
Yes |
HwmAgentCallback |
API callback object, which is the object of the class inherited from the base class HwmAgentCallback. |
authType |
Yes |
HwmAuthType |
Authentication mode. |
siteType |
No |
HwmSiteType |
Site type. The default value is 0, indicating that Chinese mainland site is used. |
logKeepDays |
No |
unsigned int |
Log storage duration. Valid value range is 3–30. The default value is 0. 0 indicates that logs are not deleted by day. Note: 1 and 2 will be converted to 3, and the values greater than 30 will be converted to 30. |
preferredCamera |
No |
char[] |
Preferred camera list. After this parameter is set, the first available camera is selected based on the sequence in the list when the camera is opened for the first time. This parameter can be left empty. If it is left empty, available cameras are enabled in the default sequence. |
isSupportMultiAppLogin |
No |
bool |
Whether to support login to multiple applications on the same device. This function is disabled by default. |
Enumerated Value |
Description |
---|---|
HWM_AUTH_TYPE_ACCOUNT_AND_PASSWORD |
Account and password authentication. |
HWM_AUTH_TYPE_APPID |
App ID authentication. |
Enumerated Value |
Description |
---|---|
SITE_TYPE_CHINA |
Chinese mainland. |
SITE_TYPE_AP |
Asia Pacific. |
Parameter |
Type |
Description |
---|---|---|
version |
char[] |
SDK version number. |
App ID authentication mode is recommended. For details about how to request an app ID, see section "Requesting an App ID" in Developer Guide.
Return Values
Type |
Description |
---|---|
HwmErrCode |
If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
// Create a notification processing object. static demoNotifyProc *notifyObj = new demoNotifyProc(); // Create a callback function processing object. static demoCallbackProc *callbackObj = new demoCallbackProc(); /** * Call the initialization API and start the application. */ int CdemoBeforeLoginDlg::Init() { // Assemble the input parameter structure. hwmsdkagent::HwmInitInfo initParam; memset(&initParam, 0, sizeof(HwmInitInfo)); // (Not required for Win32) Configure the SDK path, that is, the .exe file path, for the x64 platform after renaming the .exe file. // Convert the SDK path into the UTF-8 format and copy it to initParam. The conversion code is omitted here. strcpy_s(initParam.exePath, HWM_MAX_FILE_PATH_LEN, GetHwmSdkExePath().c_str()); // Specify the log path, convert the path into the UTF-8 format, and copy the converted path to initParam. The conversion code is omitted here. strcpy_s(initParam.logPath, HWM_MAX_FILE_PATH_LEN, GetLogPath().c_str()); // Specify the data path, convert the path into the UTF-8 format, and copy the converted path to initParam. The conversion code is omitted here. strcpy_s(initParam.userDataPath, HWM_MAX_FILE_PATH_LEN, GetUserDataPath().c_str()); // Pass the requested enterprise app ID. strncpy_s(initParam.appId, GetAppId.c_str(), HWM_MAX_APPID_LEN); initParam.notify = notifyObj; initParam.callback = callbackObj; initParam.authType = hwmsdkagent::HWM_AUTH_TYPE_APPID; int ret = hwmsdkagent::Init(&initParam); return ret; } |
- The sample code in the typical scenario and API reference is pseudo code and cannot be directly used.
- For details about the definitions of the message notification processing class demoNotifyProc and callback function processing class demoCallbackProc, see the demo code in the SDK package.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot