Difference between revisions of "Bluetooth Driver services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 96: Line 96:
 
| 40 || [3.0.0+] [[#GetPendingConnections]]
 
| 40 || [3.0.0+] [[#GetPendingConnections]]
 
|-
 
|-
| 41 || [3.0.0+] GetChannelMap
+
| 41 || [3.0.0+] [[#GetChannelMap]]
 
|-
 
|-
| 42 || [3.0.0+] EnableTxPowerBoostSetting
+
| 42 || [3.0.0+] [[#EnableTxPowerBoostSetting]]
 
|-
 
|-
| 43 || [3.0.0+] IsTxPowerBoostSettingEnabled
+
| 43 || [3.0.0+] [[#IsTxPowerBoostSettingEnabled]]
 
|-
 
|-
| 44 || [3.0.0+] EnableAfhSetting
+
| 44 || [3.0.0+] [[#EnableAfhSetting]]
 
|-
 
|-
| 45 || IsAfhSettingEnabled
+
| 45 || [[#IsAfhSettingEnabled]]
 
|-
 
|-
| 46 || [5.0.0+] InitializeBle
+
| 46 || [5.0.0+] [[#InitializeBle]]
 
|-
 
|-
| 47 || [5.0.0+] EnableBle
+
| 47 || [5.0.0+] [[#EnableBle]]
 
|-
 
|-
| 48 || [5.0.0+] DisableBle
+
| 48 || [5.0.0+] [[#DisableBle]]
 
|-
 
|-
| 49 || [5.0.0+] FinalizeBle
+
| 49 || [5.0.0+] [[#FinalizeBle]]
 
|-
 
|-
| 50 || [5.0.0+] SetBleVisibility
+
| 50 || [5.0.0+] [[#SetBleVisibility]]
 
|-
 
|-
| 51 || [5.0.0+] SetBleConnectionParameter
+
| 51 || [5.0.0+] [[#SetBleConnectionParameter]]
 
|-
 
|-
 
| 52 || [5.0.0+] [[#SetBleDefaultConnectionParameter]]
 
| 52 || [5.0.0+] [[#SetBleDefaultConnectionParameter]]
Line 362: Line 362:
 
== GetPendingConnections ==
 
== GetPendingConnections ==
 
No input/output.
 
No input/output.
 +
 +
== GetChannelMap ==
 +
Takes a type-0x16 output buffer containing a [[#ChannelMapList]].
 +
 +
== EnableTxPowerBoostSetting ==
 +
Takes an input bool, no output.
 +
 +
== IsTxPowerBoostSettingEnabled ==
 +
No input, returns an output bool.
 +
 +
sdknso sets the tmpout_bool to 1, and uses that with the cmd. The sdknso func directly returns tmpout_bool, errors from the cmd are ignored.
 +
 +
== EnableAfhSetting ==
 +
Takes an input bool, no output.
 +
 +
== IsAfhSettingEnabled ==
 +
sdknso sets the tmpout_bool to 1, and uses that with the cmd. The sdknso func directly returns tmpout_bool, errors from the cmd are ignored.
 +
 +
== InitializeBle ==
 +
No input, returns an output Event handle with EventClearMode=1.
 +
 +
== EnableBle ==
 +
No input/output.
 +
 +
== DisableBle ==
 +
No input/output.
 +
 +
== FinalizeBle ==
 +
No input/output.
 +
 +
== SetBleVisibility ==
 +
Takes two input bools, no output.
 +
 +
== SetBleConnectionParameter ==
  
 
== SetBleDefaultConnectionParameter ==
 
== SetBleDefaultConnectionParameter ==
Line 438: Line 472:
 
= PlrList =
 
= PlrList =
 
This is "nn::bluetooth::PlrList". This is a 0xA4-byte struct.
 
This is "nn::bluetooth::PlrList". This is a 0xA4-byte struct.
 +
 +
= ChannelMapList =
 +
This is "nn::bluetooth::ChannelMapList". This is a 0x88-byte struct.
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 00:19, 9 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 ([1.0.0-8.1.1] #HidWakeController)
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 input #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.

RemoveBond

Takes an input #Address, no output.

CancelBond

Takes an input #Address, no output.

RespondToPinRequest

Takes an input #Address, a bool, an u8, a #BluetoothPinCode, no output.

sdknso uses an user-specified s32 for the u8.

RespondToSspRequest

Takes an input #Address, a #BluetoothSspVariant, a bool, an u32, no output.

GetEventInfo

Takes a type-0xA output buffer and returns an output #EventType.

InitializeHid

Takes an input u16, returns an output Event with EventClearMode=1.

Originally sdknso used an user-specified value for the u16, however with newer versions it uses hard-coded value 0x1 instead.

OpenHidConnection

Takes an input #Address, no output.

CloseHidConnection

Takes an input #Address, no output.

WriteHidData

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

WriteHidData2

Takes an input #Address and a type-0x9 input buffer, no output.

SetHidReport

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

GetHidReport

Takes an input #Address, an u8, a #BluetoothHhReportType, no output.

HidWakeController

Takes an input #Address, no output.

TriggerConnection

Takes an input #Address and an u16, no output.

AddPairedDeviceInfo

Takes a type-0x19 input buffer containing BluetoothDevicesSettings, no output.

GetPairedDeviceInfo

Takes an input #Address and a type-0x1A output buffer containing BluetoothDevicesSettings.

FinalizeHid

No input/output.

GetHidEventInfo

Takes a type-0xA output buffer, returns an output #HidEventType.

SetTsi

Takes an input #Address and an u8, no output.

EnableBurstMode

Takes an input #Address and a bool, no output.

SetZeroRetransmission

Takes an input #Address and a type-0x9 input buffer containing an array of u8s, no output.

EnableMcMode

Takes an input bool, no output.

EnableLlrScan

No input/output.

DisableLlrScan

No input/output.

EnableRadio

Takes an input bool, no output.

SetVisibility

Takes two input bools, no output.

EnableTbfcScan

Takes an input bool, no output.

RegisterHidReportEvent

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

GetHidReportEventInfo

No input, takes a type-0xA output buffer and returns a #HidEventType.

[7.0.0+] No longer takes a buffer or returns output, now returns an output sharedmem handle. sdknso maps this with size=0x3000 and permissions=RW-.

Originally this was used in a dedicated sdknso func, with [7.0.0+] this is now used at the start of the sdknso impl for #RegisterHidReportEvent if the above sharedmem was not mapped yet.

The [7.0.0+] GetHidReportEventInfo sdknso func loads data using the above sharedmem.

GetLatestPlr

Takes a type-0x16 output buffer containing a #PlrList.

GetPendingConnections

No input/output.

GetChannelMap

Takes a type-0x16 output buffer containing a #ChannelMapList.

EnableTxPowerBoostSetting

Takes an input bool, no output.

IsTxPowerBoostSettingEnabled

No input, returns an output bool.

sdknso sets the tmpout_bool to 1, and uses that with the cmd. The sdknso func directly returns tmpout_bool, errors from the cmd are ignored.

EnableAfhSetting

Takes an input bool, no output.

IsAfhSettingEnabled

sdknso sets the tmpout_bool to 1, and uses that with the cmd. The sdknso func directly returns tmpout_bool, errors from the cmd are ignored.

InitializeBle

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

EnableBle

No input/output.

DisableBle

No input/output.

FinalizeBle

No input/output.

SetBleVisibility

Takes two input bools, no output.

SetBleConnectionParameter

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

BluetoothPropertyType

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

TransportType

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

BluetoothSspVariant

This is u8 enum "nn::bluetooth::BluetoothSspVariant".

EventType

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

BluetoothHhReportType

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

HidEventType

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

AdapterProperty

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

Address

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

BluetoothPinCode

This is "nn::bluetooth::BluetoothPinCode". This is a 0x10-byte struct with 1-byte alignment.

HidReport

This is "nn::bluetooth::HidReport". This is a 0x2BE-byte struct.

PlrList

This is "nn::bluetooth::PlrList". This is a 0xA4-byte struct.

ChannelMapList

This is "nn::bluetooth::ChannelMapList". This is a 0x88-byte struct.