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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
25 using namespace OIC::Service;
31 HueLight::HueLight(HueConnector* connector, std::string address){
33 m_connector = connector;
37 HueLight::~HueLight(){
41 string HueLight::getAttribute(string attributeName){
45 void HueLight::initAttributes(){
46 BundleResource::setAttribute("on-off", "false");
47 BundleResource::setAttribute("dim", "0");
48 BundleResource::setAttribute("color", "0");
49 /*m_mapAttributes.insert(std::pair<string, string>("on-off", "false"));
50 m_mapAttributes.insert(std::pair<string, string>("dim", "0"));
51 m_mapAttributes.insert(std::pair<string, string>("color", "0"));*/
54 void HueLight::setAttribute(string attributeName, string value){
55 cout << "HueLight::setAttribute setting " << attributeName << " to " << value << std::endl;
58 if(attributeName == "on-off"){
59 m_connector->transmit(this->m_address + "/state", "{\"on\":" + value + "}");
62 if(attributeName == "dim"){
63 //m_connector->transmit(this->m_address + "/state", "{\"bri\":" + (value * 2.5) + "}");
64 m_connector->transmit(this->m_address + "/state", "{\"bri\":" + value + "}");
67 if(attributeName == "color"){
68 //m_connector->transmit(this->m_address+ "/state", "{\"hue\":" + (value * 650) + "}");
69 m_connector->transmit(this->m_address+ "/state", "{\"hue\":" + value + "}");