2012-02-20 19:15:19 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-21 07:21:24 +04:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-02-20 19:15:19 +04: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 22:23:16 +04:00
|
|
|
#include "mozilla/Observer.h"
|
2012-09-13 20:37:14 +04:00
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsTArray.h"
|
2012-06-02 22:23:16 +04:00
|
|
|
|
2013-01-29 14:37:51 +04: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 14:37:51 +04:00
|
|
|
|
|
|
|
#define BT_WARNING(args...) \
|
|
|
|
__android_log_print(ANDROID_LOG_WARN, "GeckoBluetooth", args)
|
|
|
|
|
2013-01-29 14:37:51 +04:00
|
|
|
#else
|
2013-01-29 14:37:51 +04:00
|
|
|
#define BT_LOG(args, ...) \
|
2013-01-29 14:37:51 +04:00
|
|
|
do { \
|
|
|
|
if (gBluetoothDebugFlag) { \
|
2013-01-29 14:37:51 +04:00
|
|
|
printf(args, ##__VA_ARGS__); \
|
2013-01-29 14:37:51 +04:00
|
|
|
} \
|
|
|
|
} while(0)
|
2013-01-29 14:37:51 +04:00
|
|
|
|
|
|
|
#define BT_WARNING(args, ...) printf(args, ##__VA_ARGS__)
|
2013-01-29 14:37:51 +04:00
|
|
|
#endif
|
|
|
|
|
2012-02-20 19:15:19 +04: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;
|
|
|
|
|
2013-03-15 11:15:47 +04:00
|
|
|
#define KEY_LOCAL_AGENT "/B2G/bluetooth/agent"
|
|
|
|
#define KEY_REMOTE_AGENT "/B2G/bluetooth/remote_device_agent"
|
|
|
|
#define KEY_MANAGER "/B2G/bluetooth/manager"
|
|
|
|
#define KEY_ADAPTER "/B2G/bluetooth/adapter"
|
2012-08-17 14:35:59 +04:00
|
|
|
|
2013-06-08 19:26:28 +04:00
|
|
|
/**
|
2013-08-02 14:32:57 +04:00
|
|
|
* When the connection status of a Bluetooth profile is changed, we'll notify
|
|
|
|
* observers which register the following topics.
|
2013-06-08 19:26:28 +04:00
|
|
|
*/
|
2013-08-02 14:32:57 +04:00
|
|
|
#define BLUETOOTH_A2DP_STATUS_CHANGED_ID "bluetooth-a2dp-status-changed"
|
|
|
|
#define BLUETOOTH_HFP_STATUS_CHANGED_ID "bluetooth-hfp-status-changed"
|
2013-08-12 13:32:25 +04:00
|
|
|
#define BLUETOOTH_HID_STATUS_CHANGED_ID "bluetooth-hid-status-changed"
|
2013-08-02 14:32:57 +04:00
|
|
|
#define BLUETOOTH_SCO_STATUS_CHANGED_ID "bluetooth-sco-status-changed"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When the connection status of a Bluetooth profile is changed, we'll
|
2013-09-04 06:40:01 +04:00
|
|
|
* dispatch one of the following events.
|
2013-08-02 14:32:57 +04:00
|
|
|
*/
|
|
|
|
#define A2DP_STATUS_CHANGED_ID "a2dpstatuschanged"
|
|
|
|
#define HFP_STATUS_CHANGED_ID "hfpstatuschanged"
|
|
|
|
#define SCO_STATUS_CHANGED_ID "scostatuschanged"
|
|
|
|
|
|
|
|
/**
|
2013-09-04 06:40:01 +04:00
|
|
|
* When the pair status of a Bluetooth device is changed, we'll dispatch an
|
2013-08-02 14:32:57 +04:00
|
|
|
* event.
|
|
|
|
*/
|
|
|
|
#define PAIRED_STATUS_CHANGED_ID "pairedstatuschanged"
|
2013-06-08 19:26:28 +04:00
|
|
|
|
2013-09-04 06:40:01 +04:00
|
|
|
/**
|
|
|
|
* When receiving a query about current play status from remote device, we'll
|
|
|
|
* dispatch an event.
|
|
|
|
*/
|
|
|
|
#define REQUEST_MEDIA_PLAYSTATUS_ID "requestmediaplaystatus"
|
|
|
|
|
2012-08-17 14:35:59 +04:00
|
|
|
// Bluetooth address format: xx:xx:xx:xx:xx:xx (or xx_xx_xx_xx_xx_xx)
|
|
|
|
#define BLUETOOTH_ADDRESS_LENGTH 17
|
2013-04-05 04:52:12 +04:00
|
|
|
#define BLUETOOTH_ADDRESS_NONE "00:00:00:00:00:00"
|
2012-08-17 14:35:59 +04:00
|
|
|
|
2012-06-02 22:23:16 +04:00
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
2012-09-06 07:06:20 +04:00
|
|
|
enum BluetoothSocketType {
|
|
|
|
RFCOMM = 1,
|
2013-04-12 14:45:37 +04:00
|
|
|
SCO = 2,
|
|
|
|
L2CAP = 3,
|
|
|
|
EL2CAP = 4
|
2012-09-06 07:06:20 +04:00
|
|
|
};
|
|
|
|
|
2012-07-18 07:41:54 +04:00
|
|
|
class BluetoothSignal;
|
|
|
|
typedef mozilla::Observer<BluetoothSignal> BluetoothSignalObserver;
|
2012-06-02 22:23:16 +04:00
|
|
|
|
2012-08-01 08:49:59 +04: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 20:37:14 +04:00
|
|
|
TYPE_DEVICE = 2,
|
|
|
|
|
|
|
|
TYPE_INVALID
|
2012-08-01 08:49:59 +04:00
|
|
|
};
|
|
|
|
|
2013-07-29 13:32:34 +04:00
|
|
|
enum ControlPlayStatus {
|
|
|
|
PLAYSTATUS_STOPPED = 0x00,
|
|
|
|
PLAYSTATUS_PLAYING = 0x01,
|
|
|
|
PLAYSTATUS_PAUSED = 0x02,
|
|
|
|
PLAYSTATUS_FWD_SEEK = 0x03,
|
|
|
|
PLAYSTATUS_REV_SEEK = 0x04,
|
|
|
|
PLAYSTATUS_UNKNOWN,
|
|
|
|
PLAYSTATUS_ERROR = 0xFF,
|
|
|
|
};
|
|
|
|
|
2012-06-02 22:23:16 +04:00
|
|
|
END_BLUETOOTH_NAMESPACE
|
2012-02-20 19:15:19 +04:00
|
|
|
|
|
|
|
#endif // mozilla_dom_bluetooth_bluetoothcommon_h__
|