Commit f6394a48 authored by Philippe Coval's avatar Philippe Coval Committed by Nathan Heldt-Sheller

resource: Fix occlientbasicops to support coaps

The fix is to do querry only on resource's address (to use CoAPs channel)

Observed issue was:

 ./ocserverbasicops

  ./occlientbasicops -u 0 -c 0 -d 1 -p 0 -t 2
  (...)

  INFO: occlientbasicops: Callback Context for GET query recvd successfully
  INFO: occlientbasicops: StackResult: OC_STACK_UNAUTHORIZED_REQ
  INFO: occlientbasicops: SEQUENCE NUMBER: 16777216
  INFO: PayloadLog: NULL Payload
  INFO: occlientbasicops: =============> Get Response

I fixed it to:

  INFO: occlientbasicops: StackResult: OC_STACK_OK (...)
  INFO: PayloadLog: Payload Type: Representation (...)
  INFO: PayloadLog:     URI:/a/led (...)
  INFO: PayloadLog:             state(bool):false (...)

Extra note, it look like the parse function is never returning false.

Change-Id: Id3e48c8a04453e87a09e7636ead9a9f64c499d44
Bug: https://jira.iotivity.org/browse/IOT-2390
Origin: https://gerrit.iotivity.org/gerrit/#/c/23637/Signed-off-by: default avatarPhilippe Coval <philippe.coval@osg.samsung.com>
parent 83a52aba
......@@ -36,6 +36,10 @@ const char *getResult(OCStackResult result) {
return "OC_STACK_RESOURCE_CREATED";
case OC_STACK_RESOURCE_DELETED:
return "OC_STACK_RESOURCE_DELETED";
case OC_STACK_CONTINUE:
return "OC_STACK_CONTINUE";
case OC_STACK_RESOURCE_CHANGED:
return "OC_STACK_RESOURCE_CHANGED";
case OC_STACK_INVALID_URI:
return "OC_STACK_INVALID_URI";
case OC_STACK_INVALID_QUERY:
......@@ -48,12 +52,18 @@ const char *getResult(OCStackResult result) {
return "OC_STACK_INVALID_CALLBACK";
case OC_STACK_INVALID_METHOD:
return "OC_STACK_INVALID_METHOD";
case OC_STACK_INVALID_PARAM:
return "OC_STACK_INVALID_PARAM";
case OC_STACK_INVALID_OBSERVE_PARAM:
return "OC_STACK_INVALID_OBSERVE_PARAM";
case OC_STACK_NO_MEMORY:
return "OC_STACK_NO_MEMORY";
case OC_STACK_COMM_ERROR:
return "OC_STACK_COMM_ERROR";
case OC_STACK_INVALID_PARAM:
return "OC_STACK_INVALID_PARAM";
case OC_STACK_TIMEOUT:
return "OC_STACK_TIMEOUT";
case OC_STACK_ADAPTER_NOT_ENABLED:
return "OC_STACK_ADAPTER_NOT_ENABLED";
case OC_STACK_NOTIMPL:
return "OC_STACK_NOTIMPL";
case OC_STACK_NO_RESOURCE:
......@@ -62,14 +72,48 @@ const char *getResult(OCStackResult result) {
return "OC_STACK_RESOURCE_ERROR";
case OC_STACK_SLOW_RESOURCE:
return "OC_STACK_SLOW_RESOURCE";
case OC_STACK_DUPLICATE_REQUEST:
return "OC_STACK_DUPLICATE_REQUEST";
case OC_STACK_NO_OBSERVERS:
return "OC_STACK_NO_OBSERVERS";
case OC_STACK_OBSERVER_NOT_FOUND:
return "OC_STACK_OBSERVER_NOT_FOUND";
case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
return "OC_STACK_VIRTUAL_DO_NOT_HANDLE";
case OC_STACK_INVALID_OPTION:
return "OC_STACK_INVALID_OPTION";
case OC_STACK_MALFORMED_RESPONSE:
return "OC_STACK_MALFORMED_RESPONSE";
case OC_STACK_INVALID_REQUEST_HANDLE:
return "OC_STACK_INVALID_REQUEST_HANDLE";
case OC_STACK_INVALID_DEVICE_INFO:
return "OC_STACK_INVALID_DEVICE_INFO";
case OC_STACK_INVALID_JSON:
return "OC_STACK_INVALID_JSON";
case OC_STACK_UNAUTHORIZED_REQ:
return "OC_STACK_UNAUTHORIZED_REQ";
case OC_STACK_TOO_LARGE_REQ:
return "OC_STACK_TOO_LARGE_REQ";
#ifdef WITH_PRESENCE
case OC_STACK_PRESENCE_STOPPED:
return "OC_STACK_PRESENCE_STOPPED";
case OC_STACK_PRESENCE_TIMEOUT:
return "OC_STACK_PRESENCE_TIMEOUT";
case OC_STACK_PRESENCE_DO_NOT_HANDLE:
return "OC_STACK_PRESENCE_DO_NOT_HANDLE";
#endif
case OC_STACK_USER_DENIED_REQ:
return "OC_STACK_USER_DENIED_REQ";
case OC_STACK_NOT_ACCEPTABLE:
return "OC_STACK_NOT_ACCEPTABLE";
case OC_STACK_FORBIDDEN_REQ:
return "OC_STACK_FORBIDDEN_REQ";
case OC_STACK_INTERNAL_SERVER_ERROR:
return "OC_STACK_INTERNAL_SERVER_ERROR";
case OC_STACK_GATEWAY_TIMEOUT:
return "OC_STACK_GATEWAY_TIMEOUT";
case OC_STACK_SERVICE_UNAVAILABLE:
return "OC_STACK_SERVICE_UNAVAILABLE";
case OC_STACK_ERROR:
return "OC_STACK_ERROR";
default:
......
......@@ -68,11 +68,13 @@ static char CRED_FILE_NONDEVOWNER[] = "oic_svr_db_client_nondevowner.dat";
const char * OIC_STD_URI_PREFIX = "/oic/";
const char * COAPS_STR = "coaps";
#ifdef __WITH_TLS__
const char * COAPS_TCP_STR = "coaps+tcp";
#endif
int gQuitFlag = 0;
static const char *gResourceUri = "/a/led";
/* SIGINT handler: set gQuitFlag to 1 for graceful termination */
void handleSigInt(int signum)
......@@ -206,18 +208,32 @@ OCStackApplicationResult discoveryReqCB(void *, OCDoHandle,
if (parseClientResponse(clientResponse) != -1)
{
switch (TestCase)
OCDiscoveryPayload *payload = (OCDiscoveryPayload *) clientResponse->payload;
OCResourcePayload *resource = (OCResourcePayload *) payload->resources;
for (;resource; resource = resource->next)
{
case TEST_NON_CON_OP:
InitGetRequest(&clientResponse->devAddr, OC_LOW_QOS);
InitPutRequest(&clientResponse->devAddr, OC_LOW_QOS);
InitPostRequest(&clientResponse->devAddr, OC_LOW_QOS);
break;
case TEST_CON_OP:
InitGetRequest(&clientResponse->devAddr, OC_HIGH_QOS);
InitPutRequest(&clientResponse->devAddr, OC_HIGH_QOS);
InitPostRequest(&clientResponse->devAddr, OC_HIGH_QOS);
if ((0 == strcmp(gResourceUri, resource->uri))
&& (0 == strcmp(COAPS_STR, resource->eps->tps)))
{
OCDevAddr* endpoint = &clientResponse->devAddr;
strcpy(endpoint->addr, resource->eps->addr);
endpoint->port = resource->eps->port;
endpoint->flags = resource->eps->family;
switch (TestCase)
{
case TEST_NON_CON_OP:
InitGetRequest(endpoint, OC_LOW_QOS);
InitPutRequest(endpoint, OC_LOW_QOS);
InitPostRequest(endpoint, OC_LOW_QOS);
break;
case TEST_CON_OP:
InitGetRequest(endpoint, OC_HIGH_QOS);
InitPutRequest(endpoint, OC_HIGH_QOS);
InitPostRequest(endpoint, OC_HIGH_QOS);
break;
}
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment