2012-02-20 07:15:19 -08:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-20 20:21:24 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-02-20 07:15:19 -08:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_bluetooth_bluetoothcommon_h__
|
|
|
|
#define mozilla_dom_bluetooth_bluetoothcommon_h__
|
|
|
|
|
2012-06-02 11:23:16 -07:00
|
|
|
#include "mozilla/Observer.h"
|
2012-09-13 09:37:14 -07:00
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsTArray.h"
|
2012-06-02 11:23:16 -07:00
|
|
|
|
2013-01-29 02:37:51 -08:00
|
|
|
extern bool gBluetoothDebugFlag;
|
|
|
|
|
|
|
|
#define SWITCH_BT_DEBUG(V) (gBluetoothDebugFlag = V)
|
|
|
|
|
|
|
|
#undef BT_LOG
|
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
#include <android/log.h>
|
|
|
|
#define BT_LOG(args...) \
|
|
|
|
do { \
|
|
|
|
if (gBluetoothDebugFlag) { \
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
2013-01-29 02:37:51 -08:00
|
|
|
|
|
|
|
#define BT_WARNING(args...) \
|
|
|
|
__android_log_print(ANDROID_LOG_WARN, "GeckoBluetooth", args)
|
|
|
|
|
2013-01-29 02:37:51 -08:00
|
|
|
#else
|
2013-01-29 02:37:51 -08:00
|
|
|
#define BT_LOG(args, ...) \
|
2013-01-29 02:37:51 -08:00
|
|
|
do { \
|
|
|
|
if (gBluetoothDebugFlag) { \
|
2013-01-29 02:37:51 -08:00
|
|
|
printf(args, ##__VA_ARGS__); \
|
2013-01-29 02:37:51 -08:00
|
|
|
} \
|
|
|
|
} while(0)
|
2013-01-29 02:37:51 -08:00
|
|
|
|
|
|
|
#define BT_WARNING(args, ...) printf(args, ##__VA_ARGS__)
|
2013-01-29 02:37:51 -08:00
|
|
|
#endif
|
|
|
|
|
2012-02-20 07:15:19 -08:00
|
|
|
#define BEGIN_BLUETOOTH_NAMESPACE \
|
|
|
|
namespace mozilla { namespace dom { namespace bluetooth {
|
|
|
|
#define END_BLUETOOTH_NAMESPACE \
|
|
|
|
} /* namespace bluetooth */ } /* namespace dom */ } /* namespace mozilla */
|
|
|
|
#define USING_BLUETOOTH_NAMESPACE \
|
|
|
|
using namespace mozilla::dom::bluetooth;
|
|
|
|
|
2012-08-17 03:35:59 -07:00
|
|
|
#define LOCAL_AGENT_PATH "/B2G/bluetooth/agent"
|
|
|
|
#define REMOTE_AGENT_PATH "/B2G/bluetooth/remote_device_agent"
|
|
|
|
|
|
|
|
// Bluetooth address format: xx:xx:xx:xx:xx:xx (or xx_xx_xx_xx_xx_xx)
|
|
|
|
#define BLUETOOTH_ADDRESS_LENGTH 17
|
|
|
|
|
2012-06-02 11:23:16 -07:00
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
2012-09-05 20:06:20 -07:00
|
|
|
enum BluetoothSocketType {
|
|
|
|
RFCOMM = 1,
|
|
|
|
SCO = 2,
|
|
|
|
L2CAP = 3
|
|
|
|
};
|
|
|
|
|
2012-07-17 20:41:54 -07:00
|
|
|
class BluetoothSignal;
|
|
|
|
typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver;
|
2012-06-02 11:23:16 -07:00
|
|
|
|
2012-07-31 21:49:59 -07:00
|
|
|
// Enums for object types, currently used for shared function lookups
|
|
|
|
// (get/setproperty, etc...). Possibly discernable via dbus paths, but this
|
|
|
|
// method is future-proofed for platform independence.
|
|
|
|
enum BluetoothObjectType {
|
|
|
|
TYPE_MANAGER = 0,
|
|
|
|
TYPE_ADAPTER = 1,
|
2012-09-13 09:37:14 -07:00
|
|
|
TYPE_DEVICE = 2,
|
|
|
|
|
|
|
|
TYPE_INVALID
|
2012-07-31 21:49:59 -07:00
|
|
|
};
|
|
|
|
|
2012-06-02 11:23:16 -07:00
|
|
|
END_BLUETOOTH_NAMESPACE
|
2012-02-20 07:15:19 -08:00
|
|
|
|
|
|
|
#endif // mozilla_dom_bluetooth_bluetoothcommon_h__
|