コード例 #1
0
USING_BLUETOOTH_NAMESPACE

#define BT_LOGR_PROFILE(mgr, args...)                 \
  do {                                                \
    nsCString name;                                   \
    mgr->GetName(name);                               \
    BT_LOGR("%s: [%s] %s", __FUNCTION__, name.get(),  \
      nsPrintfCString(args).get());                   \
  } while(0)

BluetoothProfileController::BluetoothProfileController(
    bool aConnect,
    const nsAString& aDeviceAddress,
    BluetoothReplyRunnable* aRunnable,
    BluetoothProfileControllerCallback aCallback,
    uint16_t aServiceUuid,
    uint32_t aCod)
    : mConnect(aConnect)
    , mDeviceAddress(aDeviceAddress)
    , mRunnable(aRunnable)
    , mCallback(aCallback)
    , mSuccess(false)
    , mProfilesIndex(-1)
{
    MOZ_ASSERT(!aDeviceAddress.IsEmpty());
    MOZ_ASSERT(aRunnable);
    MOZ_ASSERT(aCallback);

    mProfiles.Clear();

    /**
     * If the service uuid is not specified, either connect multiple profiles
     * based on Cod, or disconnect all connected profiles.
     */
    if (!aServiceUuid) {
        mTarget.cod = aCod;
        SetupProfiles(false);
    } else {
        BluetoothServiceClass serviceClass =
            BluetoothUuidHelper::GetBluetoothServiceClass(aServiceUuid);
        mTarget.service = serviceClass;
        SetupProfiles(true);
    }
}
コード例 #2
0
BluetoothProfileController::BluetoothProfileController(
                                   bool aConnect,
                                   const nsAString& aDeviceAddress,
                                   BluetoothReplyRunnable* aRunnable,
                                   BluetoothProfileControllerCallback aCallback,
                                   uint16_t aServiceUuid,
                                   uint32_t aCod)
  : mConnect(aConnect)
  , mDeviceAddress(aDeviceAddress)
  , mRunnable(aRunnable)
  , mCallback(aCallback)
  , mCurrentProfileFinished(false)
  , mSuccess(false)
  , mProfilesIndex(-1)
{
  MOZ_ASSERT(!aDeviceAddress.IsEmpty());
  MOZ_ASSERT(aRunnable);
  MOZ_ASSERT(aCallback);

  mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
  MOZ_ASSERT(mTimer);

  mProfiles.Clear();

  /**
   * If the service uuid is not specified, either connect multiple profiles
   * based on Cod, or disconnect all connected profiles.
   */
  if (!aServiceUuid) {
    mTarget.cod = aCod;
    SetupProfiles(false);
  } else {
    BluetoothServiceClass serviceClass =
      BluetoothUuidHelper::GetBluetoothServiceClass(aServiceUuid);
    mTarget.service = serviceClass;
    SetupProfiles(true);
  }
}