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.
17 #ifndef __TIZEN_JS_BLUETOOTH_LOW_ENERGY_GATT_CHARACTERISTIC_H__
18 #define __TIZEN_JS_BLUETOOTH_LOW_ENERGY_GATT_CHARACTERISTIC_H__
20 #include <bluetooth.h>
22 #include "BluetoothGATTBase.h"
23 #include "BluetoothGattClientWrapper.h"
26 #include <PropertyBag.h>
27 #include <JavaScriptCore/JavaScript.h>
31 class MultiCallbackUserData;
36 class BluetoothGATTCharacteristic : public BluetoothGATTBase {
38 BluetoothGATTCharacteristic(const BluetoothGattClientWrapper &wrapper,
39 bt_gatt_h _handler, JSContextRef context);
40 JSValueRef getIsBroadCast(JSContextRef context);
41 JSValueRef getIsHasExtended(JSContextRef context);
42 JSValueRef getIsNotify(JSContextRef context);
43 JSValueRef getIsIndie(JSContextRef context);
44 JSValueRef getIsRead(JSContextRef context);
45 JSValueRef getIsSignedWrite(JSContextRef context);
46 JSValueRef getIsWrite(JSContextRef context);
47 JSValueRef getIsWriteNoResponse(JSContextRef context);
48 JSValueRef getDescriptors(JSContextRef context);
50 long addValueChangeListener(std::shared_ptr<Common::MultiCallbackUserData> _pCallback);
51 void removeValueChangeListener(long _id);
53 virtual ~BluetoothGATTCharacteristic();
55 BluetoothGattClientWrapper m_wrapper;
56 Common::PropertyBag m_localProperty;
57 void setProperty( int _propertyBits, const char* _propertyName,
58 bt_gatt_property_e _property, JSContextRef _ctx);
60 static bool descriptorsNativeCallback(int total, int index, bt_gatt_h gatt_handle,
62 static void onCharacteristicChangeNativeCallback(bt_gatt_h characteristic,
63 char *value, int len, void *user_data);
65 std::vector<BluetoothGATTBasePtr> m_descriptors;
66 std::map<int, std::shared_ptr<Common::MultiCallbackUserData>> m_pCallbacks;
68 static int m_listenerId;
71 typedef std::shared_ptr<BluetoothGATTCharacteristic> BluetoothGATTCharacteristicPtr;
73 } // namespace Bluetooth
74 } // namespace DeviceAPI
76 #endif /* SRC_BLUETOOTH_BLUETOOTHGATTCHARACTERISTC_H_ */