Difference between revisions of "BTM services"
Line 266: | Line 266: | ||
== BleConnect == | == BleConnect == | ||
Takes an input [[Bluetooth_Driver_services#Address|Address]], no output. | Takes an input [[Bluetooth_Driver_services#Address|Address]], no output. | ||
+ | |||
+ | An error is thrown if the [[Bluetooth_Driver_services#Address|Address]] is already connected (listed in the [[Bluetooth_Driver_services#BleConnectionInfo|BleConnectionInfo]] from [[#BleGetConnectionState]]). An error is thrown if 4 [[#BleGetConnectionState|devices]] are already connected. | ||
== BleOverrideConnection == | == BleOverrideConnection == | ||
Line 274: | Line 276: | ||
== BleDisconnect == | == BleDisconnect == | ||
Takes an input u32, no output. | Takes an input u32, no output. | ||
+ | |||
+ | The u32 must match an Id in a [[Bluetooth_Driver_services#BleConnectionInfo|BleConnectionInfo]] from [[#BleGetConnectionState]] (0xFFFFFFFF is invalid). | ||
== BleGetConnectionState == | == BleGetConnectionState == | ||
Takes a type-0xA output buffer containing an array of [[Bluetooth_Driver_services#BleConnectionInfo|BleConnectionInfo]], returns an output u8 total_out. | Takes a type-0xA output buffer containing an array of [[Bluetooth_Driver_services#BleConnectionInfo|BleConnectionInfo]], returns an output u8 total_out. | ||
+ | |||
+ | Other cmds which use this internally use arraycount=4. | ||
== BleGetGattClientConditionList == | == BleGetGattClientConditionList == | ||
Line 630: | Line 636: | ||
Takes a PID, an [[Bluetooth_Driver_services#Address|Address]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output. | Takes a PID, an [[Bluetooth_Driver_services#Address|Address]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output. | ||
− | + | This is similar to the [[#BleConnect|btm]] cmd. | |
=== BleDisconnect === | === BleDisconnect === | ||
Takes an input u32, no output. | Takes an input u32, no output. | ||
− | + | This is similar to the [[#BleDisconnect|btm]] cmd. | |
=== BleGetConnectionState === | === BleGetConnectionState === | ||
Takes a PID, a type-0xA output buffer containing an array of [[Bluetooth_Driver_services#BleConnectionInfo|BleConnectionInfo]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], returns an output u8 total_out. | Takes a PID, a type-0xA output buffer containing an array of [[Bluetooth_Driver_services#BleConnectionInfo|BleConnectionInfo]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], returns an output u8 total_out. | ||
− | + | This is similar to the [[#BleGetConnectionState|btm]] cmd. | |
=== AcquireBlePairingEvent === | === AcquireBlePairingEvent === | ||
No input, returns an output u8 and an Event handle with EventClearMode=1. | No input, returns an output u8 and an Event handle with EventClearMode=1. | ||
+ | |||
+ | This is similar to the [[#AcquireBlePairingEvent|btm]] cmd. | ||
sdknso will Abort if the output u8 is value 0. | sdknso will Abort if the output u8 is value 0. |
Revision as of 14:55, 7 August 2020
btm
This is "nn::btm::IBtm".
Support for "nn::btm::*" was added to sdknso with 6.x.
This has max_sessions 6. IPC is handled by 2 threads shared with all services.
These btm services with BLE only allow connecting to devices which have a #GattService with a certain custom UUID present.
Cmd | Name |
---|---|
0 | #GetState |
1 | #GetHostDeviceProperty |
2 | #AcquireDeviceConditionEvent |
3 | #GetDeviceCondition |
4 | #SetBurstMode |
5 | #SetSlotMode |
6 | [1.0.0-8.1.0] #SetBluetoothMode |
7 | #SetWlanMode |
8 | #AcquireDeviceInfoEvent |
9 | #GetDeviceInfo |
10 | #AddDeviceInfo |
11 | #RemoveDeviceInfo |
12 | #IncreaseDeviceInfoOrder |
13 | #LlrNotify |
14 | #EnableRadio |
15 | #DisableRadio |
16 | #HidDisconnect |
17 | #HidSetRetransmissionMode |
18 | [2.0.0+] #AcquireAwakeReqEvent |
19 | [4.0.0+] #AcquireLlrStateEvent |
20 | [4.0.0+] #IsLlrStarted |
21 | [4.0.0+] #EnableSlotSaving |
22 | [5.0.0+] #ProtectDeviceInfo |
23 | [5.0.0+] #AcquireBleScanEvent |
24 | [5.1.0+] #GetBleScanParameterGeneral |
25 | [5.1.0+] #GetBleScanParameterSmartDevice |
26 | [5.1.0+] #StartBleScanForGeneral |
27 | [5.1.0+] #StopBleScanForGeneral |
28 | [5.1.0+] #GetBleScanResultsForGeneral |
29 | [5.1.0+] #StartBleScanForPairedDevice |
30 | [5.1.0+] #StopBleScanForPairedDevice |
31 | [5.1.0+] #StartBleScanForSmartDevice |
32 | [5.1.0+] #StopBleScanForSmartDevice |
33 | [5.1.0+] #GetBleScanResultsForSmartDevice |
34 | [5.1.0+] #AcquireBleConnectionEvent |
35 ([5.0.0-5.0.2] 24) | [5.0.0+] #BleConnect |
36 | [5.1.0+] #BleOverrideConnection |
37 ([5.0.0-5.0.2] 25) | [5.0.0+] #BleDisconnect |
38 ([5.0.0-5.0.2] 26) | [5.0.0+] #BleGetConnectionState |
39 ([5.0.0-5.0.2] 27) | [5.0.0+] #BleGetGattClientConditionList |
40 ([5.0.0-5.0.2] 28) | [5.0.0+] #AcquireBlePairingEvent |
41 | [5.1.0+] BlePairDevice |
42 | [5.1.0+] BleUnpairDeviceOnBoth |
43 | [5.1.0+] BleUnpairDevice |
44 | [5.1.0+] BleGetPairedAddresses |
45 | [5.1.0+] AcquireBleServiceDiscoveryEvent |
46 ([5.0.0-5.0.2] 29) | [5.0.0+] #GetGattServices |
47 ([5.0.0-5.0.2] 30) | [5.0.0+] #GetGattService |
48 ([5.0.0-5.0.2] 31) | [5.0.0+] #GetGattIncludedServices |
49 ([5.0.0-5.0.2] 32) | [5.0.0+] #GetBelongingService |
50 ([5.0.0-5.0.2] 33) | [5.0.0+] #GetGattCharacteristics |
51 ([5.0.0-5.0.2] 34) | [5.0.0+] #GetGattDescriptors |
52 ([5.0.0-5.0.2] 35) | [5.0.0+] #AcquireBleMtuConfigEvent |
53 ([5.0.0-5.0.2] 36) | [5.0.0+] #ConfigureBleMtu |
54 ([5.0.0-5.0.2] 37) | [5.0.0+] #GetBleMtu |
55 ([5.0.0-5.0.2] 38) | [5.0.0+] #RegisterBleGattDataPath |
56 ([5.0.0-5.0.2] 39) | [5.0.0+] #UnregisterBleGattDataPath |
57 ([5.0.0-5.0.2] 40) | [5.0.0+] #RegisterAppletResourceUserId |
58 ([5.0.0-5.0.2] 41) | [5.0.0+] #UnregisterAppletResourceUserId |
59 ([5.0.0-5.0.2] 42) | [5.0.0+] #SetAppletResourceUserId |
60 | [8.0.0+] |
61 | [8.0.0+] |
62 | [9.0.0+] |
63 | [9.0.0+] |
64 | [10.0.0+] |
GetState
No input, returns an output #BtmState.
GetHostDeviceProperty
No input, returns an output #HostDeviceProperty.
AcquireDeviceConditionEvent
No input, returns an output Event handle with EventClearMode=1.
[3.0.0+] Now returns an additional output u8.
GetDeviceCondition
Takes a type-0x1A output buffer containing a 0x368-byte struct.
SetBurstMode
Takes an input Address and a bool, no output.
SetSlotMode
Takes a type-0x19 input buffer containing a #DeviceSlotModeList, no output.
SetBluetoothMode
Takes an input #BluetoothMode, no output.
SetWlanMode
Takes an input #WlanMode, no output.
AcquireDeviceInfoEvent
No input, returns an output Event handle with EventClearMode=1.
[3.0.0+] Now returns an additional output u8.
GetDeviceInfo
Takes a type-0x1A output buffer containing a #DeviceInfoList.
AddDeviceInfo
Takes an input #DeviceInfo, no output.
RemoveDeviceInfo
Takes an input Address, no output.
IncreaseDeviceInfoOrder
Takes an input Address, no output.
LlrNotify
Takes an input Address, no output.
[9.0.0+] Takes an input Address and a s32, no output.
EnableRadio
No input/output.
DisableRadio
No input/output.
HidDisconnect
Takes an input Address, no output.
HidSetRetransmissionMode
Takes an input Address and a type-0x19 input buffer containing a #ZeroRetransmissionList, no output.
AcquireAwakeReqEvent
No input, returns an output Event handle with EventClearMode=1.
[3.0.0+] Now returns an additional output u8.
AcquireLlrStateEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
IsLlrStarted
No input, returns an output bool.
EnableSlotSaving
Takes an input bool, no output.
ProtectDeviceInfo
Takes an input Address and a bool, no output.
AcquireBleScanEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
GetBleScanParameterGeneral
Takes an input u16, returns a BleAdvertisePacketParameter.
The u16 must be value 0x1 or 0xFFFF.
GetBleScanParameterSmartDevice
Takes an input u16, returns a GattAttributeUuid.
The u16 must be value 0x2. The first 4-bytes of output is always 0 since it's not set.
StartBleScanForGeneral
Takes a BleAdvertisePacketParameter, no output.
StopBleScanForGeneral
No input/output.
GetBleScanResultsForGeneral
Takes a type-0x6 output buffer containing an array of BleScanResult, returns an output u8 total_out.
The max array entries is 10.
StartBleScanForPaired
Takes a BleAdvertisePacketParameter, no output.
StopBleScanForPaired
No input/output.
StartBleScanForSmartDevice
Takes a GattAttributeUuid, no output.
StopBleScanForSmartDevice
No input/output.
GetBleScanResultsForSmartDevice
Takes a type-0x6 output buffer containing an array of BleScanResult, returns an output u8 total_out.
The max array entries is 10.
AcquireBleConnectionEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
BleConnect
Takes an input Address, no output.
An error is thrown if the Address is already connected (listed in the BleConnectionInfo from #BleGetConnectionState). An error is thrown if 4 devices are already connected.
BleOverrideConnection
Takes an input u32, no output.
The u32 is the same as the param for #BleDisconnect.
BleDisconnect
Takes an input u32, no output.
The u32 must match an Id in a BleConnectionInfo from #BleGetConnectionState (0xFFFFFFFF is invalid).
BleGetConnectionState
Takes a type-0xA output buffer containing an array of BleConnectionInfo, returns an output u8 total_out.
Other cmds which use this internally use arraycount=4.
BleGetGattClientConditionList
Takes a type-0x1A output buffer containing a 0x74-byte struct.
AcquireBlePairingEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
GetGattServices
Takes a type-0x6 output buffer containing an array of #GattService, an u32, returns an output u8 total_out.
The u32 is the same as the param for #BleDisconnect. The max array entries is 100.
GetGattService
Takes a type-0x1A output buffer containing a #GattService, an u32, a GattAttributeUuid, returns an output u8 total_out.
The u32 is the same as the param for #BleDisconnect.
Same as #GetGattServices except this only returns the #GattService which matches the input GattAttributeUuid.
GetGattIncludedServices
Takes a type-0x6 output buffer containing an array of #GattService, an u16, an u32, returns an output u8.
The u32 is the same as the param for #BleDisconnect. The max array entries is 100.
Same as #GetGattServices except this only returns #GattService entries where various checks pass with u16 fields.
The param for the output u8 is unused by the sysmodule, hence the output is always 0.
GetBelongingService
Takes a type-0x1A output buffer containing a #GattService, an u16, an u32, returns an output u8 total_out.
The u32 is the same as the param for #BleDisconnect.
This is similar to #GetGattIncludedServices except this only returns 1 #GattService.
GetGattCharacteristics
Takes a type-0x6 output buffer containing an array of #GattCharacteristic, an u16, an u32, returns an output u8 total_out.
The u32 is the same as the param for #BleDisconnect. The max array entries is 100.
GetGattDescriptors
Takes a type-0x6 output buffer containing an array of #GattDescriptor, an u16, an u32, returns an output u8 total_out.
The u32 is the same as the param for #BleDisconnect. The max array entries is 100.
AcquireBleMtuConfigEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
ConfigureBleMtu
Takes an u16, an u32, no output.
The u32 is the same as the param for #BleDisconnect.
GetBleMtu
Takes an u32, returns an output u16.
The u32 is the same as the param for #BleDisconnect.
RegisterBleGattDataPath
Takes a #BleDataPath, no output.
UnregisterBleGattDataPath
Takes a #BleDataPath, no output.
RegisterAppletResourceUserId
Takes an input u32 and an AppletResourceUserId, no output.
UnregisterAppletResourceUserId
Takes an input AppletResourceUserId, no output.
SetAppletResourceUserId
Takes an input AppletResourceUserId, no output.
Cmd60
No input, returns an output Event handle with EventClearMode=1.
Cmd61
Takes a 0x44-byte input struct, no output.
Cmd62
Takes an input bool, no output.
Cmd63
No input, returns an output bool.
Cmd64
No input/output.
btm:dbg
This is "nn::btm::IBtmDebug".
This has max_sessions 6. IPC is handled by 2 threads shared with all services.
Cmd | Name |
---|---|
0 | AcquireDiscoveryEvent |
1 | StartDiscovery |
2 | CancelDiscovery |
3 | GetDeviceProperty |
4 | CreateBond |
5 | CancelBond |
6 | SetTsiMode |
7 | GeneralTest |
8 | HidConnect |
9 | [5.0.0+] GeneralGet |
10 | [5.1.0+] GetGattClientDisconnectionReason |
11 | [5.1.0+] GetBleConnectionParameter |
12 | [5.1.0+] GetBleConnectionParameterRequest |
[3.0.0+] RegisterSystemEventForDiscovery now returns an output u8.
btm:sys
This is "nn::btm::IBtmSystem".
This has max_sessions 6. IPC is handled by 2 threads shared with all services.
Cmd | Name |
---|---|
0 | #GetCore |
GetCore
No input, returns an output #IBtmSystemCore.
IBtmSystemCore
This is "nn::btm::IBtmSystemCore".
Cmd | Name |
---|---|
0 | #StartGamepadPairing |
1 | #CancelGamepadPairing |
2 | #ClearGamepadPairingDatabase |
3 | #GetPairedGamepadCount |
4 | #EnableRadio |
5 | #DisableRadio |
6 | #GetRadioOnOff |
7 | [3.0.0+] #AcquireRadioEvent |
8 | [3.0.0+] #AcquireGamepadPairingEvent |
9 | [3.0.0+] #IsGamepadPairingStarted |
StartGamepadPairing
No input/output.
CancelGamepadPairing
No input/output.
ClearGamepadPairingDatabase
No input/output.
GetPairedGamepadCount
No input, returns an output u8.
EnableRadio
No input/output.
DisableRadio
No input/output.
GetRadioOnOff
No input, returns an output bool.
AcquireRadioEvent
No input, returns an output bool and handle.
AcquireGamepadPairingEvent
No input, returns an output bool and handle.
IsGamepadPairingStarted
No input, returns an output bool.
btm:u
This is "nn::btm::IBtmUser".
This was added with [5.0.0+].
This has max_sessions 6. IPC is handled by 2 threads shared with all services.
Cmd | Name |
---|---|
0 | GetCore |
GetCore
No input, returns an output #IBtmUserCore.
IBtmUserCore
This is "nn::btm::IBtmUserCore".
AcquireBleScanEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
sdknso will Abort if the output u8 is value 0.
GetBleScanFilterParameter
Takes an input u16, returns a BleAdvertisePacketParameter.
This is the same as #GetBleScanParameterGeneral.
GetBleScanFilterParameter2
Takes an input u16, returns a GattAttributeUuid.
This is the same as #GetBleScanParameterSmartDevice.
StartBleScanForGeneral
Takes a PID, a BleAdvertisePacketParameter, an AppletResourceUserId, no output.
This is similar to the btm cmd.
StopBleScanForGeneral
No input/output.
This is similar to the btm cmd.
GetBleScanResultsForGeneral
Takes a PID, a type-0x6 output buffer containing an array of BleScanResult, an AppletResourceUserId, returns an output u8 total_out.
This is similar to the btm cmd.
StartBleScanForPaired
Takes a PID, a BleAdvertisePacketParameter, an AppletResourceUserId, no output.
This is similar to the btm cmd.
StopBleScanForPaired
No input/output.
This is similar to the btm cmd.
StartBleScanForSmartDevice
Takes a PID, a GattAttributeUuid, an AppletResourceUserId, no output.
This is similar to the btm cmd.
StopBleScanForSmartDevice
No input/output.
This is similar to the btm cmd.
GetBleScanResultsForSmartDevice
Takes a PID, a type-0x6 output buffer containing an array of BleScanResult, an AppletResourceUserId, returns an output u8 total_out.
This is similar to the btm cmd.
AcquireBleConnectionEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
This is similar to the btm cmd.
sdknso will Abort if the output u8 is value 0.
BleConnect
Takes a PID, an Address, an AppletResourceUserId, no output.
This is similar to the btm cmd.
BleDisconnect
Takes an input u32, no output.
This is similar to the btm cmd.
BleGetConnectionState
Takes a PID, a type-0xA output buffer containing an array of BleConnectionInfo, an AppletResourceUserId, returns an output u8 total_out.
This is similar to the btm cmd.
AcquireBlePairingEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
This is similar to the btm cmd.
sdknso will Abort if the output u8 is value 0.
BlePairDevice
Takes an input BleAdvertisePacketParameter and an u32, no output.
The u32 is handled the same as BleDisconnect.
BleUnPairDevice
Takes an input BleAdvertisePacketParameter and an u32, no output.
The u32 is handled the same as BleDisconnect.
BleUnPairDevice2
Takes an input Address and a BleAdvertisePacketParameter, no output.
BleGetPairedDevices
Takes a type-0xA output buffer containing an array of Address, a BleAdvertisePacketParameter, returns an output u8 total_out.
The max array entries is 10.
AcquireBleServiceDiscoveryEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
sdknso will Abort if the output u8 is value 0.
GetGattServices
Takes a PID, a type-0x6 output buffer containing an array of #GattService, an u32, an AppletResourceUserId, returns an output u8 total_out.
The u32 is handled the same as BleDisconnect. The max array entries is 100.
GetGattService
Takes a PID, a type-0x1A output buffer containing a #GattService, an u32, a GattAttributeUuid, an AppletResourceUserId, returns an output u8 total_out.
The u32 is handled the same as BleDisconnect.
Same as GetGattServices except this only returns the #GattService which matches the input GattAttributeUuid.
GetGattIncludedServices
Takes a PID, a type-0x6 output buffer containing an array of #GattService, an u16, an u32, an AppletResourceUserId, returns an output u8.
The u32 is handled the same as BleDisconnect. The max array entries is 100.
Same as GetGattServices except this only returns #GattService entries where various checks pass with u16 fields.
The param for the output u8 is unused by the sysmodule, hence the output is always 0. However, a sdknso func which calls the nn::btm::* func for this expects this u8 to be set.
GetBelongingGattService
Takes a PID, a type-0x1A output buffer containing a #GattService, an u16, an u32, an AppletResourceUserId, returns an output u8 total_out.
The u32 is handled the same as BleDisconnect.
This is similar to GetGattIncludedServices except this only returns 1 #GattService.
GetGattCharacteristics
Takes a PID, a type-0x6 output buffer containing an array of #GattCharacteristic, an u16, an u32, an AppletResourceUserId, returns an output u8 total_out.
The u32 is handled the same as BleDisconnect. The max array entries is 100.
The u16 controls which #GattCharacteristic entries to return.
GetGattDescriptors
Takes a PID, a type-0x6 output buffer containing an array of #GattDescriptor, an u16, an u32, an AppletResourceUserId, returns an output u8 total_out.
The u32 is handled the same as BleDisconnect. The max array entries is 100.
The u16 controls which #GattDescriptor entries to return.
AcquireBleMtuConfigEvent
No input, returns an output u8 and an Event handle with EventClearMode=1.
sdknso will Abort if the output u8 is value 0.
ConfigureBleMtu
Takes a PID, an u16, an u32, an AppletResourceUserId, no output.
The u32 is handled the same as BleDisconnect.
sdknso will Abort if the user-specified u16 is <0x18 or >0x200.
GetBleMtu
Takes a PID, an u32, an AppletResourceUserId, returns an output u16.
The u32 is handled the same as BleDisconnect.
RegisterBleGattDataPath
Takes a PID, a #BleDataPath, an AppletResourceUserId, no output.
UnregisterBleGattDataPath
Takes a PID, a #BleDataPath, an AppletResourceUserId, no output.
BtmState
This is "nn::btm::BtmState". This is an u32 enum.
BluetoothMode
This is "nn::btm::BluetoothMode". This is an u32 enum.
WlanMode
This is "nn::btm::WlanMode". This is an u32 enum.
HostDeviceProperty
This is "nn::btm::HostDeviceProperty". This is a 0x2A-byte struct.
DeviceSlotModeList
This is "nn::btm::DeviceSlotModeList". This is a 0x64-byte struct.
DeviceInfoList
This is "nn::btm::DeviceInfoList". This is a 0x3C4-byte struct.
DeviceInfo
This is "nn::btm::DeviceInfo". This is a 0x60-byte struct.
ZeroRetransmissionList
This is "nn::btm::ZeroRetransmissionList". This is a 0x11-byte struct.
GattService
This is "nn::btm::user::GattService". This is a 0x24-byte struct.
Offset | Size | Description |
---|---|---|
0x0 | 0x4 | |
0x4 | 0x14 | GattAttributeUuid |
0x18 | 0x2 | |
0x1A | 0x4 | |
0x1E | 0x2 | |
0x20 | 0x1 | |
0x21 | 0x3 | Padding |
GattCharacteristic
This is "nn::btm::user::GattCharacteristic". This is a 0x24-byte struct.
GattDescriptor
This is "nn::btm::user::GattDescriptor". This is a 0x20-byte struct.
BleDataPath
This is "nn::btm::user::BleDataPath". This is a 0x18-byte struct with 4-byte alignment.
Offset | Size | Description |
---|---|---|
0x0 | 0x1 | |
0x1 | 0x3 | Padding |
0x4 | 0x14 | GattAttributeUuid |