//\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
+#include "iotivity_config.h"\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <string.h>\r
#include <signal.h>\r
+#ifdef HAVE_UNISTD_H\r
#include <unistd.h>\r
+#endif\r
+#ifdef HAVE_PTHREAD_H\r
#include <pthread.h>\r
+#endif\r
#include <iostream>\r
#include <sstream>\r
+#if defined(HAVE_WINDOWS_H)\r
+#include <windows.h>\r
+/** @todo stop-gap for naming issue. Windows.h does not like us to use ERROR */\r
+#ifdef ERROR\r
+#undef ERROR\r
+#endif\r
+#endif // defined(HAVE_WINDOWS_H)\r
#include "ocstack.h"\r
#include "logger.h"\r
#include "ocpayload.h"\r
//Secure Virtual Resource database for Iotivity Client application\r
//It contains Client's Identity and the PSK credentials\r
//of other devices which the client trusts\r
-static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";
-
+static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";\r
+\r
static const OCDPDev_t *discoveredDevs = NULL;\r
static const OCDPDev_t *pairedDevs = NULL;\r
\r
/* Start a discovery query*/\r
OIC_LOG_V(INFO, TAG, "Resource Discovery : %s\n", queryUri);\r
\r
- ret = OCDoResource(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,\r
- OC_LOW_QOS, &cbData, NULL, 0);\r
+ ret = OCDoRequest(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,\r
+ OC_LOW_QOS, &cbData, NULL, 0);\r
if (ret != OC_STACK_OK)\r
{\r
OIC_LOG(ERROR, TAG, "OCStack resource error");\r
cbData.cd = NULL;\r
\r
OIC_LOG(INFO, TAG, "Request to /a/light ");\r
- ret = OCDoResource(&handle, OC_REST_GET, szQueryUri,\r
- &endpoint, NULL, peer->connType, OC_LOW_QOS, &cbData, NULL, 0);\r
+ ret = OCDoRequest(&handle, OC_REST_GET, szQueryUri,\r
+ &endpoint, NULL, peer->connType, OC_LOW_QOS, &cbData, NULL, 0);\r
if (ret != OC_STACK_OK)\r
{\r
OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, OC_REST_GET);\r
\r
void *CLInterface(void *data)\r
{\r
- printf(RED_BEGIN"#Ready to operation ('h' for help)#\n"COLOR_END);\r
+ printf(RED_BEGIN "#Ready to operation ('h' for help)#\n" COLOR_END);\r
\r
(void)data;\r
OCStackResult ret;\r
- char query[MAX_LINE] = {0,};\r
- const char prompt[] = BOLD_BEGIN"IoTivity-DP#"COLOR_END" ";\r
+ char query[MAX_LINE] = {0};\r
+ const char prompt[] = BOLD_BEGIN "IoTivity-DP#" COLOR_END" ";\r
const char* helpmsg[6] = {\r
- GREEN_BEGIN"# h (or help) : show help message"COLOR_END,\r
- GREEN_BEGIN"# dd (DP device discovery) : discover Direct-Pairing devices"COLOR_END,\r
- GREEN_BEGIN"# dp (start Direct-Pairing) : negotiate DP method & start Direct-Pairing"COLOR_END,\r
- GREEN_BEGIN"# sd (send data) : send data to device"COLOR_END,\r
- GREEN_BEGIN"# ll (list all device) : list all discovered/paired devices"COLOR_END,\r
- GREEN_BEGIN"# q (quit) : quit test"COLOR_END,\r
+ GREEN_BEGIN "# h (or help) : show help message" COLOR_END,\r
+ GREEN_BEGIN "# dd (DP device discovery) : discover Direct-Pairing devices" COLOR_END,\r
+ GREEN_BEGIN "# dp (start Direct-Pairing) : negotiate DP method & start Direct-Pairing" COLOR_END,\r
+ GREEN_BEGIN "# sd (send data) : send data to device" COLOR_END,\r
+ GREEN_BEGIN "# ll (list all device) : list all discovered/paired devices" COLOR_END,\r
+ GREEN_BEGIN "# q (quit) : quit test" COLOR_END,\r
};\r
\r
for (size_t i=0; i<(sizeof(helpmsg)/sizeof(char*)); i++)\r
OIC_LOG(ERROR, TAG, "Invalid PIN");\r
continue;\r
}\r
- sscanf(input, "%8s", pinNumber);
- printf("\n");
+ sscanf(input, "%8s", pinNumber);\r
+ printf("\n");\r
\r
ret = DoDirectPairing(peer, pmSel, pinNumber);\r
if (OC_STACK_OK != ret)\r
return 0;\r
}\r
\r
+#if defined(_WIN32)\r
+ Sleep(100);\r
+#else\r
nanosleep(&timeout, NULL);\r
+#endif // defined(_WIN32)\r
+\r
}\r
OIC_LOG(INFO, TAG, "Exiting occlient main loop...");\r
\r