Difference between revisions of "Bluetooth Driver services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 26: Line 26:
 
| 5 || [[#GetAdapterProperties]]
 
| 5 || [[#GetAdapterProperties]]
 
|-
 
|-
| 6 || GetAdapterProperty
+
| 6 || [[#GetAdapterProperty]]
 
|-
 
|-
| 7 || SetAdapterProperty
+
| 7 || [[#SetAdapterProperty]]
 
|-
 
|-
| 8 || StartInquiry
+
| 8 || [[#StartInquiry]]
 
|-
 
|-
| 9 || StopInquiry
+
| 9 || [[#StopInquiry]]
 
|-
 
|-
 
| 10 || [[#CreateBond]]
 
| 10 || [[#CreateBond]]
Line 242: Line 242:
 
== GetAdapterProperties ==
 
== GetAdapterProperties ==
 
Takes a type-0x1A output buffer containing an [[#AdapterProperty]].
 
Takes a type-0x1A output buffer containing an [[#AdapterProperty]].
 +
 +
== GetAdapterProperty ==
 +
Takes an input [[#BluetoothPropertyType]] and a type-0xA output buffer.
 +
 +
== SetAdapterProperty ==
 +
Takes an input [[#BluetoothPropertyType]] and a type-0x9 input buffer.
 +
 +
== StartInquiry ==
 +
No input/output.
 +
 +
== StopInquiry ==
 +
No input/output.
  
 
== CreateBond ==
 
== CreateBond ==
Takes a total of 0x6-bytes of input and a type-0x19 input buffer, no output.
+
Takes an [[#Address]] and a type-0x19 input buffer containing a [[#TransportType]], no output.
  
[9.0.0+] Now only takes a total of 0xC-bytes of input without a buffer, no output.
+
[9.0.0+] Now only takes an [[#Address]] and a [[#TransportType]] without a buffer, no output.
  
 
== TriggerConnection ==
 
== TriggerConnection ==
Line 300: Line 312:
 
| 9 || RegisterBleEvent
 
| 9 || RegisterBleEvent
 
|}
 
|}
 +
 +
= AdapterProperty =
 +
This is "nn::bluetooth::AdapterProperty".
 +
 +
= BluetoothPropertyType =
 +
This is u32 enum "nn::bluetooth::BluetoothPropertyType".
 +
 +
= Address =
 +
This is "nn::bluetooth::Address". This is a 0x6-byte struct with 1-byte alignment.
 +
 +
= TransportType =
 +
This is u32 enum "nn::bluetooth::TransportType".
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 16:05, 8 July 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.

Support for "nn::bluetooth::*" was added to sdknso with 6.x.

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+].

InitializeBluetoothDriver

No input/output.

This is the first cmd used during service init.

InitializeBluetooth

No input, returns an output Event handle with EventClearMode=1.

EnableBluetooth

No input/output.

DisableBluetooth

No input/output.

FinalizeBluetooth

No input/output.

GetAdapterProperties

Takes a type-0x1A output buffer containing an #AdapterProperty.

GetAdapterProperty

Takes an input #BluetoothPropertyType and a type-0xA output buffer.

SetAdapterProperty

Takes an input #BluetoothPropertyType and a type-0x9 input buffer.

StartInquiry

No input/output.

StopInquiry

No input/output.

CreateBond

Takes an #Address and a type-0x19 input buffer containing a #TransportType, no output.

[9.0.0+] Now only takes an #Address and a #TransportType 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

AdapterProperty

This is "nn::bluetooth::AdapterProperty".

BluetoothPropertyType

This is u32 enum "nn::bluetooth::BluetoothPropertyType".

Address

This is "nn::bluetooth::Address". This is a 0x6-byte struct with 1-byte alignment.

TransportType

This is u32 enum "nn::bluetooth::TransportType".