int main() { int ret = system("clear"); // shell invoke error: 127, others: -1 if (SYSTEM_INVOKE_ERROR == ret || SYSTEM_ERROR == ret) { printf("Terminal Clear Error: %d\n", ret); return -1; } printf("=============================================\n"); printf("\t\tsample main\n"); printf("=============================================\n"); CAResult_t res = CAInitialize(); if (CA_STATUS_OK != res) { printf("CAInitialize fail\n"); return -1; } /* * Read DTLS PSK credentials from persistent storage and * set in the OC stack. */ #ifdef __WITH_DTLS__ res = SetCredentials(); if (CA_STATUS_OK != res) { printf("SetCredentials failed\n"); return -1; } res = CARegisterDTLSCredentialsHandler(CAGetDtlsPskCredentials); if (CA_STATUS_OK != res) { printf("Set credential handler fail\n"); return -1; } #endif // set handler. CARegisterHandler(request_handler, response_handler, error_handler); process(); CADestroyToken(g_last_request_token); g_last_request_token = NULL; CATerminate(); #ifdef __WITH_DTLS__ clearDtlsCredentialInfo(); #endif return 0; }
void Initialize() { if(CAInitialize() != CA_STATUS_OK) { Serial.println("Initialize failed"); return; } SelectNetwork(); // set handler. CARegisterHandler(RequestHandler, ResponseHandler, ErrorHandler); }
JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMRegisterHandler(JNIEnv *env, jobject obj) { LOGI("RMRegisterHandler"); if(!env || !obj) { LOGI("Invalid input parameter"); return; } CARegisterHandler(request_handler, response_handler, error_handler); }
int main() { int ret = system("clear"); // shell invoke error: 127, others: -1 if (SYSTEM_INVOKE_ERROR == ret || SYSTEM_ERROR == ret) { printf("Terminal Clear Error: %d\n", ret); return -1; } printf("=============================================\n"); printf("\t\tsample main\n"); printf("=============================================\n"); CAResult_t res = CAInitialize(); if (CA_STATUS_OK != res) { printf("CAInitialize fail\n"); return -1; } // Set the PSK Credentials callback handler. #ifdef __WITH_DTLS__ res = CARegisterDTLSCredentialsHandler(CAGetDtlsPskCredentials); if (CA_STATUS_OK != res) { printf("Register credential handler fail\n"); return -1; } #endif // set handler. CARegisterHandler(request_handler, response_handler, error_handler); process(); CADestroyToken(g_last_request_token); g_last_request_token = NULL; CATerminate(); return 0; }
TEST_F(CATests, SendRequestTestWithInvalidAddress) { CARegisterHandler(request_handler, response_handler, error_handler); EXPECT_EQ(CA_STATUS_OK, CASelectNetwork(CA_ADAPTER_IP)); CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "10.11.13.13.14", PORT, &tempRep); memset(&requestData, 0, sizeof(CAInfo_t)); CAGenerateToken(&tempToken, tokenLength); requestData.token = tempToken; requestData.tokenLength = tokenLength; requestData.type = CA_MSG_CONFIRM; memset(&requestInfo, 0, sizeof(CARequestInfo_t)); requestInfo.method = CA_GET; requestInfo.info = requestData; EXPECT_EQ(CA_STATUS_OK, CASendRequest(tempRep, &requestInfo)); CADestroyToken(tempToken); CADestroyEndpoint(tempRep); free(requestData.payload); tempRep = NULL; }
// CARegisterHandlerTest TC // check return value TEST_F(CATests, RegisterHandlerTest) { CARegisterHandler(request_handler, response_handler, error_handler); char* check = (char *) "registerHandler success"; EXPECT_STREQ(check, "registerHandler success"); }