#include "ocpayload.h"
#include "payload_logging.h"
+#ifdef ROUTING_GATEWAY
+/**
+ * Maximum number of gateway requests to form the routing table.
+ */
+#define MAX_NUM_GATEWAY_REQUEST 20
+
+/**
+ * Sleep duration after every OCProcess().
+ */
+#define SLEEP_DURATION 100000
+#endif
// Tracking user input
static int UnicastDiscovery = 0;
static int TestCase = 0;
if (clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Put Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Put Response"));
}
else
{
if (clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Post Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Post Response"));
}
else
{
if (clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Delete Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Delete Response"));
}
else
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Get Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Get Response"));
if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
{
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
OC_LOG_V(INFO, TAG, "Callback Context for OBSERVE notification recvd successfully %d",
gNumObserveNotifies);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Obs Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Obs Response"));
gNumObserveNotifies++;
if (gNumObserveNotifies == 15) //large number to test observing in DELETE case.
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "Callback Context for Presence notification recvd successfully %d",
gNumPresenceNotifies);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Presence Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Presence Response"));
gNumPresenceNotifies++;
if (gNumPresenceNotifies == 20)
{
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
ConnType = clientResponse->connType;
serverAddr = clientResponse->devAddr;
if (clientResponse)
{
- OC_LOG(INFO, TAG, PCF("Discovery Response:"));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("Discovery Response:"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
if (clientResponse)
{
- OC_LOG(INFO, TAG, PCF("Discovery Response:"));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("Discovery Response:"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
return 0;
}
+#ifdef ROUTING_GATEWAY
+ /*
+ * Before invoking Discover resource, we process the gateway requests
+ * and form the routing table.
+ */
+ for (int index = 0; index < MAX_NUM_GATEWAY_REQUEST; index++)
+ {
+ if (OC_STACK_OK != OCProcess())
+ {
+ OC_LOG(ERROR, TAG, "OCStack process error");
+ return 0;
+ }
+ usleep(SLEEP_DURATION);
+ }
+#endif
if (Connectivity == CT_ADAPTER_DEFAULT || Connectivity == CT_IP)
{
ConnType = CT_ADAPTER_IP;
OC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
-
- sleep(2);
+#ifndef ROUTING_GATEAWAY
+ sleep(1);
+#endif
}
OC_LOG(INFO, TAG, "Exiting occlient main loop...");