{
if(g_OnBoardingSucceeded)
{
- OC_LOG_V(ERROR, TAG, "Failure in Provisioning. \
+ OIC_LOG_V(ERROR, TAG, "Failure in Provisioning. \
Current Enrollee State: %d",enrolleeState);
g_OnBoardingSucceeded = false;
}
else if(g_ProvisioningSucceeded)
{
- OC_LOG_V(ERROR, TAG, "Failure in connect to target network. \
+ OIC_LOG_V(ERROR, TAG, "Failure in connect to target network. \
Current Enrollee State: %d",enrolleeState);
g_ProvisioningSucceeded = false;
}
extern char *__brkval;
//address of tmp gives us the current stack boundry
int tmp;
- OC_LOG_V(INFO, TAG, "Stack: %u Heap: %u", (unsigned int)&tmp, (unsigned int)__brkval);
- OC_LOG_V(INFO, TAG, "Unallocated Memory between heap and stack: %u",
+ OIC_LOG_V(INFO, TAG, "Stack: %u Heap: %u", (unsigned int)&tmp, (unsigned int)__brkval);
+ OIC_LOG_V(INFO, TAG, "Unallocated Memory between heap and stack: %u",
((unsigned int)&tmp - (unsigned int)__brkval));
#endif
}
void StartEasySetup()
{
- OC_LOG(DEBUG, TAG, "OCServer is starting...");
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
if(InitEasySetup(CT_ADAPTER_IP, ssid, passwd, EventCallbackInApp) == ES_ERROR)
{
- OC_LOG(ERROR, TAG, "OnBoarding Failed");
+ OIC_LOG(ERROR, TAG, "OnBoarding Failed");
return;
}
g_isInitialized = true;
- OC_LOG_V(ERROR, TAG, "OnBoarding succeeded. Successfully connected to ssid : %s",ssid);
+ OIC_LOG_V(ERROR, TAG, "OnBoarding succeeded. Successfully connected to ssid : %s",ssid);
}
void StartProvisioning()
{
- OC_LOG(DEBUG, TAG, "StartProvisioning is invoked...");
+ OIC_LOG(DEBUG, TAG, "StartProvisioning is invoked...");
if(InitProvisioning()== ES_ERROR)
{
- OC_LOG(ERROR, TAG, "Init Provisioning Failed");
+ OIC_LOG(ERROR, TAG, "Init Provisioning Failed");
return;
}
}
void StopEasySetup()
{
- OC_LOG(DEBUG, TAG, "Stopping EasySetup is invoked...");
+ OIC_LOG(DEBUG, TAG, "Stopping EasySetup is invoked...");
g_isInitialized = false;
if(TerminateEasySetup()== ES_ERROR)
{
- OC_LOG(ERROR, TAG, "TerminateEasySetup Failed");
+ OIC_LOG(ERROR, TAG, "TerminateEasySetup Failed");
return;
}
}
{
// Add your initialization code here
// Note : This will initialize Serial port on Arduino at 115200 bauds
- OC_LOG_INIT();
+ OIC_LOG_INIT();
Serial.println("#########################");
Serial.println("EasySetup Enrollee SAMPLE");
// Give CPU cycles to OCStack to perform send/recv and other OCStack stuff
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return;
}
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, ES_NH_TAG, "WiFi shield not present");
+ OIC_LOG(ERROR, ES_NH_TAG, "WiFi shield not present");
return ES_ERROR;
}
// Verify that WiFi Shield is running the firmware with all UDP fixes
fwVersion = WiFi.firmwareVersion();
- OC_LOG_V(INFO, ES_NH_TAG, "WiFi Shield Firmware version %s", fwVersion);
+ OIC_LOG_V(INFO, ES_NH_TAG, "WiFi Shield Firmware version %s", fwVersion);
if (strncmp(fwVersion, ARDUINO_WIFI_SHIELD_UDP_FW_VER, sizeof(ARDUINO_WIFI_SHIELD_UDP_FW_VER))
!= 0)
{
- OC_LOG(DEBUG, ES_NH_TAG, "!!!!! Upgrade WiFi Shield Firmware version !!!!!!");
+ OIC_LOG(DEBUG, ES_NH_TAG, "!!!!! Upgrade WiFi Shield Firmware version !!!!!!");
return ES_ERROR;
}
//Retry counter is reset everytime the ConnectToWiFiNetwork is invoked
g_retryCounter = 0;
- OC_LOG_V(INFO, ES_NH_TAG, "Finding SSID: %s", ssid);
+ OIC_LOG_V(INFO, ES_NH_TAG, "Finding SSID: %s", ssid);
while ((findNetwork(ssid) == 0) && g_retryCounter < ES_MAX_NETWORK_RETRY) // found
{
}
if(g_retryCounter == ES_MAX_NETWORK_RETRY){
- OC_LOG_V(ERROR, ES_NH_TAG, "Connection to network failed after %d attempts",
- g_retryCounter);
+ OIC_LOG_V(ERROR, ES_NH_TAG, "Connection to network failed after %d attempts",
+ g_retryCounter);
return ES_ERROR;
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED && g_retryCounter < ES_MAX_NETWORK_RETRY)
{
- OC_LOG_V(INFO, ES_NH_TAG, "Attempting to connect to SSID: %s", ssid);
+ OIC_LOG_V(INFO, ES_NH_TAG, "Attempting to connect to SSID: %s", ssid);
status = WiFi.begin((char *) ssid, (char *) pass);
}
if(g_retryCounter == ES_MAX_NETWORK_RETRY){
- OC_LOG_V(ERROR, ES_NH_TAG, "Connection to network failed after %d attempts",
- g_retryCounter);
+ OIC_LOG_V(ERROR, ES_NH_TAG, "Connection to network failed after %d attempts",
+ g_retryCounter);
return ES_ERROR;
}
- OC_LOG(DEBUG, ES_NH_TAG, "Connected to wifi");
+ OIC_LOG(DEBUG, ES_NH_TAG, "Connected to wifi");
enrolleeIP = WiFi.localIP();
- OC_LOG_V(INFO, ES_NH_TAG, "IP Address: %d.%d.%d.%d", enrolleeIP[0], enrolleeIP[1],
- enrolleeIP[2], enrolleeIP[3]);
+ OIC_LOG_V(INFO, ES_NH_TAG, "IP Address: %d.%d.%d.%d", enrolleeIP[0], enrolleeIP[1],
+ enrolleeIP[2], enrolleeIP[3]);
char buf[50];
sprintf(buf, "IP Address: %d.%d.%d.%d", enrolleeIP[0], enrolleeIP[1],
void EventCallbackInOnboarding(ESResult esResult)
{
if (g_cbForEnrolleeStatus != NULL){
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with esResult = %d", esResult);
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with esResult = %d", esResult);
if(esResult == ES_OK){
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
ES_ON_BOARDED_STATE);
g_cbForEnrolleeStatus(esResult, ES_ON_BOARDED_STATE);
}
else{
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
ES_INIT_STATE);
g_cbForEnrolleeStatus(esResult, ES_INIT_STATE);
}
}
else{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
}
}
if(TerminateEasySetup() != OC_STACK_OK)
{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "Terminating stack failed");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "Terminating stack failed");
return;
}
if (g_cbForEnrolleeStatus != NULL)
{
if(res == ES_NETWORKCONNECTED){
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
ES_PROVISIONED_STATE);
g_cbForEnrolleeStatus(ES_OK, ES_PROVISIONED_STATE);
}
else{
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
ES_PROVISIONING_STATE);
g_cbForEnrolleeStatus(ES_OK, ES_PROVISIONING_STATE);
}
{
if (g_cbForEnrolleeStatus != NULL){
if(esResult == ES_OK){
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
ES_PROVISIONED_STATE);
g_cbForEnrolleeStatus(esResult, ES_PROVISIONED_STATE);
}
else{
- OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
ES_PROVISIONING_STATE);
g_cbForEnrolleeStatus(esResult, ES_PROVISIONING_STATE);
}
}
else{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
}
}
if(ConnectToWiFiNetwork(ssid, passwd, EventCallbackInOnboarding) != ES_NETWORKCONNECTED)
{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Failed");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Failed");
cb(ES_ERROR, ES_ON_BOARDING_STATE);
return ES_ERROR;
}
else{
- OC_LOG(INFO, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Success");
+ OIC_LOG(INFO, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Success");
cb(ES_OK, ES_ON_BOARDED_STATE);
return ES_OK;
}
{
if(FindNetworkForOnboarding(networkType, ssid, passwd, cb) != ES_OK)
{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "OnBoarding Failed");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "OnBoarding Failed");
return ES_ERROR;
}
// Initialize the OC Stack in Server mode
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack init error");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack init error");
return ES_ERROR;
}
else
{
- OC_LOG(DEBUG, ES_ENROLLEE_TAG, "OCStack init success");
+ OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "OCStack init success");
return ES_OK;
}
}
{
if(OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack stop failed");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack stop failed");
return ES_ERROR;
}
else
{
- OC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack stop success");
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "OCStack stop success");
return ES_OK;
}
}
OCStackResult res = OCCreateResource(&g_prov.handle, "oic.r.prov", OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb, NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
- OC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, ES_RH_TAG, "Created Prov resource with result: %s", getResult(res));
return res;
}
netInfo.ipaddr[3]);
sprintf(g_net.cnn, "%s", netInfo.ssid);
- OC_LOG_V(INFO, ES_RH_TAG, "SSID: %s", g_net.cnn);
- OC_LOG_V(INFO, ES_RH_TAG, "IP Address: %s", g_net.ipaddr);
+ OIC_LOG_V(INFO, ES_RH_TAG, "SSID: %s", g_net.cnn);
+ OIC_LOG_V(INFO, ES_RH_TAG, "IP Address: %s", g_net.ipaddr);
OCStackResult res = OCCreateResource(&g_net.handle, "oic.r.net", OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_NET, OCEntityHandlerCb,NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
- OC_LOG_V(INFO, ES_RH_TAG, "Created Net resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, ES_RH_TAG, "Created Net resource with result: %s", getResult(res));
return res;
}
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if (!ehRequest)
{
- OC_LOG(ERROR, ES_RH_TAG, "Request is Null");
+ OIC_LOG(ERROR, ES_RH_TAG, "Request is Null");
return ehResult;
}
if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
+ OIC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload *getResp = constructResponse(ehRequest);
if (!getResp)
{
- OC_LOG(ERROR, ES_RH_TAG, "constructResponse failed");
+ OIC_LOG(ERROR, ES_RH_TAG, "constructResponse failed");
return OC_EH_ERROR;
}
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
+ OIC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload* input = (OCRepPayload*) (ehRequest->payload);
if (!input)
{
- OC_LOG(ERROR, ES_RH_TAG, "Failed to parse");
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to parse");
return ehResult;
}
OCRepPayload *getResp = constructResponse(ehRequest);
if (!getResp)
{
- OC_LOG(ERROR, ES_RH_TAG, "constructResponse failed");
+ OIC_LOG(ERROR, ES_RH_TAG, "constructResponse failed");
return OC_EH_ERROR;
}
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if (!ehRequest)
{
- OC_LOG(ERROR, ES_RH_TAG, "Request is Null");
+ OIC_LOG(ERROR, ES_RH_TAG, "Request is Null");
return ehResult;
}
if (ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
+ OIC_LOG(ERROR, ES_RH_TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload* input = (OCRepPayload*) (ehRequest->payload);
if (!input)
{
- OC_LOG(ERROR, ES_RH_TAG, "Failed to parse");
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to parse");
return ehResult;
}
char* tr;
OCRepPayload* payload = OCRepPayloadCreate();
if (!payload)
{
- OC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
}
{
if (OC_REST_GET == entityHandlerRequest->method)
{
- OC_LOG(INFO, ES_RH_TAG, "Received GET request");
+ OIC_LOG(INFO, ES_RH_TAG, "Received GET request");
ehRet = ProcessGetRequest(entityHandlerRequest, &payload);
}
else if (OC_REST_PUT == entityHandlerRequest->method)
{
- OC_LOG(INFO, ES_RH_TAG, "Received PUT request");
+ OIC_LOG(INFO, ES_RH_TAG, "Received PUT request");
if (g_prov.handle != NULL && entityHandlerRequest->resource == g_prov.handle)
{
else if (OC_REST_POST == entityHandlerRequest->method)
{
// TODO: As of now, POST request will be not received.
- OC_LOG(INFO, ES_RH_TAG, "Received OC_REST_POST from client");
+ OIC_LOG(INFO, ES_RH_TAG, "Received OC_REST_POST from client");
//ehRet = ProcessPostRequest (entityHandlerRequest, payload, sizeof(payload) - 1);
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, ES_RH_TAG, "Error sending response");
+ OIC_LOG(ERROR, ES_RH_TAG, "Error sending response");
ehRet = OC_EH_ERROR;
}
}
{
for (RCSResourceAttributes::iterator it = attrs.begin(); it != attrs.end(); ++it)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "set attribute \(%s)'",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "set attribute \(%s)'",
std::string(it->key() + "\', with " + it->value().toString()).c_str());
m_resourceAttributes[it->key()] = it->value();
void BundleResource::setAttribute(const std::string &key,
RCSResourceAttributes::Value &&value, bool notify)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "set attribute \(%s)'", std::string(key + "\', with " +
+ OIC_LOG_V(INFO, CONTAINER_TAG, "set attribute \(%s)'", std::string(key + "\', with " +
value.toString()).c_str());
m_resourceAttributes[key] = value;
RCSResourceAttributes::Value BundleResource::getAttribute(const std::string &key)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "get attribute \'(%s)" , std::string(key + "\'").c_str());
+ OIC_LOG_V(INFO, CONTAINER_TAG, "get attribute \'(%s)" , std::string(key + "\'").c_str());
return m_resourceAttributes.at(key);
}
}
catch (rapidxml::parse_error &e)
{
- OC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
- OC_LOG_V(ERROR, CONTAINER_TAG, "Exception : (%s)", e.what());
+ OIC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception : (%s)", e.what());
}
}
}
}
catch (rapidxml::parse_error &e)
{
- OC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
- OC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
+ OIC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
}
}
}
}
catch (rapidxml::parse_error &e)
{
- OC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
- OC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
+ OIC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
}
}
}
}
catch (rapidxml::parse_error &e)
{
- OC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
- OC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
+ OIC_LOG(ERROR, CONTAINER_TAG, "xml parsing failed !!");
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
}
}
else
{
- OC_LOG(ERROR, CONTAINER_TAG, "Configuration File load failed !!");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Configuration File load failed !!");
}
}
}
-}
\ No newline at end of file
+}
{
if (vm->AttachCurrentThread((void **) &env, NULL) != 0)
{
- OC_LOG_V(ERROR, CONTAINER_TAG,
+ OIC_LOG_V(ERROR, CONTAINER_TAG,
"[JavaBundleResource::handleGetAttributeRequest] Failed to attach ");
}
}
else if (envStat == JNI_EVERSION)
{
- OC_LOG_V(ERROR, CONTAINER_TAG,
+ OIC_LOG_V(ERROR, CONTAINER_TAG,
"[JavaBundleResource::handleGetAttributeRequest] Env: version not supported");
}
{
if (vm->AttachCurrentThread((void **) &env, NULL) != 0)
{
- OC_LOG_V(ERROR, CONTAINER_TAG,
+ OIC_LOG_V(ERROR, CONTAINER_TAG,
"[JavaBundleResource::handleSetAttributeRequest] Failed to attach ");
}
}
else if (envStat == JNI_EVERSION)
{
- OC_LOG_V(ERROR, CONTAINER_TAG,
+ OIC_LOG_V(ERROR, CONTAINER_TAG,
"[JavaBundleResource::handleSetAttributeRequest] Env: version not supported ");
}
void ResourceContainerImpl::startContainer(const std::string &configFile)
{
- OC_LOG(INFO, CONTAINER_TAG, "Starting resource container.");
+ OIC_LOG(INFO, CONTAINER_TAG, "Starting resource container.");
#if (JAVA_SUPPORT)
- OC_LOG(INFO, CONTAINER_TAG, "Resource container has Java support.");
+ OIC_LOG(INFO, CONTAINER_TAG, "Resource container has Java support.");
#else
- OC_LOG(INFO, CONTAINER_TAG, "Resource container without Java support.");
+ OIC_LOG(INFO, CONTAINER_TAG, "Resource container without Java support.");
#endif
bundles[i][BUNDLE_LIBRARY_PATH]);
}
- OC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Init Bundle:(%s)",
std::string(bundles[i][BUNDLE_ID] + ";" +
bundles[i][BUNDLE_PATH]).c_str());
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path.");
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Container started with invalid configfile path.");
}
}
else
{
- OC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided.");
+ OIC_LOG_V(INFO, CONTAINER_TAG, "No configuration file for the container provided.");
}
map<std::string, boost::thread >::iterator activatorIterator;
void ResourceContainerImpl::stopContainer()
{
- OC_LOG(INFO, CONTAINER_TAG, "Stopping resource container.");
+ OIC_LOG(INFO, CONTAINER_TAG, "Stopping resource container.");
for (std::map< std::string, BundleInfoInternal * >::iterator it = m_bundles.begin();
it != m_bundles.end(); ++it)
void ResourceContainerImpl::activateBundle(const std::string &id)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
std::string(m_bundles[id]->getID()).c_str());
activationLock.lock();
auto f = std::bind(&ResourceContainerImpl::activateBundleThread, this,
boost::thread activator(f);
activator.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
activationLock.unlock();
- OC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
std::string(m_bundles[id]->getID()).c_str());
}
// loads the bundle
void ResourceContainerImpl::registerBundle(RCSBundleInfo *bundleInfo)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "Registering bundle: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Registering bundle: (%s)",
std::string(bundleInfo->getPath()).c_str());
if (has_suffix(bundleInfo->getPath(), ".jar"))
{
void *bundleHandle = m_bundles[id]->getBundleHandle();
- OC_LOG_V(INFO, CONTAINER_TAG, "Unregister bundle: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Unregister bundle: (%s)",
std::string(m_bundles[id]->getID()).c_str());
const char *error;
if ((error = dlerror()) != NULL)
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Error (%s)", error);
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Error (%s)", error);
}
else
{
RCSResourceObject::Ptr server = nullptr;
int ret = EINVAL;
- OC_LOG_V(INFO, CONTAINER_TAG, "Registration of resource (%s)" ,
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Registration of resource (%s)" ,
std::string(strUri + ", " + strResourceType).c_str());
registrationLock.lock();
std::bind(&ResourceContainerImpl::setRequestHandler, this,
std::placeholders::_1, std::placeholders::_2));
- OC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
std::string(strUri + ", " +
strResourceType).c_str());
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "resource with (%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "resource with (%s)",
std::string(strUri + " already exists.").c_str());
ret = -EEXIST;
}
string strUri = resource->m_uri;
string strResourceType = resource->m_resourceType;
- OC_LOG_V(INFO, CONTAINER_TAG, "Unregistration of resource (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Unregistration of resource (%s)",
std::string(resource->m_uri + ", " +
resource->m_resourceType).c_str());
void ResourceContainerImpl::onNotificationReceived(const std::string &strResourceUri)
{
- OC_LOG_V(INFO, CONTAINER_TAG,
+ OIC_LOG_V(INFO, CONTAINER_TAG,
"notification from (%s)", std::string(strResourceUri + ".").c_str());
if (m_mapServers.find(strResourceUri) != m_mapServers.end())
activateBundle(m_bundles[bundleId]);
else
{
- OC_LOG(ERROR, CONTAINER_TAG, "Bundle already started");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Bundle already started");
}
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
std::string(bundleId + "\' is not registered.").c_str());
}
}
deactivateBundle(m_bundles[bundleId]);
else
{
- OC_LOG(ERROR, CONTAINER_TAG, "Bundle not activated");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Bundle not activated");
}
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
std::string(bundleId + "\' is not registered.").c_str());
}
}
(void) bundleUri;
if (m_bundles.find(bundleId) != m_bundles.end())
- OC_LOG(ERROR, CONTAINER_TAG, "BundleId already exist");
+ OIC_LOG(ERROR, CONTAINER_TAG, "BundleId already exist");
else
{
((BundleInfoInternal *)bundleInfo)->setLibraryPath(params[BUNDLE_LIBRARY_PATH]);
}
- OC_LOG_V(INFO, CONTAINER_TAG, "Add Bundle: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Add Bundle: (%s)",
std::string(bundleInfo->getID() + "; " +
bundleInfo->getPath()).c_str());
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
std::string(bundleId + "\' is not registered.").c_str());
}
}
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
std::string(bundleId + "\' is not registered.").c_str());
}
}
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Bundle with ID \'(%s)",
std::string(bundleId + "\' is not registered.").c_str());
}
}
if ((error = dlerror()) != NULL)
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Error : (%s)", error);
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Error : (%s)", error);
}
else
{
{
if ((error = dlerror()) != NULL)
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Error : (%s)", error);
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Error : (%s)", error);
}
}
}
else
{
//Unload module and return error
- OC_LOG(ERROR, CONTAINER_TAG, "Activation unsuccessful.");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Activation unsuccessful.");
}
BundleInfoInternal *bundleInfoInternal = (BundleInfoInternal *) m_bundles[bundleId];
{
deactivator_t *bundleDeactivator = m_bundles[id]->getBundleDeactivator();
- OC_LOG_V(INFO, CONTAINER_TAG, "De-activating bundle: (%s)", std::string(
+ OIC_LOG_V(INFO, CONTAINER_TAG, "De-activating bundle: (%s)", std::string(
m_bundles[id]->getID()).c_str());
if (bundleDeactivator != NULL)
else
{
//Unload module and return error
- OC_LOG(ERROR, CONTAINER_TAG, "De-activation unsuccessful.");
+ OIC_LOG(ERROR, CONTAINER_TAG, "De-activation unsuccessful.");
}
}
}
else
{
- OC_LOG(ERROR, CONTAINER_TAG, "addResource unsuccessful.");
+ OIC_LOG(ERROR, CONTAINER_TAG, "addResource unsuccessful.");
}
}
}
else
{
- OC_LOG(ERROR, CONTAINER_TAG, "removeResource unsuccessful.");
+ OIC_LOG(ERROR, CONTAINER_TAG, "removeResource unsuccessful.");
}
}
}
void ResourceContainerImpl::activateBundleThread(const std::string &id)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s)",
std::string(m_bundles[id]->getID()).c_str());
if (m_bundles[id]->getJavaBundle())
activateSoBundle (id);
}
- OC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Bundle activated: (%s)",
std::string(m_bundles[id]->getID()).c_str());
}
void ResourceContainerImpl::registerJavaBundle(RCSBundleInfo *bundleInfo)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "Registering Java bundle (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Registering Java bundle (%s)",
std::string(bundleInfo->getID()).c_str());
JavaVM *jvm;
JNIEnv *env;
{
fclose(file);
- OC_LOG_V(INFO, CONTAINER_TAG, "Resource bundle (%s)",
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Resource bundle (%s)",
std::string(bundleInfo->getPath() +
" available.").c_str());
}
else
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Resource bundle (%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Resource bundle (%s)",
std::string(bundleInfo->getPath() + " not available.").c_str());
return;
strcpy(classpath, "-Djava.class.path=");
strcat(classpath, bundleInfo->getPath().c_str());
- OC_LOG(INFO, CONTAINER_TAG,
+ OIC_LOG(INFO, CONTAINER_TAG,
std::string("Configured classpath: ").append(classpath).c_str());
options[1].optionString = classpath;
strcat(libraryPath, bundleInfo->getLibraryPath().c_str());
options[2].optionString = libraryPath;
- OC_LOG(INFO, CONTAINER_TAG,
+ OIC_LOG(INFO, CONTAINER_TAG,
std::string("Configured library path: ").append(libraryPath).c_str());
vm_args.version = JNI_VERSION_1_4;
if (res < 0)
{
- OC_LOG(ERROR, CONTAINER_TAG, "cannot create JavaVM.");
+ OIC_LOG(ERROR, CONTAINER_TAG, "cannot create JavaVM.");
return;
}
else
{
- OC_LOG(INFO, CONTAINER_TAG, "JVM successfully created.");
+ OIC_LOG(INFO, CONTAINER_TAG, "JVM successfully created.");
}
m_bundleVM.insert(std::pair< string, JavaVM * >(bundleInfo->getID(), jvm));
const char *className = bundleInfoInternal->getActivatorName().c_str();
- OC_LOG_V(INFO, CONTAINER_TAG, "Looking up class: (%s)", std::string(
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Looking up class: (%s)", std::string(
bundleInfoInternal->getActivatorName() + "|").c_str());
jclass bundleActivatorClass = env->FindClass(className);
if (bundleActivatorClass == NULL)
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
std::string( bundleInfoInternal->getID()
+ " bundle activator(" + bundleInfoInternal->getActivatorName()
+ ") not found ").c_str());
if (activateMethod == NULL)
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
std::string( bundleInfoInternal->getID()
+ " activate bundle method not found ").c_str());
return;
if (deactivateMethod == NULL)
{
- OC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
+ OIC_LOG_V(ERROR, CONTAINER_TAG, "Cannot register bundle (%s)",
std::string( bundleInfoInternal->getID()
+ " deactivate bundle method not found ").c_str());
return;
m_bundles[bundleInfo->getID()] = ((BundleInfoInternal *)bundleInfo);
- OC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
+ OIC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
}
void ResourceContainerImpl::activateJavaBundle(string bundleId)
{
- OC_LOG(INFO, CONTAINER_TAG, "Activating java bundle");
+ OIC_LOG(INFO, CONTAINER_TAG, "Activating java bundle");
JavaVM *vm = getJavaVM(bundleId);
BundleInfoInternal *bundleInfoInternal = (BundleInfoInternal *) m_bundles[bundleId];
{
if (vm->AttachCurrentThread((void **) &env, NULL) != 0)
{
- OC_LOG(ERROR, CONTAINER_TAG, "Failed to attach ");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Failed to attach ");
}
}
else if (envStat == JNI_EVERSION)
{
- OC_LOG(ERROR, CONTAINER_TAG, "Env: version not supported ");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Env: version not supported ");
}
env->CallVoidMethod(bundleInfoInternal->getJavaBundleActivatorObject(),
void ResourceContainerImpl::deactivateJavaBundle(string bundleId)
{
- OC_LOG(INFO, CONTAINER_TAG, "Deactivating java bundle");
+ OIC_LOG(INFO, CONTAINER_TAG, "Deactivating java bundle");
JavaVM *vm = getJavaVM(bundleId);
BundleInfoInternal *bundleInfoInternal = (BundleInfoInternal *) m_bundles[bundleId];
{
if (vm->AttachCurrentThread((void **) &env, NULL) != 0)
{
- OC_LOG(ERROR, CONTAINER_TAG, "Failed to attach ");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Failed to attach ");
}
}
else if (envStat == JNI_EVERSION)
{
- OC_LOG(ERROR, CONTAINER_TAG, "Env: version not supported ");
+ OIC_LOG(ERROR, CONTAINER_TAG, "Env: version not supported ");
}
env->CallVoidMethod(bundleInfoInternal->getJavaBundleActivatorObject(),
void ResourceContainerImpl::unregisterBundleJava(string id)
{
- OC_LOG_V(INFO, CONTAINER_TAG, "Unregister Java bundle: (%s)", std::string(
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Unregister Java bundle: (%s)", std::string(
m_bundles[id]->getID()).c_str());
- OC_LOG(INFO, CONTAINER_TAG, "Destroying JVM");
+ OIC_LOG(INFO, CONTAINER_TAG, "Destroying JVM");
m_bundleVM[id]->DestroyJavaVM();
static void printStoragedResources(OCRDStorePublishResources *payload)
{
- OC_LOG(DEBUG, TAG, "Print Storage Resources ... ");
+ OIC_LOG(DEBUG, TAG, "Print Storage Resources ... ");
for (OCRDStorePublishResources *temp = payload; temp; temp = temp->next)
{
if (temp->publishedResource)
OCResourceCollectionPayload *storeResource = (OCResourceCollectionPayload *)OICCalloc(1, sizeof(OCResourceCollectionPayload));
if (!storeResource)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for OCRDStorePublishResources.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for OCRDStorePublishResources.");
return OC_STACK_NO_MEMORY;
}
- OC_LOG_V(DEBUG, TAG, "Storing Resources for %s:%u", address->addr, address->port);
+ OIC_LOG_V(DEBUG, TAG, "Storing Resources for %s:%u", address->addr, address->port);
OCTagsPayload *tags = payload->tags;
storeResource->tags = OCCopyTagsResources(tags->n.deviceName, tags->di.id, tags->baseURI,
tags->bitmap, address->port, tags->ins, tags->rts, tags->drel, tags->ttl);
if (!storeResource->tags)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for tags.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for tags.");
OCFreeCollectionResource(storeResource);
return OC_STACK_NO_MEMORY;
}
links->rel, links->obs, links->title, links->uri, links->ins, links->mt);
if (!storeResource->setLinks)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for links.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for links.");
OCFreeCollectionResource(storeResource);
return OC_STACK_NO_MEMORY;
}
links->obs, links->title, links->uri, links->ins, links->mt);
if (!temp->next)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for links.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for links.");
OCFreeCollectionResource(storeResource);
return OC_STACK_NO_MEMORY;
}
// not null it will continue execution.
if (!resourceType && !interfaceType)
{
- OC_LOG(DEBUG, TAG, "Missing resource type or interace type.");
+ OIC_LOG(DEBUG, TAG, "Missing resource type or interace type.");
return OC_STACK_INVALID_PARAM;
}
- OC_LOG(DEBUG, TAG, "Check Resource in RD");
+ OIC_LOG(DEBUG, TAG, "Check Resource in RD");
if (g_rdStorage && g_rdStorage->publishedResource)
{
for (OCRDStorePublishResources *pResource = g_rdStorage;
// If either rt or itf are NULL, it should skip remaining code execution.
if (!tLinks->rt || !tLinks->itf)
{
- OC_LOG(DEBUG, TAG, "Either resource type or interface type is missing.");
+ OIC_LOG(DEBUG, TAG, "Either resource type or interface type is missing.");
continue;
}
if (resourceType)
OCStringLL *temp = tLinks->rt;
while(temp)
{
- OC_LOG_V(DEBUG, TAG, "Resource Type: %s %s", resourceType, temp->value);
+ OIC_LOG_V(DEBUG, TAG, "Resource Type: %s %s", resourceType, temp->value);
if (strcmp(resourceType, temp->value) == 0)
{
OCTagsPayload *tag = pResource->publishedResource->tags;
OCStringLL *temp = tLinks->itf;
while (temp)
{
- OC_LOG_V(DEBUG, TAG, "Interface Type: %s %s", interfaceType, temp->value);
+ OIC_LOG_V(DEBUG, TAG, "Interface Type: %s %s", interfaceType, temp->value);
if (strcmp(interfaceType, temp->value) == 0)
{
OCTagsPayload *tag = pResource->publishedResource->tags;
if (result == OC_STACK_OK)
{
- OC_LOG(DEBUG, TAG, "Resource Directory send successful...");
+ OIC_LOG(DEBUG, TAG, "Resource Directory send successful...");
}
else
{
- OC_LOG(ERROR, TAG, "Resource Directory send failed...");
+ OIC_LOG(ERROR, TAG, "Resource Directory send failed...");
}
return result;
__attribute__((unused)) OCClientResponse *clientResponse)
{
OCStackApplicationResult ret = OC_STACK_DELETE_TRANSACTION;
- OC_LOG(DEBUG, TAG, "Successfully published resources.");
+ OIC_LOG(DEBUG, TAG, "Successfully published resources.");
if (OC_STACK_OK == OCStopMulticastServer())
{
- OC_LOG_V(DEBUG, TAG, "Stopped receiving the multicast traffic.");
+ OIC_LOG_V(DEBUG, TAG, "Stopped receiving the multicast traffic.");
}
else
{
- OC_LOG_V(DEBUG, TAG, "Failed stopping the multicast traffic.");
+ OIC_LOG_V(DEBUG, TAG, "Failed stopping the multicast traffic.");
}
return ret;
static void retreiveRDDetails(OCClientResponse *clientResponse, OCRDBiasFactorCB clientCB)
{
- OC_LOG_V(DEBUG, TAG, "\tAddress of the RD: %s:%d", clientResponse->devAddr.addr,
+ OIC_LOG_V(DEBUG, TAG, "\tAddress of the RD: %s:%d", clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
+ OIC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
// TODO: Multiple Resource Directory will have different biasFactor,
// needs to cache here detail
static OCStackApplicationResult handleDiscoverCB(void *ctx,
__attribute__((unused)) OCDoHandle handle, OCClientResponse *clientResponse)
{
- OC_LOG(DEBUG, TAG, "Found Resource Directory");
+ OIC_LOG(DEBUG, TAG, "Found Resource Directory");
OCStackApplicationResult ret = OC_STACK_DELETE_TRANSACTION;
OCRDClientContextCB *cb = (OCRDClientContextCB *)ctx;
if (!cb)
{
- OC_LOG(ERROR, TAG, "RD Context Invalid Parameters.");
+ OIC_LOG(ERROR, TAG, "RD Context Invalid Parameters.");
return ret;
}
if (cb->context != (void *) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(ERROR, TAG, "RD Context Invalid Context Value Parameters.");
+ OIC_LOG(ERROR, TAG, "RD Context Invalid Context Value Parameters.");
return ret;
}
if (clientResponse)
{
- OC_LOG_V(DEBUG, TAG, "Callback Context for DISCOVER query received successfully :%d.", clientResponse->result);
+ OIC_LOG_V(DEBUG, TAG, "Callback Context for DISCOVER query received successfully :%d.", clientResponse->result);
if (clientResponse->result == OC_STACK_OK)
{
retreiveRDDetails(clientResponse, cb->cbFunc);
}
else
{
- OC_LOG(ERROR, TAG, "Discovery of RD Failed");
+ OIC_LOG(ERROR, TAG, "Discovery of RD Failed");
}
}
else
{
- OC_LOG(ERROR, TAG, "No client response.");
+ OIC_LOG(ERROR, TAG, "No client response.");
}
OICFree(cb);
{
if (!cbBiasFactor)
{
- OC_LOG(DEBUG, TAG, "No callback function specified.");
+ OIC_LOG(DEBUG, TAG, "No callback function specified.");
return OC_STACK_INVALID_CALLBACK;
}
char queryUri[MAX_URI_LENGTH] = { '\0' };
snprintf(queryUri, MAX_URI_LENGTH, "coap://%s%s", OC_MULTICAST_PREFIX, OC_RSRVD_RD_URI);
- OC_LOG_V(DEBUG, TAG, "Querying RD: %s\n", queryUri);
+ OIC_LOG_V(DEBUG, TAG, "Querying RD: %s\n", queryUri);
OCRDClientContextCB *cbContext = (OCRDClientContextCB *)OICCalloc(1, sizeof(OCRDClientContextCB));
if (!cbContext)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
*stringLL = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
if (!*stringLL)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
(*stringLL)->value = OICStrdup(value);
if (!(*stringLL)->value)
{
- OC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
+ OIC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
return OC_STACK_NO_MEMORY;
}
}
cur->next = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
if (!cur->next)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
cur->next->value = OICStrdup(value);
if (!cur->next->value)
{
- OC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
+ OIC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
return OC_STACK_NO_MEMORY;
}
}
{
if (!addr)
{
- OC_LOG(ERROR, TAG, "RD address not specified.");
+ OIC_LOG(ERROR, TAG, "RD address not specified.");
return OC_STACK_INVALID_PARAM;
}
char targetUri[MAX_URI_LENGTH];
snprintf(targetUri, MAX_URI_LENGTH, "coap://%s:%d%s?rt=%s", addr, port,
OC_RSRVD_RD_URI, OC_RSRVD_RESOURCE_TYPE_RDPUBLISH);
- OC_LOG_V(DEBUG, TAG, "Target URI : %s", targetUri);
+ OIC_LOG_V(DEBUG, TAG, "Target URI : %s", targetUri);
// Gather all resources locally and do publish
OCCallbackData cbData = { 0 };
OICStrcpy(rdAddr.addr, MAX_ADDR_STR_SIZE, addr);
rdAddr.port = port;
- OC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
+ OIC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
return sendRequest(OC_REST_POST, targetUri, &rdAddr, (OCPayload *)rdPayload, cbData);
no_memory:
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
va_end(arguments);
if (rt)
{
{
if (!ehRequest)
{
- OC_LOG(DEBUG, TAG, "Invalid request pointer.");
+ OIC_LOG(DEBUG, TAG, "Invalid request pointer.");
return OC_EH_ERROR;
}
OCEntityHandlerResult ehResult = OC_EH_OK;
- OC_LOG_V(DEBUG, TAG, "Received OC_REST_GET from client with query: %s.", ehRequest->query);
+ OIC_LOG_V(DEBUG, TAG, "Received OC_REST_GET from client with query: %s.", ehRequest->query);
OCRDPayload *rdPayload = OCRDPayloadCreate();
if (!rdPayload)
return OC_STACK_NO_MEMORY;
}
- OC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
+ OIC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
if (sendResponse(ehRequest, rdPayload) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Sending response failed.");
+ OIC_LOG(ERROR, TAG, "Sending response failed.");
ehResult = OC_EH_ERROR;
}
if (!ehRequest)
{
- OC_LOG(DEBUG, TAG, "Invalid request pointer");
+ OIC_LOG(DEBUG, TAG, "Invalid request pointer");
return OC_EH_ERROR;
}
- OC_LOG_V(DEBUG, TAG, "Received OC_REST_PUT from client with query: %s.", ehRequest->query);
+ OIC_LOG_V(DEBUG, TAG, "Received OC_REST_PUT from client with query: %s.", ehRequest->query);
OCRDPayload *payload = (OCRDPayload *)ehRequest->payload;
if (payload && payload->rdPublish)
OCRDPayload *rdPayload = OCRDPayloadCreate();
if (!rdPayload)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
- OC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
+ OIC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
if (sendResponse(ehRequest, rdPayload) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Sending response failed.");
+ OIC_LOG(ERROR, TAG, "Sending response failed.");
ehResult = OC_EH_ERROR;
}
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG(DEBUG, TAG, "Flag includes OC_REQUEST_FLAG.");
+ OIC_LOG(DEBUG, TAG, "Flag includes OC_REQUEST_FLAG.");
switch (ehRequest->method)
{
case OC_REST_GET:
if (result == OC_STACK_OK)
{
- OC_LOG(DEBUG, TAG, "Resource Directory Started.");
+ OIC_LOG(DEBUG, TAG, "Resource Directory Started.");
}
else
{
- OC_LOG(ERROR, TAG, "Failed starting Resource Directory.");
+ OIC_LOG(ERROR, TAG, "Failed starting Resource Directory.");
}
return result;
if (result == OC_STACK_OK)
{
- OC_LOG(DEBUG, TAG, "Resource Directory Stopped.");
+ OIC_LOG(DEBUG, TAG, "Resource Directory Stopped.");
}
else
{
- OC_LOG(ERROR, TAG, "Failed stopping Resource Directory.");
+ OIC_LOG(ERROR, TAG, "Failed stopping Resource Directory.");
}
return result;
}
{
static constexpr char DEFAULT_ENTER_STR[]{ "IN" };
- OC_LOG_V(m_level, m_tag, "%s %s", m_scopeName, DEFAULT_ENTER_STR);
+ OIC_LOG_V(m_level, m_tag, "%s %s", m_scopeName, DEFAULT_ENTER_STR);
}
~ScopeLogger()
if (std::uncaught_exception())
{
- OC_LOG_V(m_level, m_tag, "%s %s by stack unwinding (uncaught exception)",
+ OIC_LOG_V(m_level, m_tag, "%s %s by stack unwinding (uncaught exception)",
m_scopeName, DEFAULT_EXIT_STR);
}
else
{
- OC_LOG_V(m_level, m_tag, "%s %s", m_scopeName, DEFAULT_EXIT_STR);
+ OIC_LOG_V(m_level, m_tag, "%s %s", m_scopeName, DEFAULT_EXIT_STR);
}
}
DevicePresencePtr DeviceAssociation::findDevice(const std::string & address)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"findDevice()");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"findDevice()");
DevicePresencePtr retDevice = nullptr;
for(auto it : s_deviceList)
{
if(address == it->getAddress())
{
- OC_LOG_V(DEBUG,BROKER_TAG,"find device in deviceList");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"find device in deviceList");
retDevice = it;
break;
}
void DeviceAssociation::addDevice(DevicePresencePtr dPresence)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"addDevice()");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"addDevice()");
DevicePresencePtr foundDevice = findDevice(dPresence->getAddress());
if(foundDevice == nullptr)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"add device in deviceList");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"add device in deviceList");
s_deviceList.push_back(dPresence);
}
}
void DeviceAssociation::removeDevice(DevicePresencePtr dPresence)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"removeDevice()");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"removeDevice()");
DevicePresencePtr foundDevice = findDevice(dPresence->getAddress());
if(foundDevice != nullptr)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"remove device in deviceList");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"remove device in deviceList");
s_deviceList.remove(foundDevice);
foundDevice.reset();
}
bool DeviceAssociation::isEmptyDeviceList()
{
- OC_LOG_V(DEBUG,BROKER_TAG,"isEmptyDeviceList()");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"isEmptyDeviceList()");
return s_deviceList.empty();
}
} // namespace Service
{
if(presenceSubscriber.isSubscribing())
{
- OC_LOG_V(DEBUG,BROKER_TAG,"unsubscribed presence.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"unsubscribed presence.");
presenceSubscriber.unsubscribe();
}
resourcePresenceList.clear();
- OC_LOG_V(DEBUG,BROKER_TAG,"destroy Timer.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"destroy Timer.");
}
void DevicePresence::initializeDevicePresence(PrimitiveResourcePtr pResource)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "initializeDevicePresence()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "initializeDevicePresence()");
address = pResource->getHost();
- OC_LOG_V(DEBUG, BROKER_TAG, "%s",address.c_str());
+ OIC_LOG_V(DEBUG, BROKER_TAG, "%s",address.c_str());
try
{
- OC_LOG_V(DEBUG, BROKER_TAG, "subscribe Presence");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "subscribe Presence");
presenceSubscriber
= PresenceSubscriber(address, BROKER_TRANSPORT, pSubscribeRequestCB);
} catch(RCSPlatformException &e)
{
- OC_LOG_V(DEBUG, BROKER_TAG,
+ OIC_LOG_V(DEBUG, BROKER_TAG,
"exception in subscribe Presence %s", e.getReason().c_str());
throw;
}
const std::string DevicePresence::getAddress() const
{
- OC_LOG_V(DEBUG, BROKER_TAG, "getAddress()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "getAddress()");
return address;
}
void DevicePresence::addPresenceResource(ResourcePresence * rPresence)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "addPresenceResource()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "addPresenceResource()");
resourcePresenceList.push_back(rPresence);
}
void DevicePresence::removePresenceResource(ResourcePresence * rPresence)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "removePresenceResource()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "removePresenceResource()");
resourcePresenceList.remove(rPresence);
}
void DevicePresence::changeAllPresenceMode(BROKER_MODE mode)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "changeAllPresenceMode()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "changeAllPresenceMode()");
if(!resourcePresenceList.empty())
{
for(auto it : resourcePresenceList)
bool DevicePresence::isEmptyResourcePresence() const
{
- OC_LOG_V(DEBUG, BROKER_TAG, "isEmptyResourcePresence()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "isEmptyResourcePresence()");
return resourcePresenceList.empty();
}
void DevicePresence::subscribeCB(OCStackResult ret,
const unsigned int seq, const std::string & hostAddress)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "subscribeCB()");
- OC_LOG_V(DEBUG, BROKER_TAG, "Received presence CB from: %s",hostAddress.c_str());
- OC_LOG_V(DEBUG, BROKER_TAG, "In subscribeCB: %d",ret);
+ OIC_LOG_V(DEBUG, BROKER_TAG, "subscribeCB()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "Received presence CB from: %s",hostAddress.c_str());
+ OIC_LOG_V(DEBUG, BROKER_TAG, "In subscribeCB: %d",ret);
if(isRunningTimeOut)
{
case OC_STACK_RESOURCE_CREATED:
case OC_STACK_CONTINUE:
{
- OC_LOG_V(DEBUG, BROKER_TAG, "SEQ# %d",seq);
+ OIC_LOG_V(DEBUG, BROKER_TAG, "SEQ# %d",seq);
setDeviceState(DEVICE_STATE::ALIVE);
- OC_LOG_V(DEBUG, BROKER_TAG, "device state : %d",
+ OIC_LOG_V(DEBUG, BROKER_TAG, "device state : %d",
(int)getDeviceState());
changeAllPresenceMode(BROKER_MODE::DEVICE_PRESENCE_MODE);
presenceTimerHandle
}
default:
{
- OC_LOG_V(DEBUG, BROKER_TAG, "Presence Lost Signal because unknown type");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "Presence Lost Signal because unknown type");
setDeviceState(DEVICE_STATE::LOST_SIGNAL);
changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE);
break;
void DevicePresence::timeOutCB(TimerID /*id*/)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"timeOutCB()");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"timeOutCB()");
std::unique_lock<std::mutex> lock(timeoutMutex);
isRunningTimeOut = true;
- OC_LOG_V(DEBUG, BROKER_TAG,
+ OIC_LOG_V(DEBUG, BROKER_TAG,
"Timeout execution. will be discard after receiving cb message");
setDeviceState(DEVICE_STATE::LOST_SIGNAL);
changeAllPresenceMode(BROKER_MODE::NON_PRESENCE_MODE);
{
if(s_presenceList != nullptr)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "clear the ResourcePresenceList.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "clear the ResourcePresenceList.");
s_presenceList->erase(s_presenceList->begin(), s_presenceList->end());
s_presenceList->clear();
}
if(s_brokerIDMap != nullptr)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "clear the brokerIDMap.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "clear the brokerIDMap.");
s_brokerIDMap->erase(s_brokerIDMap->begin(), s_brokerIDMap->end());
s_brokerIDMap->clear();
}
BrokerID ResourceBroker::hostResource(PrimitiveResourcePtr pResource, BrokerCB cb)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "hostResource().");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "hostResource().");
if(pResource == nullptr || cb == nullptr || cb == NULL)
{
throw InvalidParameterException("[hostResource] input parameter(PrimitiveResource or BrokerCB) is Invalid");
ResourcePresencePtr presenceItem = findResourcePresence(pResource);
if(presenceItem == nullptr)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "Not found any Handled Resource.");
- OC_LOG_V(DEBUG, BROKER_TAG, "Create New Resource Presence Handler.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "Not found any Handled Resource.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "Create New Resource Presence Handler.");
try
{
- OC_LOG_V(DEBUG, BROKER_TAG, "create the ResourcePresence.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "create the ResourcePresence.");
presenceItem.reset(new ResourcePresence());
presenceItem->initializeResourcePresence(pResource);
}catch(RCSPlatformException &e)
}
if(s_presenceList != nullptr)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "push the ResourcePresence in presenceList.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "push the ResourcePresence in presenceList.");
s_presenceList->push_back(presenceItem);
}
}
- OC_LOG_V(DEBUG, BROKER_TAG, "add the BrokerRequester in ResourcePresence.");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "add the BrokerRequester in ResourcePresence.");
presenceItem->addBrokerRequester(retID, cb);
BrokerCBResourcePair pair(presenceItem, cb);
void ResourceBroker::cancelHostResource(BrokerID brokerId)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"cancelHostResource().");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"cancelHostResource().");
if(brokerId == 0)
{
// input parameter is wrong.
// hostResource never return value 0;
- OC_LOG_V(DEBUG,BROKER_TAG,"brokerId is zero.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"brokerId is zero.");
throw InvalidParameterException("[cancelHostResource] brokerId is invalid.");
}
if(it == s_brokerIDMap->end())
{
// not found requested brokerId in BrokerMap;
- OC_LOG_V(DEBUG,BROKER_TAG,"brokerId is not found in brokerIDMap.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"brokerId is not found in brokerIDMap.");
throw InvalidParameterException("[cancelHostResource] brokerId is not found in brokerIDMap.");
}
else
if(presenceItem->isEmptyRequester())
{
- OC_LOG_V(DEBUG,BROKER_TAG,"remove resourcePresence in presenceList because it is not including any requester info.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"remove resourcePresence in presenceList because it is not including any requester info.");
s_presenceList->remove(presenceItem);
}
}
BROKER_STATE ResourceBroker::getResourceState(BrokerID brokerId)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"getResourceState().");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"getResourceState().");
if(brokerId == 0)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"brokerId is zero.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"brokerId is zero.");
throw InvalidParameterException("[getResourceState] input BrokerID is Invalid");
}
if(it == s_brokerIDMap->end())
{
// not found requested brokerId in BrokerMap;
- OC_LOG_V(DEBUG,BROKER_TAG,"brokerId is not found in brokerIDMap.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"brokerId is not found in brokerIDMap.");
throw InvalidParameterException("[getResourceState] input BrokerID is unknown ID");
}
else
BROKER_STATE ResourceBroker::getResourceState(PrimitiveResourcePtr pResource)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"getResourceState().");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"getResourceState().");
if(pResource == nullptr)
{
throw InvalidParameterException("[getResourceState] input PrimitiveResource is Invalid");
void ResourceBroker::initializeResourceBroker()
{
- OC_LOG_V(DEBUG,BROKER_TAG,"initializeResourceBroker().");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"initializeResourceBroker().");
if(s_presenceList == nullptr)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"create the presenceList.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"create the presenceList.");
s_presenceList = std::unique_ptr<PresenceList>(new PresenceList);
}
if(s_brokerIDMap == nullptr)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"create the brokerIDMap.");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"create the brokerIDMap.");
s_brokerIDMap = std::unique_ptr<BrokerIDMap>(new BrokerIDMap);
}
}
ResourcePresencePtr ResourceBroker::findResourcePresence(PrimitiveResourcePtr pResource)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"findResourcePresence().");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"findResourcePresence().");
ResourcePresencePtr retResource(nullptr);
if(s_presenceList->empty() != true)
BrokerID ResourceBroker::generateBrokerID()
{
- OC_LOG_V(DEBUG,BROKER_TAG,"generateBrokerID().");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"generateBrokerID().");
BrokerID retID = 0;
srand(time(NULL));
void getCallback(const HeaderOptions &hos, const ResponseStatement& rep,
int eCode, std::weak_ptr<ResourcePresence> this_ptr)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"getCallback().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"getCallback().\n");
std::shared_ptr<ResourcePresence> Ptr = this_ptr.lock();
if(Ptr)
{
}
void timeOutCallback(unsigned int msg, std::weak_ptr<ResourcePresence> this_ptr)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"timeOutCallback().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"timeOutCallback().\n");
std::shared_ptr<ResourcePresence> Ptr = this_ptr.lock();
if(Ptr)
{
void ResourcePresence::initializeResourcePresence(PrimitiveResourcePtr pResource)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"initializeResourcePresence().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"initializeResourcePresence().\n");
pGetCB = std::bind(getCallback, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::weak_ptr<ResourcePresence>(shared_from_this()));
pTimeoutCB = std::bind(timeOutCallback, std::placeholders::_1,
(new std::list<BrokerRequesterInfoPtr>);
timeoutHandle = expiryTimer.post(BROKER_SAFE_MILLISECOND, pTimeoutCB);
- OC_LOG_V(DEBUG,BROKER_TAG,"initializeResourcePresence::requestGet.\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"initializeResourcePresence::requestGet.\n");
primitiveResource->requestGet(pGetCB);
registerDevicePresence();
void ResourcePresence::addBrokerRequester(BrokerID _id, BrokerCB _cb)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"addBrokerRequester().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"addBrokerRequester().\n");
requesterList->push_back(
std::make_shared<BrokerRequesterInfo>(BrokerRequesterInfo(_id, _cb)));
}
void ResourcePresence::removeAllBrokerRequester()
{
- OC_LOG_V(DEBUG,BROKER_TAG,"removeAllBrokerRequester().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"removeAllBrokerRequester().\n");
if(requesterList != nullptr)
{
requesterList->erase(requesterList->begin(), requesterList->end());
void ResourcePresence::removeBrokerRequester(BrokerID _id)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"removeBrokerRequester().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"removeBrokerRequester().\n");
std::list<BrokerRequesterInfoPtr>::iterator iter = requesterList->begin();
for(; iter != requesterList->end(); ++iter)
{
if(iter->get()->brokerId == _id)
{
- OC_LOG_V(DEBUG,BROKER_TAG,"find broker-id in requesterList.\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"find broker-id in requesterList.\n");
requesterList->erase(iter);
break;
}
bool ResourcePresence::isEmptyRequester() const
{
- OC_LOG_V(DEBUG,BROKER_TAG,"isEmptyRequester().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"isEmptyRequester().\n");
return (requesterList!=nullptr)?requesterList->empty():true;
}
int ResourcePresence::requesterListSize() const {
- OC_LOG_V(DEBUG,BROKER_TAG,"requesterListSize().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"requesterListSize().\n");
return (requesterList!=nullptr)?requesterList->size():0;
}
void ResourcePresence::requestResourceState() const
{
- OC_LOG_V(DEBUG,BROKER_TAG,"requestResourceState().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"requestResourceState().\n");
primitiveResource->requestGet(pGetCB);
- OC_LOG_V(DEBUG, BROKER_TAG, "Request Get\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "Request Get\n");
}
void ResourcePresence::registerDevicePresence()
{
- OC_LOG_V(DEBUG,BROKER_TAG,"registerDevicePresence().\n");
+ OIC_LOG_V(DEBUG,BROKER_TAG,"registerDevicePresence().\n");
std::string deviceAddress = primitiveResource->getHost();
DevicePresencePtr foundDevice
void ResourcePresence::executeAllBrokerCB(BROKER_STATE changedState)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "executeAllBrokerCB().\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "executeAllBrokerCB().\n");
if(state != changedState)
{
setResourcestate(changedState);
void ResourcePresence::setResourcestate(BROKER_STATE _state)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "setResourcestate().\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "setResourcestate().\n");
this->state = _state;
}
void ResourcePresence::timeOutCB(unsigned int /*msg*/)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "timeOutCB()");
- OC_LOG_V(DEBUG, BROKER_TAG, "waiting for terminate getCB\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "timeOutCB()");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "waiting for terminate getCB\n");
std::unique_lock<std::mutex> lock(cbMutex);
time_t currentTime;
return;
}
this->isWithinTime = false;
- OC_LOG_V(DEBUG, BROKER_TAG,
+ OIC_LOG_V(DEBUG, BROKER_TAG,
"Timeout execution. will be discard after receiving cb message.\n");
executeAllBrokerCB(BROKER_STATE::LOST_SIGNAL);
void ResourcePresence::pollingCB(unsigned int /*msg*/)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "pollingCB().\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "pollingCB().\n");
if(this->requesterList->size() != 0)
{
this->requestResourceState();
void ResourcePresence::getCB(const HeaderOptions & /*hos*/,
const ResponseStatement & /*rep*/, int eCode)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "getCB().\n");
- OC_LOG_V(DEBUG, BROKER_TAG, "waiting for terminate TimeoutCB.\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "getCB().\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "waiting for terminate TimeoutCB.\n");
std::unique_lock<std::mutex> lock(cbMutex);
time_t currentTime;
void ResourcePresence::verifiedGetResponse(int eCode)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "verifiedGetResponse().\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "verifiedGetResponse().\n");
BROKER_STATE verifiedState = BROKER_STATE::NONE;
switch(eCode)
{
}
executeAllBrokerCB(verifiedState);
- OC_LOG_V(DEBUG, BROKER_TAG, "resource state : %d",(int)state);
+ OIC_LOG_V(DEBUG, BROKER_TAG, "resource state : %d",(int)state);
}
const PrimitiveResourcePtr ResourcePresence::getPrimitiveResource() const
{
- OC_LOG_V(DEBUG, BROKER_TAG, "getPrimitiveResource()\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "getPrimitiveResource()\n");
return primitiveResource;
}
BROKER_STATE ResourcePresence::getResourceState() const
{
- OC_LOG_V(DEBUG, BROKER_TAG, "getResourceState()\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "getResourceState()\n");
return state;
}
void ResourcePresence::changePresenceMode(BROKER_MODE newMode)
{
- OC_LOG_V(DEBUG, BROKER_TAG, "changePresenceMode()\n");
+ OIC_LOG_V(DEBUG, BROKER_TAG, "changePresenceMode()\n");
if(newMode != mode)
{
expiryTimer.cancel(timeoutHandle);
if (isMonitoring())
{
- OC_LOG(DEBUG, TAG, "startMonitoring : already started");
+ OIC_LOG(DEBUG, TAG, "startMonitoring : already started");
throw RCSBadRequestException{ "Monitoring already started." };
}
if (!isMonitoring())
{
- OC_LOG(DEBUG, TAG, "stopMonitoring : Not started");
+ OIC_LOG(DEBUG, TAG, "stopMonitoring : Not started");
return;
}
if (isCaching())
{
- OC_LOG(DEBUG, TAG, "startCaching : already Started");
+ OIC_LOG(DEBUG, TAG, "startCaching : already Started");
throw RCSBadRequestException{ "Caching already started." };
}
m_primitiveResource, { }, REPORT_FREQUENCY::NONE, 0);
}
- OC_LOG_V(DEBUG, TAG, "startCaching CACHE ID %d", m_cacheId);
+ OIC_LOG_V(DEBUG, TAG, "startCaching CACHE ID %d", m_cacheId);
}
void RCSRemoteResourceObject::stopCaching()
if (!isCaching())
{
- OC_LOG(DEBUG, TAG, "Caching already terminated");
+ OIC_LOG(DEBUG, TAG, "Caching already terminated");
return;
}
}
catch (const OC::OCException& e)
{
- OC_LOG_V(WARNING, LOG_TAG, "Error (%s)", e.what());
+ OIC_LOG_V(WARNING, LOG_TAG, "Error (%s)", e.what());
}
return OC_EH_ERROR;
}
catch (...)
{
- OC_LOG(WARNING, LOG_TAG, "Failed to unregister resource.");
+ OIC_LOG(WARNING, LOG_TAG, "Failed to unregister resource.");
}
}
}
OCEntityHandlerResult RCSResourceObject::entityHandler(
const std::shared_ptr< OC::OCResourceRequest >& request)
{
- OC_LOG(WARNING, LOG_TAG, "entityHandler");
+ OIC_LOG(WARNING, LOG_TAG, "entityHandler");
if (!request)
{
return OC_EH_ERROR;
}
catch (const std::exception& e)
{
- OC_LOG_V(WARNING, LOG_TAG, "Failed to handle request : %s", e.what());
+ OIC_LOG_V(WARNING, LOG_TAG, "Failed to handle request : %s", e.what());
throw;
}
catch (...)
{
- OC_LOG(WARNING, LOG_TAG, "Failed to handle request.");
+ OIC_LOG(WARNING, LOG_TAG, "Failed to handle request.");
throw;
}
auto replaced = requestHandler->applyAcceptanceMethod(response.getAcceptanceMethod(),
*this, requstAttrs);
- OC_LOG_V(WARNING, LOG_TAG, "replaced num %zu", replaced.size());
+ OIC_LOG_V(WARNING, LOG_TAG, "replaced num %zu", replaced.size());
for (const auto& attrKeyValPair : replaced)
{
std::shared_ptr< AttributeUpdatedListener > foundListener;
autoNotify(attrsChanged, m_autoNotifyPolicy);
return sendResponse(*this, request, response);
} catch (const RCSPlatformException& e) {
- OC_LOG_V(ERROR, LOG_TAG, "Error : %s ", e.what());
+ OIC_LOG_V(ERROR, LOG_TAG, "Error : %s ", e.what());
return OC_EH_ERROR;
}
}
if (m_requestGenList.end() != m_requestGenList.find(id))
{
m_requestGenList[id]->stop();
- OC_LOG_V(INFO, TAG, "Auto request generation session stopped [%d]", id);
+ OIC_LOG_V(INFO, TAG, "Auto request generation session stopped [%d]", id);
return;
}
- OC_LOG_V(ERROR, TAG, "Invalid verification id : %d", id);
+ OIC_LOG_V(ERROR, TAG, "Invalid verification id : %d", id);
}
void AutoRequestGenMngr::onProgressChange(int sessionId, OperationState state,
std::lock_guard<std::mutex> lock(m_statusLock);
if (m_status)
{
- OC_LOG(ERROR, TAG, "Operation already in progress !");
+ OIC_LOG(ERROR, TAG, "Operation already in progress !");
throw OperationInProgressException("Another GET request generation session is already in progress!");
}
void GETRequestGenerator::SendAllRequests()
{
// Notify the progress status
- OC_LOG(DEBUG, TAG, "Sending OP_START event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_START event");
m_callback(m_id, OP_START);
do
void GETRequestGenerator::onResponseReceived(SimulatorResult result,
SimulatorResourceModelSP repModel)
{
- OC_LOG_V(INFO, TAG, "Response recieved result:%d", result);
+ OIC_LOG_V(INFO, TAG, "Response recieved result:%d", result);
m_responseCnt++;
completed();
}
{
if (m_stopRequested)
{
- OC_LOG(DEBUG, TAG, "Sending OP_ABORT event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_ABORT event");
m_callback(m_id, OP_ABORT);
}
else
{
- OC_LOG(DEBUG, TAG, "Sending OP_COMPLETE event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_COMPLETE event");
m_callback(m_id, OP_COMPLETE);
}
}
-}
\ No newline at end of file
+}
// Check the representation
if (!m_rep)
{
- OC_LOG(ERROR, TAG, "Invalid Representation given!");
+ OIC_LOG(ERROR, TAG, "Invalid Representation given!");
throw SimulatorException(SIMULATOR_ERROR, "Invalid representation detected!");
}
std::lock_guard<std::mutex> lock(m_statusLock);
if (m_status)
{
- OC_LOG(ERROR, TAG, "Operation already in progress !");
+ OIC_LOG(ERROR, TAG, "Operation already in progress !");
throw OperationInProgressException("Another POST request generation session is already in progress!");
}
void POSTRequestGenerator::SendAllRequests()
{
// Notify the progress status
- OC_LOG(DEBUG, TAG, "Sending OP_START event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_START event");
m_callback(m_id, OP_START);
// Create attribute generator for value manipulation
if (!attributeGenList.size())
{
- OC_LOG(ERROR, TAG, "Zero attribute found from resource model!");
+ OIC_LOG(ERROR, TAG, "Zero attribute found from resource model!");
return;
}
void POSTRequestGenerator::onResponseReceived(SimulatorResult result,
SimulatorResourceModelSP repModel)
{
- OC_LOG_V(INFO, TAG, "Response recieved result:%d", result);
+ OIC_LOG_V(INFO, TAG, "Response recieved result:%d", result);
m_responseCnt++;
completed();
}
{
if (m_stopRequested)
{
- OC_LOG(DEBUG, TAG, "Sending OP_ABORT event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_ABORT event");
m_callback(m_id, OP_ABORT);
}
else
{
- OC_LOG(DEBUG, TAG, "Sending OP_COMPLETE event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_COMPLETE event");
m_callback(m_id, OP_COMPLETE);
}
}
-}
\ No newline at end of file
+}
// Check the representation
if (!m_rep)
{
- OC_LOG(ERROR, TAG, "Invalid Representation given!");
+ OIC_LOG(ERROR, TAG, "Invalid Representation given!");
throw SimulatorException(SIMULATOR_ERROR, "Invalid representation detected!");
}
std::lock_guard<std::mutex> lock(m_statusLock);
if (m_status)
{
- OC_LOG(ERROR, TAG, "Operation already in progress !");
+ OIC_LOG(ERROR, TAG, "Operation already in progress !");
throw OperationInProgressException("Another PUT request generation session is already in progress!");
}
void PUTRequestGenerator::SendAllRequests()
{
- OC_LOG(DEBUG, TAG, "Sending OP_START event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_START event");
m_callback(m_id, OP_START);
// Create attribute combination generator for generating resource model
if (!attributes.size())
{
- OC_LOG(ERROR, TAG, "Zero attribute found from resource model!");
+ OIC_LOG(ERROR, TAG, "Zero attribute found from resource model!");
return;
}
void PUTRequestGenerator::onResponseReceived(SimulatorResult result,
SimulatorResourceModelSP repModel)
{
- OC_LOG_V(INFO, TAG, "Response recieved result:%d", result);
+ OIC_LOG_V(INFO, TAG, "Response recieved result:%d", result);
m_responseCnt++;
completed();
}
{
if (m_stopRequested)
{
- OC_LOG(DEBUG, TAG, "Sending OP_ABORT event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_ABORT event");
m_callback(m_id, OP_ABORT);
}
else
{
- OC_LOG(DEBUG, TAG, "Sending OP_COMPLETE event");
+ OIC_LOG(DEBUG, TAG, "Sending OP_COMPLETE event");
m_callback(m_id, OP_COMPLETE);
}
}
-}
\ No newline at end of file
+}
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, requestId));
if (OC_STACK_OK != ocResult)
{
- OC_LOG_V(ERROR, TAG, "Sending request failed [errorcode: %d]", ocResult);
+ OIC_LOG_V(ERROR, TAG, "Sending request failed [errorcode: %d]", ocResult);
m_requestList.remove(requestId);
throw SimulatorException(static_cast<SimulatorResult>(ocResult), "Failed to send request!");
}
if (!m_getRequestSender)
{
- OC_LOG(ERROR, TAG, "Invalid GET request sender!");
+ OIC_LOG(ERROR, TAG, "Invalid GET request sender!");
throw NoSupportException("Can not send GET request on this resource!");
}
if (!m_getRequestSender)
{
- OC_LOG(ERROR, TAG, "Invalid GET request sender !");
+ OIC_LOG(ERROR, TAG, "Invalid GET request sender !");
throw NoSupportException("Can not send GET request on this resource!");
}
if (!m_putRequestSender)
{
- OC_LOG(ERROR, TAG, "Invalid PUT request sender !");
+ OIC_LOG(ERROR, TAG, "Invalid PUT request sender !");
throw NoSupportException("Can not send PUT request on this resource!");
}
if (!m_putRequestSender)
{
- OC_LOG(ERROR, TAG, "Invalid PUT request sender !");
+ OIC_LOG(ERROR, TAG, "Invalid PUT request sender !");
throw NoSupportException("Can not send PUT request on this resource!");
}
if (!m_postRequestSender)
{
- OC_LOG(ERROR, TAG, "Invalid POST request sender !");
+ OIC_LOG(ERROR, TAG, "Invalid POST request sender !");
throw NoSupportException("Can not send POST request on this resource!");
}
if (!m_postRequestSender)
{
- OC_LOG(ERROR, TAG, "Invalid POST request sender !");
+ OIC_LOG(ERROR, TAG, "Invalid POST request sender !");
throw NoSupportException("Can not send POST request on this resource!");
}
if (!m_autoRequestGenMngr)
{
- OC_LOG(ERROR, TAG, "Invalid auto request generation manager !");
+ OIC_LOG(ERROR, TAG, "Invalid auto request generation manager !");
throw NoSupportException("Resource is not configured with RAML!");
}
{
if (id < 0)
{
- OC_LOG(ERROR, TAG, "Invalid session id!");
+ OIC_LOG(ERROR, TAG, "Invalid session id!");
throw InvalidArgsException(SIMULATOR_INVALID_PARAM, "Invalid ID!");
}
if (!m_autoRequestGenMngr)
{
- OC_LOG(ERROR, TAG, "Invalid auto request generation manager !");
+ OIC_LOG(ERROR, TAG, "Invalid auto request generation manager !");
throw NoSupportException("Resource is not configured with RAML!");
}
RequestModelSP RequestModelBuilder::createRequestModel(const RAML::ActionPtr &action)
{
- OC_LOG(DEBUG, TAG, "Creating request model");
+ OIC_LOG(DEBUG, TAG, "Creating request model");
// Validate the action type. Only GET, PUT, POST and DELETE are supported.
RAML::ActionType actionType = action->getType();
&& actionType != RAML::ActionType::POST
&& actionType != RAML::ActionType::DELETE)
{
- OC_LOG(ERROR, TAG, "Failed to create request model as it is of unknown type!");
+ OIC_LOG(ERROR, TAG, "Failed to create request model as it is of unknown type!");
return nullptr;
}
{
if (key.empty())
{
- OC_LOG(ERROR, TAG, "key is empty!");
+ OIC_LOG(ERROR, TAG, "key is empty!");
return false;
}
{
if (false == m_resource->updateAttributeValue(attribute))
{
- OC_LOG_V(ERROR, ATAG, "Failed to update the attribute![%s]", attribute.getName().c_str());
+ OIC_LOG_V(ERROR, ATAG, "Failed to update the attribute![%s]", attribute.getName().c_str());
continue;
}
resourceImpl->notifyApp();
if (!m_stopRequested)
{
- OC_LOG_V(DEBUG, ATAG, "Attribute:%s automation is completed!", m_attrName.c_str());
+ OIC_LOG_V(DEBUG, ATAG, "Attribute:%s automation is completed!", m_attrName.c_str());
SIM_LOG(ILogger::INFO, "Automation of " << m_attrName << " attribute is completed.");
}
if (0 == attributes.size())
{
- OC_LOG(ERROR, RTAG, "Resource has zero attributes!");
+ OIC_LOG(ERROR, RTAG, "Resource has zero attributes!");
throw SimulatorException(SIMULATOR_ERROR, "Resource has zero attributes!");
}
{
if (!callback)
{
- OC_LOG(ERROR, TAG, "Invalid callback!");
+ OIC_LOG(ERROR, TAG, "Invalid callback!");
throw InvalidArgsException(SIMULATOR_INVALID_CALLBACK, "Invalid callback!");
}
std::lock_guard<std::mutex> lock(m_lock);
resourceAutomation->start();
- OC_LOG_V(DEBUG, TAG, "Resource automation successfully started [id: %d]", m_id);
+ OIC_LOG_V(DEBUG, TAG, "Resource automation successfully started [id: %d]", m_id);
SIM_LOG(ILogger::INFO, "Resource automation successfully started [ id: " << m_id << " ]");
m_resourceUpdationList[m_id] = resourceAutomation;
{
if (!callback)
{
- OC_LOG(ERROR, TAG, "Invalid callback!");
+ OIC_LOG(ERROR, TAG, "Invalid callback!");
throw InvalidArgsException(SIMULATOR_INVALID_CALLBACK, "Invalid callback!");
}
SimulatorResourceModel::Attribute attribute;
if (false == resource->getAttribute(attrName, attribute))
{
- OC_LOG_V(ERROR, TAG, "Attribute:%s not present in resource!", attrName.c_str());
+ OIC_LOG_V(ERROR, TAG, "Attribute:%s not present in resource!", attrName.c_str());
throw SimulatorException(SIMULATOR_ERROR, "Attribute is not present in resource!");
}
std::lock_guard<std::mutex> lock(m_lock);
attributeAutomation->start();
- OC_LOG_V(DEBUG, TAG, "Attribute automation successfully started [name: %s, id: %d]",
+ OIC_LOG_V(DEBUG, TAG, "Attribute automation successfully started [name: %s, id: %d]",
attrName.c_str(), m_id);
SIM_LOG(ILogger::INFO, "Automation for " << attrName << " attribute has successfully started [ id: "
<<
if (0 == raml->getResources().size()\r
|| nullptr == (ramlResource = raml->getResources().begin()->second))\r
{\r
- OC_LOG(ERROR, TAG, "Zero resources detected from RAML!");\r
+ OIC_LOG(ERROR, TAG, "Zero resources detected from RAML!");\r
return nullptr;\r
}\r
\r
if (0 == raml->getResources().size()\r
|| nullptr == (ramlResource = raml->getResources().begin()->second))\r
{\r
- OC_LOG(ERROR, TAG, "Zero resources detected from RAML!");\r
+ OIC_LOG(ERROR, TAG, "Zero resources detected from RAML!");\r
return resources;\r
}\r
\r
std::shared_ptr<SimulatorResource> resource = buildResource(ramlResource);\r
if (!resource)\r
{\r
- OC_LOG(ERROR, TAG, "Failed to create resource!");\r
+ OIC_LOG(ERROR, TAG, "Failed to create resource!");\r
return resources;\r
}\r
\r
RAML::ActionPtr action = ramlResource->getAction(type);\r
if (!action)\r
{\r
- OC_LOG(ERROR, TAG, "Resource does not possess the request!");\r
+ OIC_LOG(ERROR, TAG, "Resource does not possess the request!");\r
return nullptr;\r
}\r
\r
RAML::ResponsePtr response = action->getResponse(responseCode);\r
if (!response)\r
{\r
- OC_LOG(ERROR, TAG, "Resource does not provide valid GET response!");\r
+ OIC_LOG(ERROR, TAG, "Resource does not provide valid GET response!");\r
return nullptr;\r
}\r
\r
RAML::RequestResponseBodyPtr responseBody = response->getResponseBody("application/json");\r
if (!responseBody)\r
{\r
- OC_LOG(ERROR, TAG, "GET response is not of type \"application/json\" ");\r
+ OIC_LOG(ERROR, TAG, "GET response is not of type \"application/json\" ");\r
return nullptr;\r
}\r
\r