void collectUniqueResource(const OCClientResponse * clientResponse) { char * sid = NULL; char ** uri = NULL; int totalRes = 0; if(parseJSON(clientResponse->resJSONPayload, & sid, & uri, &totalRes) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "Error while parsing JSON payload in OCClientResponse"); OICFree(sid); OICFree(uri); return; } int i; for(i = 0; i < totalRes; i++) { if(insertResource(sid, uri[i], clientResponse) == 1) { printf("%s%s%s%s\n",sid, ":", uri[i], " is new"); printResourceList(); queryResource(); } else { printf("%s%s%s%s\n\n",sid, ":", uri[i], " has been seen before"); } } OICFree(sid); OICFree(uri); }
void collectUniqueResource(const OCClientResponse * clientResponse) { OCResourcePayload* res = ((OCDiscoveryPayload*)clientResponse->payload)->resources; char sidStr[UUID_LENGTH]; while(res) { int ret = snprintf(sidStr, UUID_LENGTH, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", res->sid[0], res->sid[1], res->sid[2], res->sid[3], res->sid[4], res->sid[5], res->sid[6], res->sid[7], res->sid[8], res->sid[9], res->sid[10], res->sid[11], res->sid[12], res->sid[13], res->sid[14], res->sid[15] ); if (ret == UUID_LENGTH - 1) { if(insertResource(sidStr, res->uri, clientResponse) == 1) { OC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is new"); printResourceList(); queryResource(); } else { OC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is old"); } } else { OC_LOG(ERROR, TAG, "Could Not Retrieve the Server ID"); } res = res->next; } }
void collectUniqueResource(const OCClientResponse * clientResponse) { OCResourcePayload* res = ((OCDiscoveryPayload*)clientResponse->payload)->resources; // Including the NUL terminator, length of UUID string of the form: // "a62389f7-afde-00b6-cd3e-12b97d2fcf09" # define UUID_LENGTH 37 char sidStr[UUID_LENGTH]; while(res) { int ret = snprintf(sidStr, UUID_LENGTH, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", res->sid[0], res->sid[1], res->sid[2], res->sid[3], res->sid[4], res->sid[5], res->sid[6], res->sid[7], res->sid[8], res->sid[9], res->sid[10], res->sid[11], res->sid[12], res->sid[13], res->sid[14], res->sid[15] ); if (ret == UUID_LENGTH - 1) { if(insertResource(sidStr, res->uri, clientResponse) == 1) { OC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is new"); printResourceList(); queryResource(); } else { OC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is old"); } } else { OC_LOG(ERROR, TAG, "Could Not Retrieve the Server ID"); } res = res->next; } }