*
*/
-#include "GroupManager.h"
#include <algorithm>
#include <thread>
#include <unistd.h>
-
#include <string.h>
+#include "GroupManager.h"
+
#define PLAIN_DELIMITER "\""
#define ACTION_DELIMITER "*"
#define DESC_DELIMITER "|"
{
// std::cout << "resourceTypes : " << resourceTypes.at(i) << std::endl;
- std::string query = OC_MULTICAST_DISCOVERY_URI;
+ std::string query = OC_RSRVD_WELL_KNOWN_URI;
query.append("?rt=");
query.append(resourceTypes.at(i));
OCPlatform::findResource("",
query,
- OC_ALL,
+ CT_DEFAULT,
std::function < void(std::shared_ptr < OCResource > resource)
> (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
waitsec)));
// Callback to presence
void GroupManager::collectionPresenceHandler(OCStackResult result, const unsigned int nonce,
- const std::string& hostAddress, std::string host, std::string uri)
+ const std::string& /*hostAddress*/, std::string host, std::string uri)
{
std::cout << "uri : " << uri << std::endl;
std::cout << "host : " << host << std::endl;
result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
// resourceType,
resourceTypes.front(),
- OC_ALL,
+ CT_DEFAULT,
std::function<
void(OCStackResult result, const unsigned int nonce,
const std::string& hostAddress) >(
}
}
-void GroupManager::onGetForPresence(const HeaderOptions& headerOptions,
+void GroupManager::onGetForPresence(const HeaderOptions& /*headerOptions*/,
const OCRepresentation& rep, const int eCode, CollectionPresenceCallback callback)
{
if (eCode == OC_STACK_OK)
char *plainPtr = NULL;
char *attr = NULL, *desc = NULL;
+ Action *action = NULL;
Capability *capa = NULL;
ActionSet *actionset = new ActionSet();
if (desc != NULL)
{
- Action *action = NULL;
strcpy(desc, token);
token = strtok_r(desc, DESC_DELIMITER, &descPtr);
token = strtok_r(attr, ATTR_DELIMITER, &attrPtr);
while (token != NULL)
{
- if (strcmp(token, "uri") == 0)
+ if ( (action == NULL) && strcmp(token, "uri") == 0) //consider only first "uri" as uri, other as attribute.
{
token = strtok_r(NULL, ATTR_DELIMITER, &attrPtr);
if(token == NULL)
}
if( action != NULL )
+ {
actionset->listOfAction.push_back(action);
+ action = NULL;
+ }
else
goto exit;
//delete action;
token = strtok_r(NULL, ACTION_DELIMITER, &plainPtr);
}
- DELETE(plainText);
+ DELETEARRAY(plainText);
return actionset;
exit:
+ DELETE(action);
DELETE(capa)
DELETE(actionset)
DELETEARRAY(attr);