2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include "BluetoothLEAdvertiseData.h"
21 #include "plugin_config_impl.h"
26 BluetoothLEAdvertiseData::BluetoothLEAdvertiseData() : m_includeName(false), m_includeTxPowerLevel(false) {
27 // TODO Auto-generated constructor stub
28 m_serviceData = new BluetoothLEServiceData();
29 m_manufacturerData = new BluetoothLEManufacturerData();
32 BluetoothLEAdvertiseData::~BluetoothLEAdvertiseData() {
33 // TODO Auto-generated destructor stub
36 void BluetoothLEAdvertiseData::setName(const bool includeName)
38 m_includeName = includeName;
41 bool BluetoothLEAdvertiseData::getName() const
46 void BluetoothLEAdvertiseData::setServiceUuids(
47 const std::vector<std::string> &uuids)
52 std::vector<std::string> BluetoothLEAdvertiseData::getServiceUuids() const
57 void BluetoothLEAdvertiseData::setSolicitationUuids(
58 const std::vector<std::string> &solicitationeuuids)
60 m_solicitationeuuids = solicitationeuuids;
63 std::vector<std::string> BluetoothLEAdvertiseData::getSolicitationUuids() const
65 return m_solicitationeuuids;
68 void BluetoothLEAdvertiseData::setAppearance(const unsigned long appearance)
70 m_appearance = appearance;
73 unsigned long BluetoothLEAdvertiseData::getAppearance() const
78 void BluetoothLEAdvertiseData::setTxPowerLevel(const bool includeTxPowerLevel)
80 m_includeTxPowerLevel = includeTxPowerLevel;
83 bool BluetoothLEAdvertiseData::getTxPowerLevel() const
85 return m_includeTxPowerLevel;
88 BluetoothLEServiceData* BluetoothLEAdvertiseData::getServiceData() const
93 void BluetoothLEAdvertiseData::setServiceData(BluetoothLEServiceData* serviceData)
95 m_serviceData = serviceData;
98 JSValueRef BluetoothLEAdvertiseData::getServiceDataJSValueRef(JSContextRef ctx) const {
100 JSObjectRef jsobject = JSObjectMake(ctx, NULL, NULL );
101 if (!m_serviceData) {
102 LOGD("m_serviceData is null");
105 Common::JSUtil::setProperty(ctx , jsobject, BLUETOOTH_LE_SERVICE_DATA_UUID,
106 Common::JSUtil::toJSValueRef(ctx, m_serviceData->getUuid()), kJSPropertyAttributeNone, NULL);
107 Common::JSUtil::setProperty(ctx , jsobject, BLUETOOTH_LE_SERVICE_DATA_DATA,
108 Common::JSUtil::toJSValueRef(ctx, m_serviceData->getData()), kJSPropertyAttributeNone, NULL);
112 void BluetoothLEAdvertiseData::setManufacturerData(BluetoothLEManufacturerData* manufacturerData)
114 m_manufacturerData = manufacturerData;
117 BluetoothLEManufacturerData* BluetoothLEAdvertiseData::getManufacturerData() const
119 return m_manufacturerData;
122 JSValueRef BluetoothLEAdvertiseData::getManufacturerJSValueRef(JSContextRef ctx) const {
124 JSObjectRef jsobject = JSObjectMake(ctx, NULL, NULL );
125 if (!m_manufacturerData) {
126 LOGD("m_manufacturerData is null");
129 Common::JSUtil::setProperty(ctx , jsobject, BLUETOOTH_LE_MANUFACTURER_DATA_ID,
130 Common::JSUtil::toJSValueRef(ctx, m_manufacturerData->getId()), kJSPropertyAttributeNone, NULL);
131 Common::JSUtil::setProperty(ctx , jsobject, BLUETOOTH_LE_MANUFACTURER_DATA_DATA,
132 Common::JSUtil::toJSValueRef(ctx, m_manufacturerData->getData()), kJSPropertyAttributeNone, NULL);
136 void BluetoothLEAdvertiseData::setAppearanceNull(bool value) {
137 m_appearance_null = value;
140 bool BluetoothLEAdvertiseData::getAppearanceNull() {
141 return m_appearance_null;
144 void BluetoothLEAdvertiseData::setUuidsNull(bool value) {
145 m_uuids_null = value;
148 bool BluetoothLEAdvertiseData::getUuidsNull() {
152 void BluetoothLEAdvertiseData::setSolicitationUuidsNull(bool value) {
153 m_solicitationuuids_null = value;
156 bool BluetoothLEAdvertiseData::getSolicitationUuidsNull() {
157 return m_solicitationuuids_null;
160 void BluetoothLEAdvertiseData::setServiceDataNull(bool value) {
161 m_serviceData_null = value;
164 bool BluetoothLEAdvertiseData::getServiceDataNull() {
165 return m_serviceData_null;
168 void BluetoothLEAdvertiseData::setManufacturerDataNull(bool value) {
169 m_manufacturerData_null = value;
172 bool BluetoothLEAdvertiseData::getManufacturerDataNull() {
173 return m_manufacturerData_null;
176 } // namespace Bluetooth
177 } // namespace DeviceAPI