kits/bluetooth: Style cleanup, add additional vendors

Change-Id: I33ac709fe1dc759bf9b98fe94bd1820278ef33d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2471
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Alexander von Gluck IV
2020-04-12 19:41:57 +00:00
committed by waddlesplash
parent 01990a00e8
commit 19733b44fa
11 changed files with 1257 additions and 136 deletions
+40 -102
View File
@@ -4,13 +4,17 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "CommandManager.h"
#include "CommandManager.h"
#include <bluetooth/bluetooth_error.h>
#include <bluetooth/debug.h>
inline void* buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize,
#include "CompanyIdentifiers.h"
inline void*
buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize,
size_t* outsize)
{
CALLED();
@@ -73,7 +77,8 @@ NonParameterCommandRequest(uint8 ofg, uint8 ocf, int32* result, hci_id hId,
#endif
void* buildReset(size_t* outsize)
void*
buildReset(size_t* outsize)
{
CALLED();
return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET,
@@ -81,7 +86,8 @@ void* buildReset(size_t* outsize)
}
void* buildReadLocalName(size_t* outsize)
void*
buildReadLocalName(size_t* outsize)
{
CALLED();
return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME,
@@ -89,7 +95,8 @@ void* buildReadLocalName(size_t* outsize)
}
void* buildReadClassOfDevice(size_t* outsize)
void*
buildReadClassOfDevice(size_t* outsize)
{
CALLED();
return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV,
@@ -97,7 +104,8 @@ void* buildReadClassOfDevice(size_t* outsize)
}
void* buildReadScan(size_t* outsize)
void*
buildReadScan(size_t* outsize)
{
CALLED();
return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE,
@@ -105,7 +113,8 @@ void* buildReadScan(size_t* outsize)
}
void* buildWriteScan(uint8 scanmode, size_t* outsize)
void*
buildWriteScan(uint8 scanmode, size_t* outsize)
{
CALLED();
struct hci_write_scan_enable* param;
@@ -126,7 +135,8 @@ void* buildWriteScan(uint8 scanmode, size_t* outsize)
#endif
void* buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode,
void*
buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode,
uint16 clock_offset, size_t* outsize)
{
CALLED();
@@ -144,7 +154,8 @@ void* buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode,
}
void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
void*
buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
{
CALLED();
struct hci_cp_inquiry* param;
@@ -164,14 +175,16 @@ void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
}
void* buildInquiryCancel(size_t* outsize)
void*
buildInquiryCancel(size_t* outsize)
{
CALLED();
return buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL, NULL, 0, outsize);
}
void* buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16],
void*
buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16],
size_t* outsize)
{
CALLED();
@@ -193,7 +206,8 @@ void* buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16],
}
void* buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize)
void*
buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize)
{
CALLED();
struct hci_cp_pin_code_neg_reply* param;
@@ -211,13 +225,14 @@ void* buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize)
}
void* buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize)
void*
buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize)
{
CALLED();
struct hci_cp_accept_conn_req* param;
void* command = buildCommand(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ,
(void**) &param, sizeof(struct hci_cp_accept_conn_req), outsize);
(void**) &param, sizeof(struct hci_cp_accept_conn_req), outsize);
if (command != NULL) {
param->bdaddr = bdaddr;
@@ -228,14 +243,15 @@ void* buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize)
}
void* buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize)
void*
buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize)
{
CALLED();
struct hci_cp_reject_conn_req* param;
void* command = buildCommand(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ,
(void**)&param, sizeof(struct hci_cp_reject_conn_req),
outsize);
(void**)&param, sizeof(struct hci_cp_reject_conn_req),
outsize);
if (command != NULL) {
param->bdaddr = bdaddr;
@@ -249,7 +265,9 @@ void* buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize)
#pragma mark - INFORMATIONAL_PARAM -
#endif
void* buildReadLocalVersionInformation(size_t* outsize)
void*
buildReadLocalVersionInformation(size_t* outsize)
{
CALLED();
return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION,
@@ -257,7 +275,8 @@ void* buildReadLocalVersionInformation(size_t* outsize)
}
void* buildReadBufferSize(size_t* outsize)
void*
buildReadBufferSize(size_t* outsize)
{
CALLED();
return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE,
@@ -265,7 +284,8 @@ void* buildReadBufferSize(size_t* outsize)
}
void* buildReadBdAddr(size_t* outsize)
void*
buildReadBdAddr(size_t* outsize)
{
CALLED();
return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR,
@@ -273,88 +293,6 @@ void* buildReadBdAddr(size_t* outsize)
}
const char* bluetoothManufacturers[] = {
"Ericsson Technology Licensing",
"Nokia Mobile Phones",
"Intel Corp.",
"IBM Corp.",
"Toshiba Corp.",
"3Com",
"Microsoft",
"Lucent",
"Motorola",
"Infineon Technologies AG",
"Cambridge Silicon Radio",
"Silicon Wave",
"Digianswer A/S",
"Texas Instruments Inc.",
"Parthus Technologies Inc.",
"Broadcom Corporation",
"Mitel Semiconductor",
"Widcomm, Inc.",
"Zeevo, Inc.",
"Atmel Corporation",
"Mitsubishi Electric Corporation",
"RTX Telecom A/S",
"KC Technology Inc.",
"Newlogic",
"Transilica, Inc.",
"Rohde & Schwartz GmbH & Co. KG",
"TTPCom Limited",
"Signia Technologies, Inc.",
"Conexant Systems Inc.",
"Qualcomm",
"Inventel",
"AVM Berlin",
"BandSpeed, Inc.",
"Mansella Ltd",
"NEC Corporation",
"WavePlus Technology Co., Ltd.",
"Alcatel",
"Philips Semiconductors",
"C Technologies",
"Open Interface",
"R F Micro Devices",
"Hitachi Ltd",
"Symbol Technologies, Inc.",
"Tenovis",
"Macronix International Co. Ltd.",
"GCT Semiconductor",
"Norwood Systems",
"MewTel Technology Inc.",
"ST Microelectronics",
"Synopsys",
"Red-M (Communications) Ltd",
"Commil Ltd",
"Computer Access Technology Corporation (CATC)",
"Eclipse (HQ España) S.L.",
"Renesas Technology Corp.",
"Mobilian Corporation",
"Terax",
"Integrated System Solution Corp.",
"Matsushita Electric Industrial Co., Ltd.",
"Gennum Corporation",
"Research In Motion",
"IPextreme, Inc.",
"Systems and Chips, Inc",
"Bluetooth SIG, Inc",
"Seiko Epson Corporation",
"Integrated Silicon Solution Taiwain, Inc.",
"CONWISE Technology Corporation Ltd",
"PARROT SA",
"Socket Communications",
"Atheros Communications, Inc.",
"MediaTek, Inc.",
"Bluegiga", /* (tentative) */
"Marvell Technology Group Ltd.",
"3DSP Corporation",
"Accel Semiconductor Ltd.",
"Continental Automotive Systems",
"Apple, Inc.",
"Staccato Communications, Inc."
};
const char* linkControlCommands[] = {
"Inquiry",
"Inquiry Cancel",
File diff suppressed because it is too large Load Diff
+21 -11
View File
@@ -20,12 +20,17 @@ void
DeviceClass::GetServiceClass(BString& serviceClass)
{
CALLED();
static const char *services[] = { B_TRANSLATE_MARK("Positioning"),
B_TRANSLATE_MARK("Networking"), B_TRANSLATE_MARK("Rendering"),
B_TRANSLATE_MARK("Capturing"), B_TRANSLATE_MARK("Object transfer"),
B_TRANSLATE_MARK("Audio"), B_TRANSLATE_MARK("Telephony"),
B_TRANSLATE_MARK("Information") };
static const char *services[] = {
B_TRANSLATE_MARK("Positioning"),
B_TRANSLATE_MARK("Networking"),
B_TRANSLATE_MARK("Rendering"),
B_TRANSLATE_MARK("Capturing"),
B_TRANSLATE_MARK("Object transfer"),
B_TRANSLATE_MARK("Audio"),
B_TRANSLATE_MARK("Telephony"),
B_TRANSLATE_MARK("Information")
};
if (ServiceClass() != 0) {
bool first = true;
@@ -50,11 +55,16 @@ void
DeviceClass::GetMajorDeviceClass(BString& majorClass)
{
CALLED();
static const char *major_devices[] = { B_TRANSLATE_MARK("Miscellaneous"),
B_TRANSLATE_MARK("Computer"), B_TRANSLATE_MARK("Phone"),
B_TRANSLATE_MARK("LAN access"), B_TRANSLATE_MARK("Audio/Video"),
B_TRANSLATE_MARK("Peripheral"), B_TRANSLATE_MARK("Imaging"),
B_TRANSLATE_MARK("Uncategorized") };
static const char *major_devices[] = {
B_TRANSLATE_MARK("Miscellaneous"),
B_TRANSLATE_MARK("Computer"),
B_TRANSLATE_MARK("Phone"),
B_TRANSLATE_MARK("LAN access"),
B_TRANSLATE_MARK("Audio/Video"),
B_TRANSLATE_MARK("Peripheral"),
B_TRANSLATE_MARK("Imaging"),
B_TRANSLATE_MARK("Uncategorized")
};
if (MajorDeviceClass() >= sizeof(major_devices) / sizeof(*major_devices))
majorClass << B_TRANSLATE("Invalid device class!\n");
+12 -6
View File
@@ -3,6 +3,7 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <bluetooth/bluetooth_error.h>
#include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/DiscoveryListener.h>
@@ -18,6 +19,7 @@
#include "KitSupport.h"
namespace Bluetooth {
@@ -42,7 +44,8 @@ DiscoveryAgent::StartInquiry(int accessCode, DiscoveryListener* listener)
status_t
DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs)
DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener,
bigtime_t secs)
{
CALLED();
size_t size;
@@ -68,12 +71,14 @@ DiscoveryAgent::StartInquiry(uint32 accessCode, DiscoveryListener* listener, big
request.AddInt32("hci_id", fLocalDevice->ID());
startInquiryCommand = buildInquiry(accessCode, secs, BT_MAX_RESPONSES, &size);
startInquiryCommand = buildInquiry(accessCode, secs, BT_MAX_RESPONSES,
&size);
// For stating the inquiry
request.AddData("raw command", B_ANY_TYPE, startInquiryCommand, size);
request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY));
request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
request.AddInt16("opcodeExpected",
PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY));
// For getting each discovered message
request.AddInt16("eventExpected", HCI_EVENT_INQUIRY_RESULT);
@@ -113,7 +118,8 @@ DiscoveryAgent::CancelInquiry(DiscoveryListener* listener)
cancelInquiryCommand = buildInquiryCancel(&size);
request.AddData("raw command", B_ANY_TYPE, cancelInquiryCommand, size);
request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS);
request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL));
request.AddInt16("opcodeExpected",
PACK_OPCODE(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL));
if (fMessenger->SendMessage(&request, &reply) == B_OK) {
if (reply.FindInt8("status", &bt_status ) == B_OK ) {
@@ -148,4 +154,4 @@ DiscoveryAgent::~DiscoveryAgent()
}
}
} /* End namespace Bluetooth */
+3 -3
View File
@@ -1,10 +1,9 @@
/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/DiscoveryListener.h>
#include <bluetooth/RemoteDevice.h>
@@ -18,6 +17,7 @@
#include <Message.h>
namespace Bluetooth {
@@ -156,4 +156,4 @@ DiscoveryListener::DiscoveryListener()
Run();
}
}
} /* end namespace Bluetooth */
+9 -5
View File
@@ -1,9 +1,9 @@
/*
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include <bluetooth/bluetooth.h>
#include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/debug.h>
@@ -12,7 +12,9 @@
#include "KitSupport.h"
BMessenger* _RetrieveBluetoothMessenger(void)
BMessenger*
_RetrieveBluetoothMessenger(void)
{
CALLED();
// Fix/review: leaking memory here
@@ -26,14 +28,16 @@ BMessenger* _RetrieveBluetoothMessenger(void)
}
uint8 GetInquiryTime()
uint8
GetInquiryTime()
{
CALLED();
return BT_DEFAULT_INQUIRY_TIME;
}
void SetInquiryTime(uint8 time)
void
SetInquiryTime(uint8 time)
{
CALLED();
((void)(time));
+3 -1
View File
@@ -5,12 +5,14 @@
#ifndef KITSUPPORT_H
#define KITSUPPORT_H
#include <Messenger.h>
BMessenger* _RetrieveBluetoothMessenger(void);
uint8 GetInquiryTime();
void SetInquiryTime(uint8 time);
#endif
#endif
+6 -2
View File
@@ -5,6 +5,7 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <bluetooth/bluetooth_error.h>
#include <bluetooth/HCI/btHCI_command.h>
@@ -215,6 +216,7 @@ struct authentication_t {
uint8 param;
};
status_t
LocalDevice::SetAuthentication(bool authentication)
{
@@ -424,7 +426,8 @@ LocalDevice::_ReadBufferSize()
{
int8 bt_status = BT_ERROR;
BluetoothCommand<> BufferSize(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE);
BluetoothCommand<> BufferSize(OGF_INFORMATIONAL_PARAM,
OCF_READ_BUFFER_SIZE);
BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
@@ -501,6 +504,7 @@ struct pageTimeout_t {
uint16 param;
};
status_t
LocalDevice::_ReadTimeouts()
{
@@ -624,4 +628,4 @@ LocalDevice::~LocalDevice()
}
}
} /* end namespace Bluetooth */
+5 -1
View File
@@ -4,6 +4,7 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <bluetooth/DeviceClass.h>
#include <bluetooth/DiscoveryAgent.h>
#include <bluetooth/DiscoveryListener.h>
@@ -24,15 +25,18 @@
#include "KitSupport.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "RemoteDevice"
namespace Bluetooth {
// TODO: Check headers for valid/reserved ranges
static const uint16 invalidConnectionHandle = 0xF000;
bool
RemoteDevice::IsTrustedDevice(void)
{
@@ -344,4 +348,4 @@ RemoteDevice::GetDeviceClass()
return fDeviceClass;
}
}
} /* end namespace Bluetooth */
+2 -3
View File
@@ -1,10 +1,9 @@
/*
* Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include <ConnectionIncoming.h>
@@ -81,4 +80,4 @@ bool ConnectionIncoming::QuitRequested()
}
}
} /* end namespace Bluetooth */
+6 -2
View File
@@ -3,6 +3,7 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
@@ -35,6 +36,7 @@
#define V_SEPARATION 10
#define BD_ADDR_LABEL "BD_ADDR: "
static const uint32 skMessageAcceptButton = 'acCp';
static const uint32 skMessageCancelButton = 'mVch';
@@ -46,6 +48,7 @@ namespace Bluetooth {
#pragma mark -
#endif
PincodeWindow::PincodeWindow(bdaddr_t address, hci_id hid)
: BWindow(BRect(800, 200, 900, 300), "Pincode request",
B_FLOATING_WINDOW,
@@ -85,7 +88,8 @@ PincodeWindow::InitUI()
fRemoteInfo = new BStringView("bdaddr","BD_ADDR: ");
// TODO: Pincode cannot be more than 16 bytes
fPincodeText = new BTextControl("pincode TextControl", "PIN code:", "5555", NULL);
fPincodeText = new BTextControl("pincode TextControl", "PIN code:",
"5555", NULL);
fAcceptButton = new BButton("fAcceptButton", "Pair",
new BMessage(skMessageAcceptButton));
@@ -200,4 +204,4 @@ void PincodeWindow::SetBDaddr(BString address)
}
}
} /* end namespace Bluetooth */