// create remote endpoint
CAEndpoint_t *endpoint = NULL;
- res = CACreateEndpoint(CA_DEFAULT_FLAGS, g_selectedNwType, NULL, 0, &endpoint);
+ res = CACreateEndpoint(CA_IPV4, g_selectedNwType, NULL, 0, &endpoint);
if (CA_STATUS_OK != res)
{
{
LOGI("uri has '%s' prefix", COAP_PREFIX);
startIndex = COAP_PREFIX_LEN;
- *flags = CA_DEFAULT_FLAGS;
+ *flags = CA_IPV4;
}
// #2. copy uri for parse
}
// create remote endpoint
- CAEndpoint_t *endpoint = NULL;
- res = CACreateEndpoint(0, g_selected_nw_type, NULL, 0, &endpoint);
+ CAEndpoint_t *group = NULL;
+ res = CACreateEndpoint(CA_IPV4, g_selected_nw_type, NULL, 0, &group);
if (CA_STATUS_OK != res)
{
printf("Create remote endpoint error, error code: %d\n", res);
return;
}
- CAEndpoint_t *group = (CAEndpoint_t *) malloc(sizeof(CAEndpoint_t));
- if (NULL == group)
- {
- printf("Memory allocation failed!\n");
- CADestroyEndpoint(endpoint);
- return;
- }
- group->adapter = endpoint->adapter;
-
// create token
CAToken_t token = NULL;
uint8_t tokenLength = CA_MAX_TOKEN_LEN;
if ((CA_STATUS_OK != res) || (!token))
{
printf("Token generate error!!\n");
- CADestroyEndpoint(endpoint);
- free(group);
+ CADestroyEndpoint(group);
return;
}
}
// destroy remote endpoint
- CADestroyEndpoint(endpoint);
- free(group);
+ CADestroyEndpoint(group);
printf("=============================================\n");
}
{
printf("uri has '%s' prefix\n", COAP_PREFIX);
startIndex = COAP_PREFIX_LEN;
- *flags = CA_DEFAULT_FLAGS;
+ *flags = CA_IPV4;
}
// #2. copy uri for parse