iotcon_query_destroy(hquery);
return false;
}
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hquery, IotcoRemoteResourceMonitoringCB , NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hquery, IotcoRemoteResourceMonitoringCB , NULL);
if (IOTCON_ERROR_NONE != nRet)
{
FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
if (g_found)
return false;
+ g_found = true;
+
if(resource == NULL)
{
FPRINTF("[Line : %d][%s] IotcoRemoteResourceMonitoringCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
iotcon_remote_resource_get_host_address(resource, &host_address);
iotcon_remote_resource_get_uri_path(resource, &uri);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected uri[%s], found uri[%s]", __FUNCTION__, __LINE__, REMOTE_RESOURCE_LIGHT, uri);
- if (strncmp(uri, REMOTE_RESOURCE_LIGHT, strlen(REMOTE_RESOURCE_LIGHT)) != 0) {
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected host_address[%s], found host_address[%s]", __FUNCTION__, __LINE__, g_ipv4_address, host_address);
+
+ if (strstr(host_address, g_ipv4_address) == NULL) { // targeted resource, BUT wrong device, so skip this resource and try again
g_found = false;
return true;
}
- g_found = true;
g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
if (IOTCON_ERROR_NONE != g_nCheckAPICb)
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceCachingCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceCachingCB, NULL);
if (IOTCON_ERROR_NONE != nRet)
{
FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
if (g_found)
return false;
+ g_found = true;
+
if(resource == NULL)
{
FPRINTF("[Line : %d][%s] IotconRemoteResourceCachingCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
iotcon_remote_resource_get_host_address(resource, &host_address);
iotcon_remote_resource_get_uri_path(resource, &uri);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected uri[%s], found uri[%s]", __FUNCTION__, __LINE__, LIGHT_RESOURCE_URI, uri);
- if (strncmp(uri, LIGHT_RESOURCE_URI, strlen(LIGHT_RESOURCE_URI)) != 0) {
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected host_address[%s], found host_address[%s]", __FUNCTION__, __LINE__, g_ipv4_address, host_address);
+
+ if (strstr(host_address, g_ipv4_address) == NULL) { // targeted resource, BUT wrong device, so skip this resource and try again
g_found = false;
return true;
}
- g_found = true;
g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
if (IOTCON_ERROR_NONE != g_nCheckAPICb)
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceRepresentationCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceRepresentationCB, NULL);
if (IOTCON_ERROR_NONE != nRet)
{
FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
if (g_found)
return false;
+ g_found = true;
+
+
if(resource == NULL)
{
FPRINTF("[Line : %d][%s] IotconRemoteResourceRepresentationCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
iotcon_remote_resource_get_host_address(resource, &host_address);
iotcon_remote_resource_get_uri_path(resource, &uri);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected uri[%s], found uri[%s]", __FUNCTION__, __LINE__, LIGHT_RESOURCE_URI, uri);
- if (strncmp(uri, LIGHT_RESOURCE_URI, strlen(LIGHT_RESOURCE_URI)) != 0) {
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected host_address[%s], found host_address[%s]", __FUNCTION__, __LINE__, g_ipv4_address, host_address);
+
+ if (strstr(host_address, g_ipv4_address) == NULL) { // targeted resource, BUT wrong device, so skip this resource and try again
g_found = false;
return true;
}
- g_found = true;
g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
if (IOTCON_ERROR_NONE != g_nCheckAPICb)
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP,hQuery, IotconRemoteResourceOptionsCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceOptionsCB, NULL);
if (IOTCON_ERROR_NONE != nRet)
{
FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
if (g_found)
return false;
+ g_found = true;
+
+
if(resource == NULL)
{
FPRINTF("[Line : %d][%s] Iotcon_presence_found_resource_cb input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
iotcon_remote_resource_get_host_address(resource, &host_address);
iotcon_remote_resource_get_uri_path(resource, &uri);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected uri[%s], found uri[%s]", __FUNCTION__, __LINE__, LIGHT_RESOURCE_URI, uri);
- if (strncmp(uri, LIGHT_RESOURCE_URI, strlen(LIGHT_RESOURCE_URI)) != 0) {
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected host_address[%s], found host_address[%s]", __FUNCTION__, __LINE__, g_ipv4_address, host_address);
+
+ if (strstr(host_address, g_ipv4_address) == NULL) { // targeted resource, BUT wrong device, so skip this resource and try again
g_found = false;
return true;
}
- g_found = true;
nRet = iotcon_remote_resource_clone(resource, &g_hResourceHandle);
if (IOTCON_ERROR_NONE != nRet)
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceGetPutPostDelCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceGetPutPostDelCB, NULL);
if (IOTCON_ERROR_NONE != nRet)
{
FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
if (g_found)
return false;
+ g_found = true;
+
+
if(resource == NULL)
{
FPRINTF("[Line : %d][%s] Iotcon_remote_resource_observe_cb_p input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
iotcon_remote_resource_get_host_address(resource, &host_address);
iotcon_remote_resource_get_uri_path(resource, &uri);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected uri[%s], found uri[%s]", __FUNCTION__, __LINE__, LIGHT_RESOURCE_URI, uri);
- if (strncmp(uri, LIGHT_RESOURCE_URI, strlen(LIGHT_RESOURCE_URI)) != 0) {
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected host_address[%s], found host_address[%s]", __FUNCTION__, __LINE__, g_ipv4_address, host_address);
+
+ if (strstr(host_address, g_ipv4_address) == NULL) { // targeted resource, BUT wrong device, so skip this resource and try again
g_found = false;
return true;
}
- g_found = true;
g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
if (IOTCON_ERROR_NONE != g_nCheckAPICb)
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceObserveCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceObserveCB, NULL);
if (IOTCON_ERROR_NONE != nRet)
{
FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
if (g_found)
return false;
+ g_found = true;
+
if(resource == NULL)
{
FPRINTF("[Line : %d][%s] IotconRemoteResourceObserveCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
iotcon_remote_resource_get_host_address(resource, &host_address);
iotcon_remote_resource_get_uri_path(resource, &uri);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected uri[%s], found uri[%s]", __FUNCTION__, __LINE__, LIGHT_RESOURCE_URI, uri);
- if (strncmp(uri, LIGHT_RESOURCE_URI, strlen(LIGHT_RESOURCE_URI)) != 0) {
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] expected host_address[%s], found host_address[%s]", __FUNCTION__, __LINE__, g_ipv4_address, host_address);
+
+ if (strstr(host_address, g_ipv4_address) == NULL) { // targeted resource, BUT wrong device, so skip this resource and try again
g_found = false;
return true;
}
- g_found = true;
g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
if (IOTCON_ERROR_NONE != g_nCheckAPICb)
g_bIotconConnect = true;
g_bFeatureUnsupported = false;
+ icitc_get_client_ipv4_address();
+
ic_get_svr_db_path(&svr_db_path);
int nRet = iotcon_initialize(svr_db_path);
free(svr_db_path);
*/
void ITs_iotcon_remote_resource_cleanup(void)
{
+ icitc_free_client_ipv4_address();
+
if( g_bIotconConnect )
{
iotcon_deinitialize();
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceObserveCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceObserveCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet),IotconDestroyLiteResource();iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceGetPutPostDelCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceGetPutPostDelCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet),IotconDestroyLiteResource();iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceCachingCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceCachingCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource(); iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotcoRemoteResourceMonitoringCB , NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotcoRemoteResourceMonitoringCB , NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyResource();iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP,hQuery, IotconRemoteResourceOptionsCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceOptionsCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource();iotcon_query_destroy(hQuery););
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP,hQuery,IotconRemoteResourceOptionsCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery,IotconRemoteResourceOptionsCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource(); iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP, hQuery, IotconRemoteResourceRepresentationCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery, IotconRemoteResourceRepresentationCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource();iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;
nRet = iotcon_query_set_resource_type(hQuery, LIGHT_RESOURCE_TYPE);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_query_set_resource_type", IotConGetError(nRet),iotcon_query_destroy(hQuery));
- nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP |IOTCON_CONNECTIVITY_PREFER_UDP,hQuery,IotconRemoteResourceOptionsCB, NULL);
+ nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP | IOTCON_CONNECTIVITY_IPV4_ONLY, hQuery,IotconRemoteResourceOptionsCB, NULL);
PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource();iotcon_query_destroy(hQuery));
RUN_POLLING_LOOP;