btdrv changes for 12.0.0

(cherry picked from commit 4d2e16fc336974c2be44a45e1cb549851ed901bc)
This commit is contained in:
ndeadly 2021-04-14 19:20:16 +02:00 committed by Dave Murphy
parent 65bdff6b52
commit 1c6a0ea488
3 changed files with 141 additions and 41 deletions

View File

@ -20,6 +20,8 @@ typedef struct {
u32 val; ///< Value u32 val; ///< Value
} type0; ///< ::BtdrvEventType_Unknown0 } type0; ///< ::BtdrvEventType_Unknown0
struct {
union {
struct { struct {
char name[0xF9]; ///< Device name, NUL-terminated string. char name[0xF9]; ///< Device name, NUL-terminated string.
BtdrvAddress addr; ///< Device address. BtdrvAddress addr; ///< Device address.
@ -32,10 +34,29 @@ typedef struct {
u8 rssi[0x4]; ///< s32 RSSI u8 rssi[0x4]; ///< s32 RSSI
u8 name3[0x4]; ///< Two bytes which are the same as name[11-12]. u8 name3[0x4]; ///< Two bytes which are the same as name[11-12].
u8 reserved_x36D[0x10]; ///< Reserved u8 reserved_x36D[0x10]; ///< Reserved
} v1;
struct {
BtdrvAddress addr; ///< Device address.
char name[0xF9]; ///< Device name, NUL-terminated string.
BtdrvClassOfDevice class_of_device; ///< Class of Device.
u8 reserved[0x6];
} v12;
};
} inquiry_device; ///< ::BtdrvEventType_InquiryDevice } inquiry_device; ///< ::BtdrvEventType_InquiryDevice
struct {
union {
struct { struct {
BtdrvInquiryStatus status; ///< Status: 0 = stopped, 1 = started. BtdrvInquiryStatus status; ///< Status: 0 = stopped, 1 = started.
} v1;
struct {
BtdrvInquiryStatus status; ///< Status: 0 = stopped, 1 = started.
u8 pad[3]; ///< Padding
u32 service_mask;
} v12;
};
} inquiry_status; ///< ::BtdrvEventType_InquiryStatus } inquiry_status; ///< ::BtdrvEventType_InquiryStatus
struct { struct {
@ -44,6 +65,8 @@ typedef struct {
BtdrvClassOfDevice class_of_device; ///< Class of Device. BtdrvClassOfDevice class_of_device; ///< Class of Device.
} pairing_pin_code_request; ///< ::BtdrvEventType_PairingPinCodeRequest } pairing_pin_code_request; ///< ::BtdrvEventType_PairingPinCodeRequest
struct {
union {
struct { struct {
BtdrvAddress addr; ///< Device address. BtdrvAddress addr; ///< Device address.
char name[0xF9]; ///< Device name, NUL-terminated string. char name[0xF9]; ///< Device name, NUL-terminated string.
@ -51,13 +74,35 @@ typedef struct {
u8 pad[2]; ///< Padding u8 pad[2]; ///< Padding
u32 type; ///< 0 = SSP confirm request, 3 = SSP passkey notification. u32 type; ///< 0 = SSP confirm request, 3 = SSP passkey notification.
s32 passkey; ///< Passkey, only set when the above field is value 3. s32 passkey; ///< Passkey, only set when the above field is value 3.
} v1;
struct {
BtdrvAddress addr; ///< Device address.
char name[0xF9]; ///< Device name, NUL-terminated string.
BtdrvClassOfDevice class_of_device; ///< Class of Device.
u32 type; ///< 0 = SSP confirm request, 3 = SSP passkey notification.
u8 pad; ///< Padding
s32 passkey; ///< Passkey, only set when the above field is value 3.
} v12;
};
} ssp_request; ///< ::BtdrvEventType_SspRequest } ssp_request; ///< ::BtdrvEventType_SspRequest
struct {
union {
struct { 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). 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. BtdrvAddress addr; ///< Device address.
u8 pad[2]; ///< Padding u8 pad[2]; ///< Padding
u32 type; ///< \ref BtdrvConnectionEventType u32 type; ///< \ref BtdrvConnectionEventType
} v1;
struct {
u32 type; ///< \ref BtdrvConnectionEventType
BtdrvAddress addr; ///< Device address.
u8 reserved[0xfe];
} v12;
};
} connection; ///< ::BtdrvEventType_Connection } connection; ///< ::BtdrvEventType_Connection
struct { struct {
@ -71,10 +116,19 @@ typedef struct {
union { union {
u8 data[0x480]; ///< Raw data. u8 data[0x480]; ///< Raw data.
struct {
union {
struct { struct {
BtdrvAddress addr; ///< Device address. BtdrvAddress addr; ///< Device address.
u8 pad[2]; ///< Padding u8 pad[2]; ///< Padding
BtdrvHidConnectionStatus status; ///< Status: 0 = hid connection opened, 2 = hid connection closed, 8 = failed to open hid connection. BtdrvHidConnectionStatus status; ///< Status: 0 = hid connection opened, 2 = hid connection closed, 8 = failed to open hid connection.
} v1;
struct {
BtdrvHidConnectionStatusV12 status; ///< Status: 0 = hid connection opened, 2 = hid connection closed, 8 = failed to open hid connection.
BtdrvAddress addr; ///< Device address.
} v12;
};
} connection; ///< ::BtdrvHidEventType_Connection } connection; ///< ::BtdrvHidEventType_Connection
struct { struct {
@ -424,9 +478,9 @@ Result btdrvCancelBond(BtdrvAddress addr);
* @param[in] addr \ref BtdrvAddress * @param[in] addr \ref BtdrvAddress
* @param[in] flag Flag * @param[in] flag Flag
* @param[in] pin_code \ref BtdrvBluetoothPinCode * @param[in] pin_code \ref BtdrvBluetoothPinCode
* @param[in] unk Unknown * @param[in] length Length of pin_code
*/ */
Result btdrvRespondToPinRequest(BtdrvAddress addr, bool flag, const BtdrvBluetoothPinCode *pin_code, u8 unk); Result btdrvRespondToPinRequest(BtdrvAddress addr, bool flag, const BtdrvBluetoothPinCode *pin_code, u8 length);
/** /**
* @brief RespondToSspRequest * @brief RespondToSspRequest

View File

@ -16,7 +16,7 @@ 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;
/// EventType /// EventType [1.0.0-11.0.1]
typedef enum { typedef enum {
BtdrvEventType_Unknown0 = 0, ///< Unused BtdrvEventType_Unknown0 = 0, ///< Unused
BtdrvEventType_InquiryDevice = 3, ///< Device found during Inquiry. BtdrvEventType_InquiryDevice = 3, ///< Device found during Inquiry.
@ -27,6 +27,21 @@ typedef enum {
BtdrvEventType_BluetoothCrash = 13, ///< BluetoothCrash BtdrvEventType_BluetoothCrash = 13, ///< BluetoothCrash
} BtdrvEventType; } BtdrvEventType;
/// EventType [12.0.0]
typedef enum {
BtdrvEventTypeV12_InquiryDevice = 0, ///< Device found during Inquiry.
BtdrvEventTypeV12_InquiryStatus = 1, ///< Inquiry status changed.
BtdrvEventTypeV12_PairingPinCodeRequest = 2, ///< Pairing PIN code request.
BtdrvEventTypeV12_SspRequest = 3, ///< SSP confirm request / SSP passkey notification.
BtdrvEventTypeV12_Connection = 4, ///< Connection
BtdrvEventTypeV12_Tsi = 5, ///< SetTsi (\ref btdrvSetTsi)
BtdrvEventTypeV12_BurstMode = 6, ///< SetBurstMode (\ref btdrvEnableBurstMode)
BtdrvEventTypeV12_SetZeroRetransmission = 7, ///< \ref btdrvSetZeroRetransmission
BtdrvEventTypeV12_PendingConnections = 8, ///< \ref btdrvGetPendingConnections
BtdrvEventTypeV12_MoveToSecondaryPiconet = 9, ///< \ref btdrvMoveToSecondaryPiconet
BtdrvEventTypeV12_BluetoothCrash = 10, ///< BluetoothCrash
} BtdrvEventTypeV12;
/// BtdrvInquiryStatus /// BtdrvInquiryStatus
typedef enum { typedef enum {
BtdrvInquiryStatus_Stopped = 0, ///< Inquiry started. BtdrvInquiryStatus_Stopped = 0, ///< Inquiry started.
@ -40,7 +55,7 @@ typedef enum {
BtdrvConnectionEventType_Suspended = 2, ///< ACL Link is now Suspended. BtdrvConnectionEventType_Suspended = 2, ///< ACL Link is now Suspended.
} BtdrvConnectionEventType; } BtdrvConnectionEventType;
/// ExtEventType /// ExtEventType [1.0.0-11.0.1]
typedef enum { typedef enum {
BtdrvExtEventType_SetTsi = 0, ///< SetTsi (\ref btdrvSetTsi) BtdrvExtEventType_SetTsi = 0, ///< SetTsi (\ref btdrvSetTsi)
BtdrvExtEventType_ExitTsi = 1, ///< ExitTsi (\ref btdrvSetTsi) BtdrvExtEventType_ExitTsi = 1, ///< ExitTsi (\ref btdrvSetTsi)
@ -61,7 +76,7 @@ typedef enum {
BtdrvBluetoothHhReportType_Feature = 3, ///< Feature BtdrvBluetoothHhReportType_Feature = 3, ///< Feature
} BtdrvBluetoothHhReportType; } BtdrvBluetoothHhReportType;
/// HidEventType /// HidEventType [1.0.0-11.0.1]
typedef enum { typedef enum {
BtdrvHidEventType_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo. BtdrvHidEventType_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventType_Data = 4, ///< DATA report on the Interrupt channel. BtdrvHidEventType_Data = 4, ///< DATA report on the Interrupt channel.
@ -70,6 +85,14 @@ typedef enum {
BtdrvHidEventType_GetReport = 9, ///< Response to GET_REPORT. BtdrvHidEventType_GetReport = 9, ///< Response to GET_REPORT.
} BtdrvHidEventType; } BtdrvHidEventType;
/// HidEventType [12.0.0]
typedef enum {
BtdrvHidEventTypeV12_Connection = 0, ///< Connection. Only used with \ref btdrvGetHidEventInfo.
BtdrvHidEventTypeV12_Data = 1, ///< DATA report on the Interrupt channel.
BtdrvHidEventTypeV12_SetReport = 2, ///< Response to SET_REPORT.
BtdrvHidEventTypeV12_GetReport = 3, ///< Response to GET_REPORT.
} BtdrvHidEventTypeV12;
/// HidConnectionStatus /// HidConnectionStatus
typedef enum { typedef enum {
BtdrvHidConnectionStatus_Connected = 0, BtdrvHidConnectionStatus_Connected = 0,
@ -77,6 +100,12 @@ typedef enum {
BtdrvHidConnectionStatus_FailedGeneric = 8, BtdrvHidConnectionStatus_FailedGeneric = 8,
} BtdrvHidConnectionStatus; } BtdrvHidConnectionStatus;
/// HidConnectionStatusV12
typedef enum {
BtdrvHidConnectionStatusV12_Disconnected = 0,
BtdrvHidConnectionStatusV12_Connected = 1,
} BtdrvHidConnectionStatusV12;
/// This determines the u16 data to write into a CircularBuffer. /// This determines the u16 data to write into a CircularBuffer.
typedef enum { typedef enum {
BtdrvFatalReason_Invalid = 0, ///< Only for \ref BtdrvEventInfo: invalid. BtdrvFatalReason_Invalid = 0, ///< Only for \ref BtdrvEventInfo: invalid.
@ -127,6 +156,12 @@ typedef struct {
char code[0x10]; ///< PinCode char code[0x10]; ///< PinCode
} BtdrvBluetoothPinCode; } BtdrvBluetoothPinCode;
/// BtdrvPinCode
typedef struct {
char code[0x10]; ///< PinCode
u8 length; ///< Length
} BtdrvPinCode;
/// HidData, for pre-9.0.0. /// HidData, for pre-9.0.0.
typedef struct { typedef struct {
u16 size; ///< Size of data. u16 size; ///< Size of data.

View File

@ -229,15 +229,26 @@ Result btdrvCancelBond(BtdrvAddress addr) {
return _btdrvCmdInAddrNoOut(addr, 12); return _btdrvCmdInAddrNoOut(addr, 12);
} }
Result btdrvRespondToPinRequest(BtdrvAddress addr, bool flag, const BtdrvBluetoothPinCode *pin_code, u8 unk) { Result btdrvRespondToPinRequest(BtdrvAddress addr, bool flag, const BtdrvBluetoothPinCode *pin_code, u8 length) {
if (hosversionBefore(12,0,0)) {
const struct { const struct {
BtdrvAddress addr; BtdrvAddress addr;
u8 flag; u8 flag;
u8 unk; u8 length;
BtdrvBluetoothPinCode pin_code; BtdrvBluetoothPinCode pin_code;
} in = { addr, flag!=0, unk, *pin_code }; } in = { addr, flag!=0, length, *pin_code };
return serviceDispatchIn(&g_btdrvSrv, 13, in); return serviceDispatchIn(&g_btdrvSrv, 13, in);
}
else {
const struct {
BtdrvAddress addr;
BtdrvBluetoothPinCode pin_code;
uint8_t length;
} in = { addr, *pin_code, length };
return serviceDispatchIn(&g_btdrvSrv, 13, in);
}
} }
Result btdrvRespondToSspRequest(BtdrvAddress addr, u8 variant, bool flag, u32 unk) { Result btdrvRespondToSspRequest(BtdrvAddress addr, u8 variant, bool flag, u32 unk) {