//Secure Virtual Resource database for Iotivity Client application
//It contains Client's Identity and the PSK credentials
//of other devices which the client trusts
-static char CRED_FILE[] = "oic_svr_db_client.json";
+static char CRED_FILE[] = "oic_svr_db_client.dat";
int gQuitFlag = 0;
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
- OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
- OC_LOG(INFO, TAG, "-t 1 : Discover Resources");
- OC_LOG(INFO, TAG, "-t 2 : Discover Resources and"
+ OIC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
+ OIC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
+ OIC_LOG(INFO, TAG, "-t 1 : Discover Resources");
+ OIC_LOG(INFO, TAG, "-t 2 : Discover Resources and"
" Initiate Nonconfirmable Get/Put/Post Requests");
- OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get/Put/Post Requests");
- OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
- OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
+ OIC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get/Put/Post Requests");
+ OIC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
+ OIC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
}
OCStackResult InvokeOCDoResource(std::ostringstream &query,
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
+ OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
}
return ret;
OCStackApplicationResult putReqCB(void*, OCDoHandle, OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
if(clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Put Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Put Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult postReqCB(void *, OCDoHandle, OCClientResponse *clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
if(clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Post Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Post Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult getReqCB(void*, OCDoHandle, OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
if(clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Get Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Get Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult discoveryReqCB(void*, OCDoHandle,
OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG,
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG,
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
if (clientResponse->result == OC_STACK_OK)
{
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
ocConnType = clientResponse->connType;
endpoint = clientResponse->devAddr;
int InitPutRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
int InitPostRequest(OCQualityOfService qos)
{
OCStackResult result;
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(INFO, TAG, "First POST call did not succeed");
+ OIC_LOG(INFO, TAG, "First POST call did not succeed");
}
// Second POST operation (to create an LED instance)
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
{
- OC_LOG(INFO, TAG, "Second POST call did not succeed");
+ OIC_LOG(INFO, TAG, "Second POST call did not succeed");
}
// This POST operation will update the original resourced /a/led
int InitGetRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
if (UnicastDiscovery)
{
- OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
- OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
- OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+ OIC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+ OIC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+ OIC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
if (fgets(ipaddr, sizeof (ipaddr), stdin))
{
}
else
{
- OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
+ OIC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
return OC_STACK_INVALID_PARAM;
}
}
cbData.cd = NULL;
/* Start a discovery query*/
- OC_LOG_V(INFO, TAG, "Initiating %s Resource Discovery : %s\n",
+ OIC_LOG_V(INFO, TAG, "Initiating %s Resource Discovery : %s\n",
(UnicastDiscovery) ? "Unicast" : "Multicast",
queryUri);
OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
}
else
{
- OC_LOG(INFO, TAG, "Using Default Connectivity type");
+ OIC_LOG(INFO, TAG, "Using Default Connectivity type");
PrintUsage();
}
/* Initialize OCStack*/
if (OCInit(NULL, 0, OC_CLIENT_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
timeout.tv_nsec = 100000000L;
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
nanosleep(&timeout, NULL);
}
- OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
while (res)
{
coapServerResource.assign(res->uri);
- OC_LOG_V(INFO, TAG, "Uri -- %s", coapServerResource.c_str());
+ OIC_LOG_V(INFO, TAG, "Uri -- %s", coapServerResource.c_str());
if (res->secure)
{
coapSecureResource = 1;
}
- OC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
+ OIC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
// If we discovered a secure resource, exit from here
if (coapSecureResource)