17927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach/******************************************************************************
27927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *
37927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  Copyright (C) 2015 Google, Inc.
47927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *
57927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  Licensed under the Apache License, Version 2.0 (the "License");
67927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  you may not use this file except in compliance with the License.
77927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  You may obtain a copy of the License at:
87927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *
97927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  http://www.apache.org/licenses/LICENSE-2.0
107927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *
117927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  Unless required by applicable law or agreed to in writing, software
127927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  distributed under the License is distributed on an "AS IS" BASIS,
137927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
147927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  See the License for the specific language governing permissions and
157927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *  limitations under the License.
167927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach *
177927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach ******************************************************************************/
187927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach
197927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach#pragma once
207927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach
217927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach#include <stdbool.h>
227927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach
237927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach#include "btcore/include/bdaddr.h"
247927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach
25a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbachstatic const char INTEROP_MODULE[] = "interop_module";
26a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach
2795673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// NOTE:
2895673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// Only add values at the end of this enum and do NOT delete values
2995673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// as they may be used in dynamic device configuration.
307927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbachtypedef enum {
317927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach  // Disable secure connections
327927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach  // This is for pre BT 4.1/2 devices that do not handle secure mode
337927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach  // very well.
34a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach  INTEROP_DISABLE_LE_SECURE_CONNECTIONS = 0,
3527c4e634cb0d6e618bc3e53da7c0f9a305d1593bAndre Eisenbach
3627c4e634cb0d6e618bc3e53da7c0f9a305d1593bAndre Eisenbach  // Some devices have proven problematic during the pairing process, often
3727c4e634cb0d6e618bc3e53da7c0f9a305d1593bAndre Eisenbach  // requiring multiple retries to complete pairing. To avoid degrading the user
3827c4e634cb0d6e618bc3e53da7c0f9a305d1593bAndre Eisenbach  // experience for those devices, automatically re-try pairing if page
3927c4e634cb0d6e618bc3e53da7c0f9a305d1593bAndre Eisenbach  // timeouts are received during pairing.
40d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach  INTEROP_AUTO_RETRY_PAIRING,
41d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach
42d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach  // Devices requiring this workaround do not handle Bluetooth Absolute Volume
43d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach  // control correctly, leading to undesirable (potentially harmful) volume levels
44d0aa6cc53abaf122a2426c20691ccfa025ca7369Andre Eisenbach  // or general lack of controlability.
4595673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  INTEROP_DISABLE_ABSOLUTE_VOLUME,
4695673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach
4795673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // Disable automatic pairing with headsets/car-kits
4895673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // Some car kits do not react kindly to a failed pairing attempt and
4995673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // do not allow immediate re-pairing. Blacklist these so that the initial
5095673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // pairing attempt makes it to the user instead.
5195673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  INTEROP_DISABLE_AUTO_PAIRING,
5295673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach
5395673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // Use a fixed pin for specific keyboards
5495673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // Keyboards should use a variable pin at all times. However, some keyboards
5595673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // require a fixed pin of all 0000. This workaround enables auto pairing for
5695673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach  // those keyboards.
572ef994a0abccc556de97c22d517001801f344046Sharvil Nanavati  INTEROP_KEYBOARD_REQUIRES_FIXED_PIN,
582ef994a0abccc556de97c22d517001801f344046Sharvil Nanavati
5926bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  // Some headsets have audio jitter issues because of increased re-transmissions as the
6026bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  // 3 Mbps packets have a lower link margin, and are more prone to interference. We can
6126bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  // disable 3DH packets (use only 2DH packets) for the ACL link to improve sensitivity
6226bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  // when streaming A2DP audio to the headset. Air sniffer logs show reduced
6326bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  // re-transmissions after switching to 2DH packets.
6426bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  //
6526bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  // Disable 3Mbps packets and use only 2Mbps packets for ACL links when streaming audio.
6626bb30842b6c64821c2a6c4a515f290140017105Sathya Kumar  INTEROP_2MBPS_LINK_ONLY
677927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach} interop_feature_t;
687927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach
697927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach// Check if a given |addr| matches a known interoperability workaround as identified
707927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach// by the |interop_feature_t| enum. This API is used for simple address based lookups
717927f68bb2d9b963288261e1e858463b43c52a2dAndre Eisenbach// where more information is not available. No look-ups or random address resolution
72a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach// are performed on |addr|.
7395673843582fccf026d8af7592428f9b864f52fdAndre Eisenbachbool interop_match_addr(const interop_feature_t feature, const bt_bdaddr_t *addr);
7495673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach
7595673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// Check if a given remote device |name| matches a known interoperability workaround.
7695673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// Name comparisons are case sensitive and do not allow for partial matches. As in, if
7795673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// |name| is "TEST" and a workaround exists for "TESTING", then this function will
7895673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// return false. But, if |name| is "TESTING" and a workaround exists for "TEST", this
7995673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// function will return true.
8095673843582fccf026d8af7592428f9b864f52fdAndre Eisenbach// |name| cannot be null and must be null terminated.
8195673843582fccf026d8af7592428f9b864f52fdAndre Eisenbachbool interop_match_name(const interop_feature_t feature, const char *name);
82a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach
83a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach// Add a dynamic interop database entry for a device matching the first |length| bytes
84a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach// of |addr|, implementing the workaround identified by |feature|. |addr| may not be
85a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach// null and |length| must be greater than 0 and less than sizeof(bt_bdaddr_t).
86dc0b89cc7f7a8685045d4ebec4a948385d42777fAndre Eisenbach// As |interop_feature_t| is not exposed in the public API, feature must be a valid
87dc0b89cc7f7a8685045d4ebec4a948385d42777fAndre Eisenbach// integer representing an optoin in the enum.
88dc0b89cc7f7a8685045d4ebec4a948385d42777fAndre Eisenbachvoid interop_database_add(const uint16_t feature, const bt_bdaddr_t *addr, size_t length);
89a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach
90a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbach// Clear the dynamic portion of the interoperability workaround database.
91a0c02f62a49c4ae9de5789731cdbb99b686a938dAndre Eisenbachvoid interop_database_clear(void);
92