Initializing LiteOS SDK Device-Cloud Interconnect Components
Call the atiny_init() function in the entrypoint function to initialize Agent Tiny.
Function |
Description |
---|---|
int atiny_init(atiny_param_t* atiny_params, void** phandle); |
Function for initializing device-cloud interconnect components, which is implemented by device-cloud interconnect components and invoked by devices. The parameters involved are as follows:
|
The input parameter atiny_params needs to be set based on specific services. Developers can set the parameter by the following code:
#ifdef CONFIG_FEATURE_FOTA hal_init_ota(); //To define the FOTA functions, perform FOTA-related initialization. #endif #ifdef WITH_DTLS device_info->endpoint_name = g_endpoint_name_s; //Encrypted device verification code #else device_info->endpoint_name = g_endpoint_name; //Unencrypted device verification code #endif #ifdef CONFIG_FEATURE_FOTA device_info->manufacturer = "Lwm2mFota"; //Unencrypted device verification code device_info->dev_type = "Lwm2mFota"; //Device type #else device_info->manufacturer = "Agent_Tiny"; #endif atiny_params = &g_atiny_params; atiny_params->server_params.binding = "UQ"; //Binding mode atiny_params->server_params.life_time = 20; //Life cycle atiny_params->server_params.storing_cnt = 0; //Number of cached data packets atiny_params->server_params.bootstrap_mode = BOOTSTRAP_FACTORY; //Boot mode atiny_params->server_params.hold_off_time = 10; //Waiting latency //pay attention: index 0 for iot server, index 1 for bootstrap server. iot_security_param = &(atiny_params->security_params[0]); bs_security_param = &(atiny_params->security_params[1]); iot_security_param->server_ip = DEFAULT_SERVER_IPV4; //Server address bs_security_param->server_ip = DEFAULT_SERVER_IPV4; #ifdef WITH_DTLS iot_security_param->server_port = "5684"; //Encrypted device port number bs_security_param->server_port = "5684"; iot_security_param->psk_Id = g_endpoint_name_iots; //Encrypted device verification iot_security_param->psk = (char *)g_psk_iot_value; //PSK password iot_security_param->psk_len = sizeof(g_psk_iot_value); //PSK password length bs_security_param->psk_Id = g_endpoint_name_bs; bs_security_param->psk = (char *)g_psk_bs_value; bs_security_param->psk_len = sizeof(g_psk_bs_value); #else iot_security_param->server_port = "5683"; //Unencrypted device port number bs_security_param->server_port = "5683"; iot_security_param->psk_Id = NULL; //No PSK-related parameter setting for unencrypted devices iot_security_param->psk = NULL; iot_security_param->psk_len = 0; bs_security_param->psk_Id = NULL; bs_security_param->psk = NULL; bs_security_param->psk_len = 0; #endif
After setting the atiny_params parameter, initialize Agent Tiny based on the set parameter.
if(ATINY_OK != atiny_init(atiny_params, &g_phandle)) { return; }
After setting the atiny_params parameter, initialize Agent Tiny based on the set parameter.
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