btdrv: Updated/added structs/enums for events, etc.

This commit is contained in:
yellows8 2021-01-16 13:34:00 -05:00
parent 9e52e55177
commit c8fdae9189
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 135 additions and 8 deletions

View File

@ -11,11 +11,72 @@
#include "../services/set.h"
#include "../sf/service.h"
/// Data for \ref btdrvGetHidReportEventInfo. The data stored here depends on the \ref BtdrvHidEventType.
/// Data for \ref btdrvGetEventInfo. The data stored here depends on the \ref BtdrvEventType.
typedef struct {
union {
u8 data[0x400]; ///< Raw data.
struct {
u32 val; ///< Value
} type0; ///< ::BtdrvEventType_Unknown0
struct {
u8 name[0xF9]; ///< Device name, NUL-terminated string.
BtdrvAddress addr; ///< Device address.
u8 unk_xFF[0x10]; ///< Unknown
u8 device_class[0x3]; ///< Device class.
u8 unk_x112[0x4]; ///< Set to fixed value u32 0x1.
u8 unk_x116[0xFA]; ///< Unknown
u8 reserved_x210[0x5C]; ///< Reserved
u8 name2[0xF9]; ///< Device name, NUL-terminated string. Same as name above, except starting at index 1.
u8 rssi[0x4]; ///< s32 RSSI
u8 name3[0x4]; ///< Two bytes which are the same as name[11-12].
u8 reserved_x36D[0x10]; ///< Reserved
} inquiry_device; ///< ::BtdrvEventType_InquiryDevice
struct {
u32 status; ///< Status: 0 = stopped, 1 = started.
} inquiry_status; ///< ::BtdrvEventType_InquiryStatus
struct {
BtdrvAddress addr; ///< Device address.
u8 name[0xF9]; ///< Device name, NUL-terminated string.
u8 device_class[0x3]; ///< Device class.
} pairing_pin_code_request; ///< ::BtdrvEventType_PairingPinCodeRequest
struct {
BtdrvAddress addr; ///< Device address.
u8 name[0xF9]; ///< Device name, NUL-terminated string.
u8 device_class[0x3]; ///< Device class.
u8 pad[2]; ///< Padding
u32 type; ///< 0 = SSP confirm request, 3 = SSP passkey notification.
s32 passkey; ///< Passkey, only set when the above field is value 3.
} ssp_request; ///< ::BtdrvEventType_SspRequest
struct {
u32 status; ///< Status, always 0 except with ::BtdrvConnectionEventType_Status: 2 = ACL Link is now Resumed, 9 = connection failed (pairing/authentication failed, or opening the hid connection failed).
BtdrvAddress addr; ///< Device address.
u8 pad[2]; ///< Padding
u32 type; ///< \ref BtdrvConnectionEventType
} connection; ///< ::BtdrvEventType_Connection
struct {
u16 reason; ///< \ref BtdrvFatalReason
} bluetooth_crash; ///< ::BtdrvEventType_BluetoothCrash
};
} BtdrvEventInfo;
/// Data for \ref btdrvGetHidReportEventInfo / \ref btdrvGetHidEventInfo. The data stored here depends on the \ref BtdrvHidEventType.
typedef struct {
union {
u8 data[0x480]; ///< Raw data.
struct {
BtdrvAddress addr; ///< Device address.
u8 pad[2]; ///< Padding
u32 status; ///< Status: 0 = hid connection opened, 2 = hid connection closed, 8 = failed to open hid connection.
} connection; ///< ::BtdrvHidEventType_Connection
struct {
u32 unk_x0; ///< Always 0.
u8 unk_x4; ///< Always 0.
@ -25,6 +86,51 @@ typedef struct {
u8 data[]; ///< Data.
} data_report; ///< ::BtdrvHidEventType_Data
struct {
u32 type;
union {
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Device address.
} type0;
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Device address.
} type1;
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Device address.
} type2;
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Device address.
} type3;
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Device address.
u8 pad[2]; ///< Padding
u8 flag; ///< Flag
} type4;
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Unused
u8 pad[2]; ///< Padding
u32 count; ///< Count value.
} pending_connections; ///< type5
struct {
u32 status; ///< 0 for success, non-zero for error.
BtdrvAddress addr; ///< Device address.
} type6;
};
} type7; ///< ::BtdrvHidEventType_Unknown7
struct {
union {
u8 data[0xC]; ///< Raw data.
@ -182,13 +288,13 @@ Result btdrvGetAdapterProperty(BtdrvBluetoothPropertyType type, void* buffer, si
Result btdrvSetAdapterProperty(BtdrvBluetoothPropertyType type, const void* buffer, size_t size);
/**
* @brief StartInquiry
* @brief This starts Inquiry, the output data will be available via \ref btdrvGetEventInfo. Inquiry will automatically stop in 10.24 seconds.
* @note This is used by btm-sysmodule.
*/
Result btdrvStartInquiry(void);
/**
* @brief StopInquiry
* @brief This stops Inquiry which was started by \ref btdrvStartInquiry, if it's still active.
* @note This is used by btm-sysmodule.
*/
Result btdrvStopInquiry(void);
@ -237,7 +343,7 @@ Result btdrvRespondToSspRequest(BtdrvAddress addr, u8 variant, bool flag, u32 un
/**
* @brief GetEventInfo
* @note This is used by btm-sysmodule.
* @param[out] buffer Output buffer. 0x400-bytes from state is written here.
* @param[out] buffer Output buffer, see \ref BtdrvEventInfo.
* @param[in] size Output buffer size.
* @oaram[out] type Output EventType.
*/
@ -328,9 +434,9 @@ Result btdrvFinalizeHid(void);
/**
* @brief GetHidEventInfo
* @note This is used by btm-sysmodule.
* @param[out] buffer Output buffer. 0x480-bytes from state is written here.
* @param[out] buffer Output buffer, see \ref BtdrvHidReportEventInfo.
* @param[in] size Output buffer size.
* @param[out] type \ref BtdrvHidEventType, always ::BtdrvHidEventType_Unknown0 or ::BtdrvHidEventType_Unknown7.
* @param[out] type \ref BtdrvHidEventType, always ::BtdrvHidEventType_Connection or ::BtdrvHidEventType_Unknown7.
*/
Result btdrvGetHidEventInfo(void* buffer, size_t size, BtdrvHidEventType *type);
@ -431,6 +537,7 @@ Result btdrvGetLatestPlr(BtdrvPlrList *out);
/**
* @brief GetPendingConnections
* @note The output data will be available via \ref btdrvGetHidEventInfo.
* @note This is used by btm-sysmodule.
* @note Only available on [3.0.0+].
*/

View File

@ -16,6 +16,24 @@ typedef enum {
BtdrvBluetoothPropertyType_Unknown6 = 6, ///< Unknown. 1-byte. The default is value 0x68.
} BtdrvBluetoothPropertyType;
/// EventType
typedef enum {
BtdrvEventType_Unknown0 = 0, ///< Unused
BtdrvEventType_InquiryDevice = 3, ///< Device found during Inquiry.
BtdrvEventType_InquiryStatus = 4, ///< Inquiry status changed.
BtdrvEventType_PairingPinCodeRequest = 5, ///< Pairing PIN code request.
BtdrvEventType_SspRequest = 6, ///< SSP confirm request / SSP passkey notification.
BtdrvEventType_Connection = 7, ///< Connection
BtdrvEventType_BluetoothCrash = 13, ///< BluetoothCrash
} BtdrvEventType;
/// ConnectionEventType
typedef enum {
BtdrvConnectionEventType_Status = 0, ///< BtdrvEventInfo::connection::status
BtdrvConnectionEventType_SspConfirmRequest = 1, ///< SSP confirm request.
BtdrvConnectionEventType_Suspended = 2, ///< ACL Link is now Suspended.
} BtdrvConnectionEventType;
/// BluetoothHhReportType
/// Bit0-1 directly control the HID bluetooth transaction report-type value.
/// Bit2-3: these directly control the Parameter Reserved field for SetReport, for GetReport these control the Parameter Reserved and Size bits.
@ -28,18 +46,20 @@ typedef enum {
/// HidEventType
typedef enum {
BtdrvHidEventType_Unknown0 = 0, ///< Unknown. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventType_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventType_Data = 4, ///< DATA report on the Interrupt channel.
BtdrvHidEventType_Unknown7 = 7, ///< Unknown. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventType_SetReport = 8, ///< Response to SET_REPORT.
BtdrvHidEventType_GetReport = 9, ///< Response to GET_REPORT.
} BtdrvHidEventType;
/// This determines the u16 data to write into the CircularBuffer (name "BLE CORE").
/// This determines the u16 data to write into a CircularBuffer.
typedef enum {
BtdrvFatalReason_Invalid = 0, ///< Only for \ref BtdrvEventInfo: invalid.
BtdrvFatalReason_Unknown1 = 1, ///< u16 data = 0x850.
BtdrvFatalReason_Unknown2 = 2, ///< u16 data = 0x851.
BtdrvFatalReason_Unknown3 = 3, ///< Reason values which aren't 1/2: u16 data = 0x852.
BtdrvFatalReason_Enable = 7, ///< Only for \ref BtdrvEventInfo: triggered after enabling bluetooth, depending on the value of a global state field.
} BtdrvFatalReason;
/// Address