CASendNotification API is not used by RI layer.
RI layer is using CASendRequest API to send notification.
so we removed the CASendNotification API and modified the CA sample.
Change-Id: I90d490814dcd5e250564ca4f221911fb1c365128
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3457
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo);
/**
- * Send notification to the remote object.
- * @param[in] object Endpoint where the payload need to be sent.
- * This endpoint is delivered with Request or response callback.
- * @param[in] responseInfo Information for the response.
- * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
- */
-CAResult_t CASendNotification(const CAEndpoint_t *object,
- const CAResponseInfo_t *responseInfo);
-
-/**
* Select network to use.
* @param[in] interestedNetwork Connectivity Type enum.
* @return ::CA_STATUS_OK or ::CA_NOT_SUPPORTED or
DLog.v(TAG, "SendNotification click");
if ( selectedNetwork != -1) {
RM.RMSendNotification(mNotification_ed.getText().toString(),
- null, selectedNetwork, isSecured, msgType, responseValue);
+ null, selectedNetwork, isSecured, msgType);
}
else {
DLog.v(TAG, "Please Select Network Type");
public native void RMAdvertiseResource(String advertiseResource);
public native void RMSendNotification(String uri, String payload,
- int selectedNetwork, int isSecured, int msgType, int responseValue);
+ int selectedNetwork, int isSecured, int msgType);
public native void RMSelectNetwork(int interestedNetwork);
JNIEXPORT void JNICALL
Java_org_iotivity_ca_service_RMInterface_RMSendNotification(JNIEnv *env, jobject obj, jstring uri,
jstring payload, jint selectedNetwork,
- jint isSecured, jint msgType,
- jint responseValue)
+ jint isSecured, jint msgType)
{
LOGI("selectedNetwork - %d", selectedNetwork);
if (!env || !obj)
return;
}
- CAInfo_t responseData = { 0 };
- responseData.token = token;
- responseData.tokenLength = tokenLength;
- responseData.resourceUri = (CAURI_t) malloc(sizeof(resourceURI));
- if (NULL == responseData.resourceUri)
+ CAInfo_t requestData = { 0 };
+ requestData.token = token;
+ requestData.tokenLength = tokenLength;
+ requestData.resourceUri = (CAURI_t) malloc(sizeof(resourceURI));
+ if (NULL == requestData.resourceUri)
{
LOGE("Memory allocation failed!");
// destroy token
CADestroyEndpoint(endpoint);
return;
}
- memcpy(responseData.resourceUri, resourceURI, sizeof(resourceURI));
+ memcpy(requestData.resourceUri, resourceURI, sizeof(resourceURI));
if (1 == isSecured)
{
uint32_t length = sizeof(SECURE_INFO_DATA) + strlen(resourceURI);
- responseData.payload = (CAPayload_t) malloc(length);
- if (NULL == responseData.payload)
+ requestData.payload = (CAPayload_t) malloc(length);
+ if (NULL == requestData.payload)
{
LOGE("Memory allocation failed!");
// destroy token
// destroy remote endpoint
CADestroyEndpoint(endpoint);
- free(responseData.resourceUri);
+ free(requestData.resourceUri);
return;
}
- snprintf((char *) responseData.payload, length, SECURE_INFO_DATA, resourceURI, g_localSecurePort);
- responseData.payloadSize = length;
+ snprintf((char *) requestData.payload, length, SECURE_INFO_DATA, resourceURI, g_localSecurePort);
+ requestData.payloadSize = length;
}
else
{
uint32_t length = sizeof(NORMAL_INFO_DATA) + strlen(resourceURI);
- responseData.payload = (CAPayload_t) malloc(length);
- if (NULL == responseData.payload)
+ requestData.payload = (CAPayload_t) malloc(length);
+ if (NULL == requestData.payload)
{
LOGE("Memory allocation failed!");
// destroy token
// destroy remote endpoint
CADestroyEndpoint(endpoint);
- free(responseData.resourceUri);
+ free(requestData.resourceUri);
return;
}
- snprintf((char *) responseData.payload, length, NORMAL_INFO_DATA, resourceURI);
- responseData.payloadSize = length;
+ snprintf((char *) requestData.payload, length, NORMAL_INFO_DATA, resourceURI);
+ requestData.payloadSize = length;
}
- responseData.type = messageType;
+ requestData.type = messageType;
- CAResponseInfo_t responseInfo = { 0 };
- responseInfo.result = responseValue;
- responseInfo.info = responseData;
+ CARequestInfo_t requestInfo = { 0 };
+ requestInfo.method = CA_GET;
+ requestInfo.info = requestData;
// send notification
- if (CA_STATUS_OK != CASendNotification(endpoint, &responseInfo))
+ if (CA_STATUS_OK != CASendRequest(endpoint, &requestInfo))
{
LOGE("Could not send notification");
}
// destroy remote endpoint
CADestroyEndpoint(endpoint);
- free(responseData.payload);
- free(responseData.resourceUri);
+ free(requestData.payload);
+ free(requestData.resourceUri);
}
JNIEXPORT void JNICALL
* Signature: (Ljava/lang/String;Ljava/lang/String;IIII)V
*/
JNIEXPORT void JNICALL Java_org_iotivity_ca_service_RMInterface_RMSendNotification
- (JNIEnv *, jobject, jstring, jstring, jint, jint, jint, jint);
+ (JNIEnv *, jobject, jstring, jstring, jint, jint, jint);
/*
* Class: org_iotivity_ca_service_RMInterface
return;
}
- CAInfo_t respondData = {CA_MSG_NONCONFIRM};
- respondData.token = token;
- respondData.tokenLength = tokenLength;
- respondData.payload = (CAPayload_t)"Notification Data";
- respondData.payloadSize = strlen((const char *) respondData.payload);
- respondData.resourceUri = (char *)OICMalloc(strlen(resourceUri) + 1);
- strcpy(respondData.resourceUri, resourceUri);
+ CAInfo_t requestData = {CA_MSG_NONCONFIRM};
+ requestData.token = token;
+ requestData.tokenLength = tokenLength;
+ requestData.payload = (CAPayload_t)"Notification Data";
+ requestData.payloadSize = strlen((const char *) requestData.payload);
+ requestData.resourceUri = (char *)OICMalloc(strlen(resourceUri) + 1);
+ strcpy(requestData.resourceUri, resourceUri);
- CAResponseInfo_t responseInfo = {CA_BAD_REQ, {CA_MSG_RESET}};
- responseInfo.result = CA_CONTENT;
- responseInfo.info = respondData;
+ CARequestInfo_t requestInfo = {CA_GET, {CA_MSG_RESET}};
+ requestInfo.method = CA_GET;
+ requestInfo.info = requestData;
// send request
- CASendNotification(endpoint, &responseInfo);
+ CASendRequest(endpoint, &requestInfo);
// destroy remote endpoint
if (NULL != endpoint)
{
CAPayload_t payload = (CAPayload_t) "TempNotificationData";
size_t payloadSize = strlen((const char *) payload);
- CAInfo_t respondData = { .type = messageType,
+ CAInfo_t requestData = { .type = messageType,
.messageId = 0,
.token = token,
.tokenLength = tokenLength,
.numOptions = 0,
.payload = payload,
.payloadSize = payloadSize,
- .resourceUri = (CAURI_t)uri };
+ .resourceUri = (CAURI_t) uri };
- CAResponseInfo_t responseInfo = { .result = CA_CONTENT,
- .info = respondData };
+ CARequestInfo_t requestInfo = { .method = CA_GET,
+ .info = requestData };
// send request
- res = CASendNotification(endpoint, &responseInfo);
+ res = CASendRequest(endpoint, &requestInfo);
if (CA_STATUS_OK != res)
{
printf("Send notification error, error code: %d\n", res);
printf("Generated token %s\n", token);
- CAInfo_t respondData = { 0 };
- respondData.token = token;
- respondData.tokenLength = tokenLength;
- respondData.payload = (CAPayload_t) "TempNotificationData";
- respondData.payloadSize = strlen((const char *) respondData.payload);
- respondData.type = messageType;
- respondData.resourceUri = (CAURI_t)uri;
+ CAInfo_t requestData = { 0 };
+ requestData.token = token;
+ requestData.tokenLength = tokenLength;
+ requestData.payload = (CAPayload_t) "TempNotificationData";
+ requestData.payloadSize = strlen((const char *) requestData.payload);
+ requestData.type = messageType;
+ requestData.resourceUri = (CAURI_t)uri;
- CAResponseInfo_t responseInfo = { 0 };
- responseInfo.result = CA_CONTENT;
- responseInfo.info = respondData;
+ CARequestInfo_t requestInfo = { 0 };
+ requestInfo.method = CA_GET;
+ requestInfo.info = requestData;
// send notification
- res = CASendNotification(endpoint, &responseInfo);
+ res = CASendRequest(endpoint, &requestInfo);
if (CA_STATUS_OK != res)
{
printf("Send notification error, error code: %d\n", res);
return CADetachRequestMessage(object, requestInfo);
}
-CAResult_t CASendNotification(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo)
-{
- OIC_LOG(DEBUG, TAG, "CASendNotification");
-
- if(!g_isInitialized)
- {
- return CA_STATUS_NOT_INITIALIZED;
- }
-
- return CADetachResponseMessage(object, responseInfo);
-}
-
CAResult_t CASendResponse(const CAEndpoint_t *object, const CAResponseInfo_t *responseInfo)
{
OIC_LOG(DEBUG, TAG, "CASendResponse");
}
}
-// CASendNotification TC
-// check return value
-TEST(SendNotificationTest, DISABLED_TC_22_Positive_01)
-{
- addr = (char *) ADDRESS;
- CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, addr, PORT, &tempRep);
-
- memset(&responseData, 0, sizeof(CAInfo_t));
- responseData.type = CA_MSG_NONCONFIRM;
- responseData.payload = (CAPayload_t)malloc(sizeof("Temp Notification Data"));
-
- EXPECT_TRUE(responseData.payload != NULL);
- if(!responseData.payload)
- {
- CADestroyEndpoint(tempRep);
- return;
- }
-
- memcpy(responseData.payload, "Temp Notification Data", sizeof("Temp Notification Data"));
- responseData.payloadSize = sizeof("Temp Notification Data");
-
- CAGenerateToken(&tempToken, tokenLength);
- requestData.token = tempToken;
- requestData.tokenLength = tokenLength;
-
- memset(&responseInfo, 0, sizeof(CAResponseInfo_t));
- responseInfo.result = CA_CONTENT;
- responseInfo.info = responseData;
-
- EXPECT_EQ(CA_STATUS_OK, CASendNotification(tempRep, &responseInfo));
-
- CADestroyToken(tempToken);
- if (tempRep != NULL)
- {
- CADestroyEndpoint(tempRep);
- tempRep = NULL;
- }
- free(responseData.payload);
-}
-
// CASelectNewwork TC
// check return value
TEST_F(CATests, SelectNetworkTestGood)