#include <iostream>
#include <mutex>
+#define DO_ACTION "DoAction"
+#define GET_ACTIONSET "GetActionSet"
+#define ACTIONSET "ActionSet"
+#define DELETE_ACTIONSET "DelActionSet"
+
using namespace std;
using namespace OC;
namespace PH = std::placeholders;
}
catch (std::exception& e)
{
- std::cout << "" << std::endl;
+ std::cerr << "Exception in foundResource: "<< e.what() << std::endl;
}
}
}
}
-string buildActionSetDesc()
+string buildActionSetDesc(unsigned int delay = 0, unsigned int type = 0)
{
string actionsetDesc = "";
actionsetDesc = "allbulboff";
actionsetDesc.append("*");
+ actionsetDesc.append(std::to_string(delay)); // Set delay time.
+ actionsetDesc.append(" ");
+ actionsetDesc.append(std::to_string(type)); // Set action type.
+ actionsetDesc.append("*");
for (auto iter = lights.begin(); iter != lights.end(); ++iter)
{
actionsetDesc.append("uri=").append((*iter));
int main(int argc, char* argv[])
{
ostringstream requestURI;
- requestURI << OC_WELL_KNOWN_QUERY << "?rt=a.collection";
-
- OCConnectivityType connectivityType = OC_WIFI;
-
- if(argc == 2)
- {
- try
- {
- std::size_t inputValLen;
- int optionSelected = stoi(argv[1], &inputValLen);
-
- if(inputValLen == strlen(argv[1]))
- {
- if(optionSelected == 0)
- {
- connectivityType = OC_ETHERNET;
- }
- else if(optionSelected == 1)
- {
- connectivityType = OC_WIFI;
- }
- else
- {
- std::cout << "Invalid connectivity type selected. Using default WIFI"
- << std::endl;
- }
- }
- else
- {
- std::cout << "Invalid connectivity type selected. Using default WIFI" << std::endl;
- }
- }
- catch(exception& e)
- {
- std::cout << "Invalid input argument. Using WIFI as connectivity type" << std::endl;
- }
- }
- else
- {
- std::cout<<"Usage: groupclient <ConnectivityType(0|1)>\n";
- std::cout<<"ConnectivityType: Default WIFI\n";
- std::cout<<"ConnectivityType 0: ETHERNET\n";
- std::cout<<"ConnectivityType 1: WIFI\n";
- }
+ requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=a.collection";
PlatformConfig config
{ OC::ServiceType::InProc, ModeType::Client, "0.0.0.0", 0, OC::QualityOfService::LowQos };
string resourceTypeName = "a.collection";
OCPlatform::findResource("", requestURI.str(),
- connectivityType, &foundResource);
+ CT_DEFAULT, &foundResource);
//Non-intensive block until foundResource callback is called by OCPlatform
//and onGet gets resource.
}
break;
case 2:
- rep.setValue("DoAction", std::string("allbulboff"));
+ rep.setValue(DO_ACTION, std::string("allbulboff"));
if (g_resource)
{
g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),
}
break;
case 3:
- rep.setValue("GetActionSet", std::string("allbulboff"));
+ rep.setValue(GET_ACTIONSET, std::string("allbulboff"));
if (g_resource)
{
g_resource->post("a.collection", GROUP_INTERFACE, rep, QueryParamsMap(),