X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fstack%2Fsamples%2Flinux%2Fsecure%2Focclientdirectpairing.cpp;h=74dd8226fb0e24ed1093639c003b92c7ab1d5c60;hb=c315c87e07c4080ecd0ef488e7a1047bc3c509b2;hp=f92a644b522451d3024d8be8217244c328b7263c;hpb=2149e49d0daeec07841f69ee973206f49ae88ec2;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp b/resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp index f92a644..74dd822 100644 --- a/resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp +++ b/resource/csdk/stack/samples/linux/secure/occlientdirectpairing.cpp @@ -18,6 +18,7 @@ // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +#include "iotivity_config.h" #include #include #include @@ -30,13 +31,13 @@ #endif #include #include -#if defined(_WIN32) +#if defined(HAVE_WINDOWS_H) #include /** @todo stop-gap for naming issue. Windows.h does not like us to use ERROR */ #ifdef ERROR #undef ERROR #endif -#endif // defined(_WIN32) +#endif // defined(HAVE_WINDOWS_H) #include "ocstack.h" #include "logger.h" #include "ocpayload.h" @@ -60,8 +61,8 @@ static char DISCOVERY_QUERY[] = "%s/oic/res"; //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_directpairing.dat"; - +static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat"; + static const OCDPDev_t *discoveredDevs = NULL; static const OCDPDev_t *pairedDevs = NULL; @@ -281,10 +282,11 @@ OCStackApplicationResult discoveryReqCB(void*, OCDoHandle, } // This is a function called back when direct-pairing status is changed -void pairingReqCB(OCDPDev_t* peer, OCStackResult result) +void pairingReqCB(void *ctx, OCDPDev_t* peer, OCStackResult result) { OIC_LOG(INFO, TAG, "Callback Context for Direct-Pairing establishment\n"); + (void) ctx; if (OC_STACK_OK == result) { OIC_LOG_V(INFO, TAG, @@ -333,8 +335,8 @@ int DeviceDiscovery() /* Start a discovery query*/ OIC_LOG_V(INFO, TAG, "Resource Discovery : %s\n", queryUri); - ret = OCDoResource(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT, - OC_LOW_QOS, &cbData, NULL, 0); + ret = OCDoRequest(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT, + OC_LOW_QOS, &cbData, NULL, 0); if (ret != OC_STACK_OK) { OIC_LOG(ERROR, TAG, "OCStack resource error"); @@ -370,7 +372,7 @@ OCStackResult DoDirectPairing(OCDPDev_t* peer, OCPrm_t pmSel, char *pinNumber) // start direct pairing OIC_LOG(INFO, TAG, " Start Direct Pairing.."); - if(OC_STACK_OK != OCDoDirectPairing(peer, pmSel, pinNumber, pairingReqCB)) + if(OC_STACK_OK != OCDoDirectPairing(NULL, peer, pmSel, pinNumber, pairingReqCB)) { OIC_LOG(ERROR, TAG, "OCDoDirectPairing API error"); return OC_STACK_ERROR; @@ -398,8 +400,8 @@ OCStackResult SendGetRequest(OCDPDev_t* peer) cbData.cd = NULL; OIC_LOG(INFO, TAG, "Request to /a/light "); - ret = OCDoResource(&handle, OC_REST_GET, szQueryUri, - &endpoint, NULL, peer->connType, OC_LOW_QOS, &cbData, NULL, 0); + ret = OCDoRequest(&handle, OC_REST_GET, szQueryUri, + &endpoint, NULL, peer->connType, OC_LOW_QOS, &cbData, NULL, 0); if (ret != OC_STACK_OK) { OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, OC_REST_GET); @@ -416,19 +418,19 @@ FILE* client_fopen(const char *path, const char *mode) void *CLInterface(void *data) { - printf(RED_BEGIN"#Ready to operation ('h' for help)#\n"COLOR_END); + printf(RED_BEGIN "#Ready to operation ('h' for help)#\n" COLOR_END); (void)data; OCStackResult ret; - char query[MAX_LINE] = {0,}; - const char prompt[] = BOLD_BEGIN"IoTivity-DP#"COLOR_END" "; + char query[MAX_LINE] = {0}; + const char prompt[] = BOLD_BEGIN "IoTivity-DP#" COLOR_END" "; const char* helpmsg[6] = { - GREEN_BEGIN"# h (or help) : show help message"COLOR_END, - GREEN_BEGIN"# dd (DP device discovery) : discover Direct-Pairing devices"COLOR_END, - GREEN_BEGIN"# dp (start Direct-Pairing) : negotiate DP method & start Direct-Pairing"COLOR_END, - GREEN_BEGIN"# sd (send data) : send data to device"COLOR_END, - GREEN_BEGIN"# ll (list all device) : list all discovered/paired devices"COLOR_END, - GREEN_BEGIN"# q (quit) : quit test"COLOR_END, + GREEN_BEGIN "# h (or help) : show help message" COLOR_END, + GREEN_BEGIN "# dd (DP device discovery) : discover Direct-Pairing devices" COLOR_END, + GREEN_BEGIN "# dp (start Direct-Pairing) : negotiate DP method & start Direct-Pairing" COLOR_END, + GREEN_BEGIN "# sd (send data) : send data to device" COLOR_END, + GREEN_BEGIN "# ll (list all device) : list all discovered/paired devices" COLOR_END, + GREEN_BEGIN "# q (quit) : quit test" COLOR_END, }; for (size_t i=0; i<(sizeof(helpmsg)/sizeof(char*)); i++) @@ -525,8 +527,8 @@ void *CLInterface(void *data) OIC_LOG(ERROR, TAG, "Invalid PIN"); continue; } - sscanf(input, "%8s", pinNumber); - printf("\n"); + sscanf(input, "%8s", pinNumber); + printf("\n"); ret = DoDirectPairing(peer, pmSel, pinNumber); if (OC_STACK_OK != ret)