Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Initializing the SDK

Updated on 2024-07-30 GMT+08:00

Init

API Description

This API is used to start and initialize the SDK.

Precautions

  1. Before calling this API, change the name of the HwmSdk.exe file in the HwmSdk folder to your desired name.
  2. You must call this API successfully and receive the callback result before calling other APIs.
  3. Each time the initialization API is called, the SDK is restarted, and all the previous settings and operations are cleared.
  4. 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

Table 1 HwmInitInfo 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.

Table 2 Enumerated values of HwmAuthType

Enumerated Value

Description

HWM_AUTH_TYPE_ACCOUNT_AND_PASSWORD

Account and password authentication.

HWM_AUTH_TYPE_APPID

App ID authentication.

Table 3 Enumerated values of HwmSiteType

Enumerated Value

Description

SITE_TYPE_CHINA

Chinese mainland.

SITE_TYPE_AP

Asia Pacific.

Table 4 HwmSdkInfo description

Parameter

Type

Description

version

char[]

SDK version number.

NOTE:

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

Table 5 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.

Sample Code
 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;
}
NOTE:
  • 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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback