Bluetooth Driver services: Difference between revisions

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 20: Line 20:
| 3 || DisableBluetooth
| 3 || DisableBluetooth
|-
|-
| 4 || CleanupBluetooth
| 4 || FinalizeBluetooth
|-
|-
| 5 || GetAdapterProperties
| 5 || GetAdapterProperties
Line 28: Line 28:
| 7 || SetAdapterProperty
| 7 || SetAdapterProperty
|-
|-
| 8 || StartDiscovery
| 8 || StartInquiry
|-
|-
| 9 || CancelDiscovery
| 9 || StopInquiry
|-
|-
| 10 || [[#CreateBond]]
| 10 || [[#CreateBond]]
Line 38: Line 38:
| 12 || CancelBond
| 12 || CancelBond
|-
|-
| 13 || PinReply
| 13 || RespondToPinRequest
|-
|-
| 14 || SspReply
| 14 || RespondToSspRequest
|-
|-
| 15 || GetEventInfo
| 15 || GetEventInfo
Line 46: Line 46:
| 16 || InitializeHid
| 16 || InitializeHid
|-
|-
| 17 || HidConnect
| 17 || OpenHidConnection
|-
|-
| 18 || HidDisconnect
| 18 || CloseHidConnection
|-
|-
| 19 || HidSendData
| 19 || WriteHidData
|-
|-
| 20 || HidSendData2
| 20 || WriteHidData2
|-
|-
| 21 || HidSetReport
| 21 || SetHidReport
|-
|-
| 22 || HidGetReport
| 22 || GetHidReport
|-
|-
| 23 || [[#HidWakeController]]
| 23 || [[#TriggerConnection]]
|-
|-
| 24 || HidAddPairedDevice
| 24 || AddPairedDeviceInfo
|-
|-
| 25 || HidGetPairedDevice
| 25 || GetPairedDeviceInfo
|-
|-
| 26 || CleanupHid
| 26 || FinalizeHid
|-
|-
| 27 || HidGetEventInfo
| 27 || GetHidEventInfo
|-
|-
| 28 || ExtSetTsi
| 28 || SetTsi
|-
|-
| 29 || ExtSetBurstMode
| 29 || EnableBurstMode
|-
|-
| 30 || ExtSetZeroRetran
| 30 || SetZeroRetransmission
|-
|-
| 31 || ExtSetMcMode
| 31 || EnableMcMode
|-
|-
| 32 || ExtStartLlrMode
| 32 || EnableLlrScan
|-
|-
| 33 || ExtExitLlrMode
| 33 || DisableLlrScan
|-
|-
| 34 || ExtSetRadio
| 34 || EnableRadio
|-
|-
| 35 || ExtSetVisibility
| 35 || SetVisibility
|-
|-
| 36 || ExtSetTbfcScan
| 36 || EnableTbfcScan
|-
|-
| 37 || RegisterHidReportEvent
| 37 || RegisterHidReportEvent
|-
|-
| 38 || [[#HidGetReportEventInfo]]
| 38 || [[#GetHidReportEventInfo]]
|-
|-
| 39 || GetLatestPlr
| 39 || GetLatestPlr
|-
|-
| 40 || [3.0.0+] ExtGetPendingConnections
| 40 || [3.0.0+] GetPendingConnections
|-
|-
| 41 || [3.0.0+] GetChannelMap
| 41 || [3.0.0+] GetChannelMap
|-
|-
| 42 || [3.0.0+] EnableBluetoothBoostSetting
| 42 || [3.0.0+] EnableTxPowerBoostSetting
|-
|-
| 43 || [3.0.0+] IsBluetoothBoostSettingEnabled
| 43 || [3.0.0+] IsTxPowerBoostSettingEnabled
|-
|-
| 44 || [3.0.0+] EnableBluetoothAfhSetting
| 44 || [3.0.0+] EnableAfhSetting
|-
|-
| 45 || IsBluetoothAfhSettingEnabled
| 45 || IsAfhSettingEnabled
|-
|-
| 46 || [5.0.0+] InitializeBluetoothLe
| 46 || [5.0.0+] InitializeBle
|-
|-
| 47 || [5.0.0+] EnableBluetoothLe
| 47 || [5.0.0+] EnableBle
|-
|-
| 48 || [5.0.0+] DisableBluetoothLe
| 48 || [5.0.0+] DisableBle
|-
|-
| 49 || [5.0.0+] CleanupBluetoothLe
| 49 || [5.0.0+] FinalizeBle
|-
|-
| 50 || [5.0.0+] SetLeVisibility
| 50 || [5.0.0+] SetBleVisibility
|-
|-
| 51 || [5.0.0+] SetLeConnectionParameter
| 51 || [5.0.0+] SetBleConnectionParameter
|-
|-
| 52 || [5.0.0+] [[#SetLeDefaultConnectionParameter]]
| 52 || [5.0.0+] [[#SetBleDefaultConnectionParameter]]
|-
|-
| 53 || [5.0.0+] SetLeAdvertiseData
| 53 || [5.0.0+] SetBleAdvertiseData
|-
|-
| 54 || [5.0.0+] SetLeAdvertiseParameter
| 54 || [5.0.0+] SetBleAdvertiseParameter
|-
|-
| 55 || [5.0.0+] StartLeScan
| 55 || [5.0.0+] StartBleScan
|-
|-
| 56 || [5.0.0+] StopLeScan
| 56 || [5.0.0+] StopBleScan
|-
|-
| 57 || [5.0.0+] AddLeScanFilterCondition
| 57 || [5.0.0+] AddBleScanFilterCondition
|-
|-
| 58 || [5.0.0+] DeleteLeScanFilterCondition
| 58 || [5.0.0+] DeleteBleScanFilterCondition
|-
|-
| 59 || [5.0.0+] DeleteLeScanFilter
| 59 || [5.0.0+] DeleteBleScanFilter
|-
|-
| 60 || [5.0.0+] ClearLeScanFilters
| 60 || [5.0.0+] ClearBleScanFilters
|-
|-
| 61 || [5.0.0+] EnableLeScanFilter
| 61 || [5.0.0+] EnableBleScanFilter
|-
|-
| 62 || [5.0.0+] RegisterLeClient
| 62 || [5.0.0+] RegisterGattClient
|-
|-
| 63 || [5.0.0+] UnregisterLeClient
| 63 || [5.0.0+] UnregisterGattClient
|-
|-
| 64 || [5.0.0+] UnregisterLeClientAll
| 64 || [5.0.0+] UnregisterAllGattClients
|-
|-
| 65 || [5.0.0+] LeClientConnect
| 65 || [5.0.0+] ConnectGattServer
|-
|-
| 66 || [5.1.0+]
| 66 || [5.1.0+] CancelConnectGattServer
|-
|-
| 67 ([5.0.0-5.0.2] 66) || LeClientCancelConnection
| 67 ([5.0.0-5.0.2] 66) || [[#DisconnectGattServer]]
|-
|-
| 68 ([5.0.0-5.0.2] 67) || [5.0.0+] [[#LeClientDisconnect]]
| 68 ([5.0.0-5.0.2] 67) || [5.0.0+] GetGattAttribute
|-
|-
| 69 ([5.0.0-5.0.2] 68) || [5.0.0+] LeClientGetAttributes
| 69 ([5.0.0-5.0.2] 68) || [5.0.0+] GetGattService
|-
|-
| 70 ([5.0.0-5.0.2] 69) || [5.0.0+] LeClientDiscoverService
| 70 ([5.0.0-5.0.2] 69) || [5.0.0+] ConfigureAttMtu
|-
|-
| 71 ([5.0.0-5.0.2] 70) || [5.0.0+] LeClientConfigureMtu
| 71 ([5.0.0-5.0.2] 70) || [5.0.0+] RegisterGattServer
|-
|-
| 72 ([5.0.0-5.0.2] 71) || [5.0.0+] RegisterLeServer
| 72 ([5.0.0-5.0.2] 71) || [5.0.0+] UnregisterGattServer
|-
|-
| 73 ([5.0.0-5.0.2] 72) || [5.0.0+] UnregisterLeServer
| 73 ([5.0.0-5.0.2] 72) || [5.0.0+] [[#ConnectGattClient]]
|-
|-
| 74 ([5.0.0-5.0.2] 73) || [5.0.0+] [[#LeServerConnect]]
| 74 ([5.0.0-5.0.2] 73) || [5.0.0+] DisconnectGattClient
|-
|-
| 75 || [5.0.0+] CreateLeService
| 75 || [5.0.0+] AddGattService
|-
|-
| 76 ([5.0.0-5.0.2] 74) || [5.0.0+] LeServerDisconnect
| 76 ([5.0.0-5.0.2] 74) || [5.0.0+] EnableGattService
|-
|-
| 77 || [5.0.0+] AddLeCharacteristic
| 77 || [5.0.0+] AddGattCharacteristic
|-
|-
| 78 ([5.0.0-5.0.2] 76) || [5.0.0+] StartLeService
| 78 ([5.0.0-5.0.2] 76) || [5.0.0+] AddGattDescriptor
|-
|-
| 79 ([5.0.0-5.0.2] 78) || [5.0.0+] AddLeDescriptor
| 79 ([5.0.0-5.0.2] 78) || [5.0.0+] GetBleManagedEventInfo
|-
|-
| 80 ([5.0.0-5.0.2] 79) || [5.0.0+] GetLeCoreEventInfo
| 80 ([5.0.0-5.0.2] 79) || [5.0.0+] GetGattFirstCharacteristic
|-
|-
| 81 ([5.0.0-5.0.2] 80) || [5.0.0+] LeGetFirstCharacteristic
| 81 ([5.0.0-5.0.2] 80) || [5.0.0+] GetGattNextCharacteristic
|-
|-
| 82 ([5.0.0-5.0.2] 81) || [5.0.0+] LeGetNextCharacteristic
| 82 ([5.0.0-5.0.2] 81) || [5.0.0+] GetGattFirstDescriptor
|-
|-
| 83 ([5.0.0-5.0.2] 82) || [5.0.0+] LeGetFirstDescriptor
| 83 ([5.0.0-5.0.2] 82) || [5.0.0+] GetGattNextDescriptor
|-
|-
| 84 || [5.0.0+] RegisterLeCoreDataPath
| 84 || [5.0.0+] RegisterGattManagedDataPath
|-
|-
| 85 || [5.0.0+] UnregisterLeCoreDataPath
| 85 || [5.0.0+] UnregisterGattManagedDataPath
|-
|-
| 86 || [5.0.0+] RegisterLeHidDataPath
| 86 || [5.0.0+] RegisterGattHidDataPath
|-
|-
| 87 || [5.0.0+] UnregisterLeHidDataPath
| 87 || [5.0.0+] UnregisterGattHidDataPath
|-
|-
| 88 || [5.0.0+] RegisterLeDataPath
| 88 || [5.0.0+] RegisterGattDataPath
|-
|-
| 89 ([5.0.0-5.0.2] 83) || [5.0.0+] LeGetNextDescriptor
| 89 ([5.0.0-5.0.2] 83) || [5.0.0+] UnregisterGattDataPath
|-
|-
| 90 ([5.0.0-5.0.2] 89) || [5.0.0+] UnregisterLeDataPath
| 90 ([5.0.0-5.0.2] 89) || [5.0.0+] ReadGattCharacteristic
|-
|-
| 91 ([5.0.0-5.0.2] 90) || [5.0.0+] LeClientReadCharacteristic
| 91 ([5.0.0-5.0.2] 90) || [5.0.0+] ReadGattDescriptor
|-
|-
| 92 ([5.0.0-5.0.2] 91) || [5.0.0+] LeClientReadDescriptor
| 92 ([5.0.0-5.0.2] 91) || [5.0.0+] WriteGattCharacteristic
|-
|-
| 93 ([5.0.0-5.0.2] 92) || [5.0.0+] LeClientWriteCharacteristic
| 93 ([5.0.0-5.0.2] 92) || [5.0.0+] WriteGattDescriptor
|-
|-
| 94 || [5.0.0+] LeClientRegisterNotification
| 94 || [5.0.0+] RegisterGattNotification
|-
|-
| 95 ([5.0.0-5.0.2] 93) || [5.0.0+] LeClientWriteDescriptor
| 95 ([5.0.0-5.0.2] 93) || [5.0.0+] UnregisterGattNotification
|-
|-
| 96 ([5.0.0-5.0.2] 95) || [5.0.0+] LeClientDeregisterNotification
| 96 ([5.0.0-5.0.2] 95) || [5.0.0+] GetLeHidEventInfo
|-
|-
| 97 ([5.0.0-5.0.2] 96) || [5.0.0+] GetLeHidEventInfo
| 97 ([5.0.0-5.0.2] 96) || [5.0.0+] RegisterBleHidEvent
|-
|-
| 97 || [5.0.0-5.0.2] RegisterBleHidEvent
| 98 || [5.1.0+] SetBleScanParameter
|-
|-
| 98 || [5.1.0+] SetLeScanParameter
| 99 || [10.0.0+] MoveToSecondaryPiconet
|-
|-
| 256 || [5.0.0+] GetIsManufacturingMode
| 256 || [5.0.0+] IsManufacturingMode
|-
|-
| 257 || [7.0.0+] EmulateBluetoothCrash
| 257 || [7.0.0+] EmulateBluetoothCrash
Line 226: Line 226:
[9.0.0+] Now only takes a total of 0xC-bytes of input without a buffer, no output.
[9.0.0+] Now only takes a total of 0xC-bytes of input without a buffer, no output.


== HidWakeController ==
== TriggerConnection ==
Takes a total of 0x6-bytes of input, no output.
Takes a total of 0x6-bytes of input, no output.


[9.0.0+] Now takes a total of 0x8-bytes of input, no output.
[9.0.0+] Now takes a total of 0x8-bytes of input, no output.


== HidGetReportEventInfo ==
== GetHidReportEventInfo ==
No input, takes a type-0xA output buffer and returns 4-bytes of output.
No input, takes a type-0xA output buffer and returns 4-bytes of output.


[7.0.0+] No longer takes a buffer or returns output, now returns an output handle.
[7.0.0+] No longer takes a buffer or returns output, now returns an output handle.


== SetLeDefaultConnectionParameter ==
== SetBleDefaultConnectionParameter ==
Takes a total of 0x14-bytes of input, no output.
Takes a total of 0x14-bytes of input, no output.


[9.0.0+] Now takes a total of 0xC-bytes of input, no output.
[9.0.0+] Now takes a total of 0xC-bytes of input, no output.


== LeClientDisconnect ==
== DisconnectGattServer ==
Takes a total of 0xC-bytes of input, no output.
Takes a total of 0xC-bytes of input, no output.


[9.0.0+] Now takes a total of 0x4-bytes of input, no output.
[9.0.0+] Now takes a total of 0x4-bytes of input, no output.


== LeServerConnect ==
== ConnectGattClient ==
Takes a total of 0x7-bytes of input, no output.
Takes a total of 0x7-bytes of input, no output.



Revision as of 18:43, 14 April 2020

btdrv

This is "nn::bluetooth::IBluetoothDriver".

The bluetooth driver implements the bluetooth protocol over h4/uart.

It interfaces with the uart service to actually talk with the bluetooth hardware.

The code seems to be derived from a broadcom stack. A good starting point for similar source code can be found in the MICO project: https://github.com/yinhongxing/mico/tree/ea67ff3659f12d730d4dc3b8d547b093bd2ee2ee/MICO/bluetooth_bte Note that the library files contain many (symbolized) functions which match btdrv.

Cmd Name
0 InitializeBluetoothDriver
1 InitializeBluetooth
2 EnableBluetooth
3 DisableBluetooth
4 FinalizeBluetooth
5 GetAdapterProperties
6 GetAdapterProperty
7 SetAdapterProperty
8 StartInquiry
9 StopInquiry
10 #CreateBond
11 RemoveBond
12 CancelBond
13 RespondToPinRequest
14 RespondToSspRequest
15 GetEventInfo
16 InitializeHid
17 OpenHidConnection
18 CloseHidConnection
19 WriteHidData
20 WriteHidData2
21 SetHidReport
22 GetHidReport
23 #TriggerConnection
24 AddPairedDeviceInfo
25 GetPairedDeviceInfo
26 FinalizeHid
27 GetHidEventInfo
28 SetTsi
29 EnableBurstMode
30 SetZeroRetransmission
31 EnableMcMode
32 EnableLlrScan
33 DisableLlrScan
34 EnableRadio
35 SetVisibility
36 EnableTbfcScan
37 RegisterHidReportEvent
38 #GetHidReportEventInfo
39 GetLatestPlr
40 [3.0.0+] GetPendingConnections
41 [3.0.0+] GetChannelMap
42 [3.0.0+] EnableTxPowerBoostSetting
43 [3.0.0+] IsTxPowerBoostSettingEnabled
44 [3.0.0+] EnableAfhSetting
45 IsAfhSettingEnabled
46 [5.0.0+] InitializeBle
47 [5.0.0+] EnableBle
48 [5.0.0+] DisableBle
49 [5.0.0+] FinalizeBle
50 [5.0.0+] SetBleVisibility
51 [5.0.0+] SetBleConnectionParameter
52 [5.0.0+] #SetBleDefaultConnectionParameter
53 [5.0.0+] SetBleAdvertiseData
54 [5.0.0+] SetBleAdvertiseParameter
55 [5.0.0+] StartBleScan
56 [5.0.0+] StopBleScan
57 [5.0.0+] AddBleScanFilterCondition
58 [5.0.0+] DeleteBleScanFilterCondition
59 [5.0.0+] DeleteBleScanFilter
60 [5.0.0+] ClearBleScanFilters
61 [5.0.0+] EnableBleScanFilter
62 [5.0.0+] RegisterGattClient
63 [5.0.0+] UnregisterGattClient
64 [5.0.0+] UnregisterAllGattClients
65 [5.0.0+] ConnectGattServer
66 [5.1.0+] CancelConnectGattServer
67 ([5.0.0-5.0.2] 66) #DisconnectGattServer
68 ([5.0.0-5.0.2] 67) [5.0.0+] GetGattAttribute
69 ([5.0.0-5.0.2] 68) [5.0.0+] GetGattService
70 ([5.0.0-5.0.2] 69) [5.0.0+] ConfigureAttMtu
71 ([5.0.0-5.0.2] 70) [5.0.0+] RegisterGattServer
72 ([5.0.0-5.0.2] 71) [5.0.0+] UnregisterGattServer
73 ([5.0.0-5.0.2] 72) [5.0.0+] #ConnectGattClient
74 ([5.0.0-5.0.2] 73) [5.0.0+] DisconnectGattClient
75 [5.0.0+] AddGattService
76 ([5.0.0-5.0.2] 74) [5.0.0+] EnableGattService
77 [5.0.0+] AddGattCharacteristic
78 ([5.0.0-5.0.2] 76) [5.0.0+] AddGattDescriptor
79 ([5.0.0-5.0.2] 78) [5.0.0+] GetBleManagedEventInfo
80 ([5.0.0-5.0.2] 79) [5.0.0+] GetGattFirstCharacteristic
81 ([5.0.0-5.0.2] 80) [5.0.0+] GetGattNextCharacteristic
82 ([5.0.0-5.0.2] 81) [5.0.0+] GetGattFirstDescriptor
83 ([5.0.0-5.0.2] 82) [5.0.0+] GetGattNextDescriptor
84 [5.0.0+] RegisterGattManagedDataPath
85 [5.0.0+] UnregisterGattManagedDataPath
86 [5.0.0+] RegisterGattHidDataPath
87 [5.0.0+] UnregisterGattHidDataPath
88 [5.0.0+] RegisterGattDataPath
89 ([5.0.0-5.0.2] 83) [5.0.0+] UnregisterGattDataPath
90 ([5.0.0-5.0.2] 89) [5.0.0+] ReadGattCharacteristic
91 ([5.0.0-5.0.2] 90) [5.0.0+] ReadGattDescriptor
92 ([5.0.0-5.0.2] 91) [5.0.0+] WriteGattCharacteristic
93 ([5.0.0-5.0.2] 92) [5.0.0+] WriteGattDescriptor
94 [5.0.0+] RegisterGattNotification
95 ([5.0.0-5.0.2] 93) [5.0.0+] UnregisterGattNotification
96 ([5.0.0-5.0.2] 95) [5.0.0+] GetLeHidEventInfo
97 ([5.0.0-5.0.2] 96) [5.0.0+] RegisterBleHidEvent
98 [5.1.0+] SetBleScanParameter
99 [10.0.0+] MoveToSecondaryPiconet
256 [5.0.0+] IsManufacturingMode
257 [7.0.0+] EmulateBluetoothCrash
258 [9.0.0+] GetBleChannelMap

Various cmdids were moved with [4.0.0+] and [5.0.0+].

CreateBond

Takes a total of 0x6-bytes of input and a type-0x19 input buffer, no output.

[9.0.0+] Now only takes a total of 0xC-bytes of input without a buffer, no output.

TriggerConnection

Takes a total of 0x6-bytes of input, no output.

[9.0.0+] Now takes a total of 0x8-bytes of input, no output.

GetHidReportEventInfo

No input, takes a type-0xA output buffer and returns 4-bytes of output.

[7.0.0+] No longer takes a buffer or returns output, now returns an output handle.

SetBleDefaultConnectionParameter

Takes a total of 0x14-bytes of input, no output.

[9.0.0+] Now takes a total of 0xC-bytes of input, no output.

DisconnectGattServer

Takes a total of 0xC-bytes of input, no output.

[9.0.0+] Now takes a total of 0x4-bytes of input, no output.

ConnectGattClient

Takes a total of 0x7-bytes of input, no output.

[9.0.0+] Now takes a total of 1-byte of input, no output.

bt

This is "nn::bluetooth::IBluetoothUser".

Cmd Name
0 LeClientReadCharacteristic
1 LeClientReadDescriptor
2 LeClientWriteCharacteristic
3 LeClientWriteDescriptor
4 LeClientRegisterNotification
5 LeClientDeregisterNotification
6 SetLeResponse
7 LeSendIndication
8 GetLeEventInfo
9 RegisterBleEvent