btdrv: update GetAdapterProperties, GetAdapterProperty and SetAdapterProperty service wrappers for 12.0.0

This commit is contained in:
ndeadly 2021-04-20 01:14:37 +02:00 committed by Dave Murphy
parent 2129806eb3
commit c9e9ea9c21
3 changed files with 52 additions and 7 deletions

View File

@ -493,7 +493,7 @@ Result btdrvSetAdapterProperty(BtdrvAdapterPropertyType type, const BtdrvAdapter
Result btdrvLegacyStartInquiry(void); Result btdrvLegacyStartInquiry(void);
/** /**
* @brief [12.0.0+] This starts Inquiry, the output data will be available via \ref btdrvGetEventInfo. * @brief StartInquiry [12.0.0+] This starts Inquiry, the output data will be available via \ref btdrvGetEventInfo.
* @param[in] services Bitmask of allowed services. When -1 the original defaults from pre-12.0.0 are used. * @param[in] services Bitmask of allowed services. When -1 the original defaults from pre-12.0.0 are used.
* @param[in] duration Inquiry duration in nanoseconds. * @param[in] duration Inquiry duration in nanoseconds.
* @note This is used by btm-sysmodule. * @note This is used by btm-sysmodule.

View File

@ -7,7 +7,7 @@
#pragma once #pragma once
#include "../types.h" #include "../types.h"
/// BluetoothPropertyType /// BluetoothPropertyType [1.0.0-11.0.1]
typedef enum { typedef enum {
BtdrvBluetoothPropertyType_Name = 1, ///< Name. String, max length 0xF8 excluding NUL-terminator. BtdrvBluetoothPropertyType_Name = 1, ///< Name. String, max length 0xF8 excluding NUL-terminator.
BtdrvBluetoothPropertyType_Address = 2, ///< \ref BtdrvAddress BtdrvBluetoothPropertyType_Address = 2, ///< \ref BtdrvAddress
@ -16,6 +16,14 @@ typedef enum {
BtdrvBluetoothPropertyType_FeatureSet = 6, ///< 1-byte, FeatureSet. The default is value 0x68. BtdrvBluetoothPropertyType_FeatureSet = 6, ///< 1-byte, FeatureSet. The default is value 0x68.
} BtdrvBluetoothPropertyType; } BtdrvBluetoothPropertyType;
/// AdapterPropertyType [12.0.0+]
typedef enum {
BtdrvAdapterPropertyType_Address = 0, ///< \ref BtdrvAddress
BtdrvAdapterPropertyType_Name = 1, ///< Name. String, max length 0xF8 excluding NUL-terminator.
BtdrvAdapterPropertyType_ClassOfDevice = 2, ///< 3-bytes, Class of Device.
BtdrvAdapterPropertyType_Unknown3 = 3, ///< Only available with \ref btdrvSetAdapterProperty. Unknown, \ref BtdrvAddress.
} BtdrvAdapterPropertyType;
/// EventType /// EventType
typedef enum { typedef enum {
///< BtdrvEventType_* should be used on [12.0.0+] ///< BtdrvEventType_* should be used on [12.0.0+]
@ -140,14 +148,28 @@ typedef struct {
u8 class_of_device[0x3]; ///< ClassOfDevice u8 class_of_device[0x3]; ///< ClassOfDevice
} BtdrvClassOfDevice; } BtdrvClassOfDevice;
/// AdapterProperty /// AdapterProperty [1.0.0-11.0.1]
typedef struct { typedef struct {
BtdrvAddress addr; ///< Same as the data for ::BtdrvBluetoothPropertyType_Address. BtdrvAddress addr; ///< Same as the data for ::BtdrvBluetoothPropertyType_Address.
BtdrvClassOfDevice class_of_device; ///< Same as the data for ::BtdrvBluetoothPropertyType_ClassOfDevice. BtdrvClassOfDevice class_of_device; ///< Same as the data for ::BtdrvBluetoothPropertyType_ClassOfDevice.
char name[0xF9]; ///< Same as the data for ::BtdrvBluetoothPropertyType_Name (last byte is not initialized). char name[0xF9]; ///< Same as the data for ::BtdrvBluetoothPropertyType_Name (last byte is not initialized).
u8 feature_set; ///< Set to hard-coded value 0x68 (same as the data for ::BtdrvBluetoothPropertyType_FeatureSet). u8 feature_set; ///< Set to hard-coded value 0x68 (same as the data for ::BtdrvBluetoothPropertyType_FeatureSet).
} BtdrvAdapterPropertyOld;
/// AdapterProperty [12.0.0+]
typedef struct {
u8 type; ///< \ref BtdrvAdapterPropertyType
u8 size; ///< Data size.
u8 data[0x100]; ///< Data (Above size), as specified by the type.
} BtdrvAdapterProperty; } BtdrvAdapterProperty;
/// AdapterPropertySet [12.0.0+]
typedef struct {
BtdrvAddress addr; ///< Same as the data for ::BtdrvBluetoothPropertyType_Address.
BtdrvClassOfDevice class_of_device; ///< Same as the data for ::BtdrvBluetoothPropertyType_ClassOfDevice.
char name[0xF9]; ///< Same as the data for ::BtdrvBluetoothPropertyType_Name (last byte is not initialized).
} BtdrvAdapterPropertySet;
/// BluetoothPinCode [1.0.0-11.0.1] /// BluetoothPinCode [1.0.0-11.0.1]
typedef struct { typedef struct {
char code[0x10]; ///< PinCode char code[0x10]; ///< PinCode

View File

@ -173,14 +173,21 @@ Result btdrvFinalizeBluetooth(void) {
return _btdrvCmdNoIO(4); return _btdrvCmdNoIO(4);
} }
Result btdrvGetAdapterProperties(BtdrvAdapterProperty *property) { Result btdrvLegacyGetAdapterProperties(BtdrvAdapterPropertyOld *properties) {
return serviceDispatch(&g_btdrvSrv, 5, return serviceDispatch(&g_btdrvSrv, 5,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out | SfBufferAttr_FixedSize }, .buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out | SfBufferAttr_FixedSize },
.buffers = { { property, sizeof(*property) } }, .buffers = { { properties, sizeof(*properties) } },
); );
} }
Result btdrvGetAdapterProperty(BtdrvBluetoothPropertyType type, void* buffer, size_t size) { Result btdrvGetAdapterProperties(BtdrvAdapterPropertySet *properties) {
return serviceDispatch(&g_btdrvSrv, 5,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out | SfBufferAttr_FixedSize },
.buffers = { { properties, sizeof(*properties) } },
);
}
Result btdrvLegacyGetAdapterProperty(BtdrvBluetoothPropertyType type, void* buffer, size_t size) {
u32 tmp=type; u32 tmp=type;
return serviceDispatchIn(&g_btdrvSrv, 6, tmp, return serviceDispatchIn(&g_btdrvSrv, 6, tmp,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out }, .buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out },
@ -188,7 +195,15 @@ Result btdrvGetAdapterProperty(BtdrvBluetoothPropertyType type, void* buffer, si
); );
} }
Result btdrvSetAdapterProperty(BtdrvBluetoothPropertyType type, const void* buffer, size_t size) { Result btdrvGetAdapterProperty(BtdrvAdapterPropertyType type, BtdrvAdapterProperty *property) {
u32 tmp=type;
return serviceDispatchIn(&g_btdrvSrv, 6, tmp,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out | SfBufferAttr_FixedSize },
.buffers = { { property, sizeof(*property) } },
);
}
Result btdrvLegacySetAdapterProperty(BtdrvBluetoothPropertyType type, const void* buffer, size_t size) {
u32 tmp=type; u32 tmp=type;
return serviceDispatchIn(&g_btdrvSrv, 7, tmp, return serviceDispatchIn(&g_btdrvSrv, 7, tmp,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In }, .buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In },
@ -196,6 +211,14 @@ Result btdrvSetAdapterProperty(BtdrvBluetoothPropertyType type, const void* buff
); );
} }
Result btdrvSetAdapterProperty(BtdrvAdapterPropertyType type, const BtdrvAdapterProperty *property) {
u32 tmp=type;
return serviceDispatchIn(&g_btdrvSrv, 7, tmp,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In | SfBufferAttr_FixedSize },
.buffers = { { property, sizeof(*property) } },
);
}
Result btdrvLegacyStartInquiry(void) { Result btdrvLegacyStartInquiry(void) {
return _btdrvCmdNoIO(8); return _btdrvCmdNoIO(8);
} }