//\r
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
\r
+#include "iotivity_config.h"\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <string.h>\r
#endif\r
#include <iostream>\r
#include <sstream>\r
-#if defined(_WIN32)\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(_WIN32)\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
}\r
\r
// This is a function called back when direct-pairing status is changed\r
-void pairingReqCB(OCDPDev_t* peer, OCStackResult result)\r
+void pairingReqCB(void *ctx, OCDPDev_t* peer, OCStackResult result)\r
{\r
OIC_LOG(INFO, TAG, "Callback Context for Direct-Pairing establishment\n");\r
\r
+ (void) ctx;\r
if (OC_STACK_OK == result)\r
{\r
OIC_LOG_V(INFO, TAG,\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
\r
// start direct pairing\r
OIC_LOG(INFO, TAG, " Start Direct Pairing..");\r
- if(OC_STACK_OK != OCDoDirectPairing(peer, pmSel, pinNumber, pairingReqCB))\r
+ if(OC_STACK_OK != OCDoDirectPairing(NULL, peer, pmSel, pinNumber, pairingReqCB))\r
{\r
OIC_LOG(ERROR, TAG, "OCDoDirectPairing API error");\r
return OC_STACK_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