1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
26 using namespace OIC::Service;
30 m_connector = nullptr;
33 HueLight::HueLight(HueConnector *connector, std::string address)
36 m_connector = connector;
42 m_connector = nullptr;
45 void HueLight::initAttributes()
47 BundleResource::setAttribute("on-off", false, false);
48 BundleResource::setAttribute("dim", 0, false);
49 BundleResource::setAttribute("color", 0, false);
52 RCSResourceAttributes HueLight::handleGetAttributesRequest()
54 cout << "HueLight::handleGetAttributesRequest" << endl;
55 // TODO read from HueLight and update attribute data
56 return BundleResource::getAttributes();
59 void HueLight::handleSetAttributesRequest(const RCSResourceAttributes &value)
61 cout << "HueLight::handleSetAttributesRequest" << std::endl;
63 // TODO construct single write
65 for (RCSResourceAttributes::const_iterator it = value.begin(); it != value.end(); it++)
67 std::string attributeName = it->key();
68 RCSResourceAttributes::Value attrValue = it->value();
70 if (attributeName == "on-off")
72 //m_connector->transmit(this->m_address + "/state", "{\"on\":" + attrValue.toString() + "}");
75 if (attributeName == "dim")
77 // needs conversion * 2.5
78 //m_connector->transmit(this->m_address + "/state", "{\"bri\":" + attrValue.toString() + "}");
81 if (attributeName == "color")
83 // needs conversion *650
84 //m_connector->transmit(this->m_address + "/state", "{\"hue\":" + attrValue.toString() + "}");
88 BundleResource::setAttributes(value);