Exemplo n.º 1
0
JNIEXPORT void JNICALL
Java_org_iotivity_ca_service_RMInterface_RMInitialize(JNIEnv *env, jobject obj, jobject context)
{
    LOGI("RMInitialize");
    if (!env || !obj || !context)
    {
        LOGI("Invalid input parameter");
        return;
    }

    //Currently set context for Android Platform
    CANativeJNISetContext(env, context);

    CAResult_t res = CAInitialize();

    if (CA_STATUS_OK != res)
    {
        LOGE("Could not Initialize");
    }

#ifdef __WITH_DTLS__
    if (CA_STATUS_OK != SetCredentials())
    {
        LOGE("SetCredentials failed");
        return;
    }

    res = CARegisterDTLSCredentialsHandler(CAGetDtlsPskCredentials);
    if(CA_STATUS_OK != res)
    {
        LOGE("Set credential handler fail");
        return;
    }
#endif
}
Exemplo n.º 2
0
//CATerminate TC
TEST_F(CATests, TerminateTest)
{
    CATerminate();

    char* check = (char *) "terminate success";
    EXPECT_STREQ(check, "terminate success");

    CAInitialize();
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
void Initialize()
{
    if(CAInitialize() != CA_STATUS_OK)
    {
        Serial.println("Initialize failed");
        return;
    }
    SelectNetwork();
    // set handler.
    CARegisterHandler(RequestHandler, ResponseHandler, ErrorHandler);
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
CAResult_t Initialize()
{
    g_mainloop = g_main_loop_new(NULL, FALSE);
    if(!g_mainloop)
    {
        printf("g_main_loop_new failed\n");
        return CA_STATUS_FAILED;
    }

    int result = pthread_create(&thread, NULL, (void *) &GMainLoopThread, NULL);
    if (result < 0)
    {
        printf("pthread_create failed in initialize\n");
        return CA_STATUS_FAILED;
    }

    CAResult_t res = CAInitialize();
    if (res != CA_STATUS_OK)
    {
        printf("CAInitialize fail\n");
    }
    return res;
}
Exemplo n.º 7
0
 virtual void SetUp() {
     CAInitialize();
 }
Exemplo n.º 8
0
// CAInitialize TC
// check return value
TEST(InitializeTest, TC_01_Positive_01)
{
    EXPECT_EQ(CA_STATUS_OK, CAInitialize());
    CATerminate();
}
Exemplo n.º 9
0
// CAInitialize TC
TEST(InitializeTest, CAInitializeTest)
{
    EXPECT_EQ(CA_STATUS_OK, CAInitialize());
    CATerminate();
}
Exemplo n.º 10
0
 virtual void SetUp()
 {
     CAInitialize(CA_ADAPTER_IP);
 }