Changes

no edit summary
Line 7: Line 7:     
This has max_sessions 30. IPC handling is done by the main-thread.
 
This has max_sessions 30. IPC handling is done by the main-thread.
  −
As of 10.x these services only support using Hid and BLE devices, other devices such as audio are not usable.
      
[11.0.0+] sdknso moved various functions/etc from "nn::bluetooth::" into "nn::bluetooth::hal::". This includes all functions exposing btdrv. These btdrv functions now automatically initialize the service if needed, the dedicated initialization function is now a stub since calling it is no longer needed. The internal "nn::bluetooth::user::" functions implementing [[#bt]] were moved to "nn::bluetooth::hal::user::", these are called by the the user-facing "nn::bluetooth::" functions.
 
[11.0.0+] sdknso moved various functions/etc from "nn::bluetooth::" into "nn::bluetooth::hal::". This includes all functions exposing btdrv. These btdrv functions now automatically initialize the service if needed, the dedicated initialization function is now a stub since calling it is no longer needed. The internal "nn::bluetooth::user::" functions implementing [[#bt]] were moved to "nn::bluetooth::hal::user::", these are called by the the user-facing "nn::bluetooth::" functions.
Line 216: Line 214:  
| 99 || [10.0.0+] [[#MoveToSecondaryPiconet]]
 
| 99 || [10.0.0+] [[#MoveToSecondaryPiconet]]
 
|-
 
|-
| 100 || [12.0.0+]
+
| 100 || [12.0.0+] [[#IsBluetoothEnabled]]
 +
|-
 +
| 101 || [15.0.0+] ForceEnableBluetooth
 +
|-
 +
| 102 || [15.0.0+] EnableBluetoothStub
 +
|-
 +
| 128 || [12.0.0+] [[#AcquireAudioEvent]]
 +
|-
 +
| 129 || [12.0.0+] [[#GetAudioEventInfo]]
 +
|-
 +
| 130 || [12.0.0+] [[#OpenAudioConnection]]
 +
|-
 +
| 131 || [12.0.0+] [[#CloseAudioConnection]]
 +
|-
 +
| 132 || [12.0.0+] [[#OpenAudioOut]]
 +
|-
 +
| 133 || [12.0.0+] [[#CloseAudioOut]]
 +
|-
 +
| 134 || [12.0.0+] [[#AcquireAudioOutStateChangedEvent]]
 
|-
 
|-
| 128 || [12.0.0+]
+
| 135 || [12.0.0+] [[#StartAudioOut]]
 
|-
 
|-
| 129 || [12.0.0+]
+
| 136 || [12.0.0+] [[#StopAudioOut]]
 
|-
 
|-
| 130 || [12.0.0+]
+
| 137 || [12.0.0+] [[#GetAudioOutState]]
 
|-
 
|-
| 131 || [12.0.0+]
+
| 138 || [12.0.0+] [[#GetAudioOutFeedingCodec]]
 
|-
 
|-
| 132 || [12.0.0+]
+
| 139 || [12.0.0+] [[#GetAudioOutFeedingParameter]]
 
|-
 
|-
| 133 || [12.0.0+]
+
| 140 || [12.0.0+] [[#AcquireAudioOutBufferAvailableEvent]]
 
|-
 
|-
| 134 || [12.0.0+]
+
| 141 || [12.0.0+] [[#SendAudioData]]
 
|-
 
|-
| 135 || [12.0.0+]
+
| 142 || [12.0.0+] [[#AcquireAudioControlInputStateChangedEvent]]
 
|-
 
|-
| 136 || [12.0.0+]
+
| 143 || [12.0.0+] [[#GetAudioControlInputState]]
 
|-
 
|-
| 137 || [12.0.0+]
+
| 144 || [12.0.0-13.2.1] [[#AcquireAudioConnectionStateChangedEvent]]
 
|-
 
|-
| 138 || [12.0.0+]
+
| 145 || [12.0.0-13.2.1] [[#GetConnectedAudioDevice]]
 
|-
 
|-
| 139 || [12.0.0+]
+
| 146 || [13.0.0+] [[#CloseAudioControlInput]]
 
|-
 
|-
| 140 || [12.0.0+]
+
| 147 || [13.0.0+] [[#RegisterAudioControlNotification]]
 
|-
 
|-
| 141 || [12.0.0+]
+
| 148 || [13.0.0+] [[#SendAudioControlPassthroughCommand]]
 
|-
 
|-
| 142 || [12.0.0+]
+
| 149 || [13.0.0+] [[#SendAudioControlSetAbsoluteVolumeCommand]]
 
|-
 
|-
| 143 || [12.0.0+]
+
| 150 || [14.0.0+] AcquireAudioSinkVolumeLocallyChangedEvent
 
|-
 
|-
| 144 || [12.0.0+]
+
| 151 || [14.0.0+] AcquireAudioSinkVolumeUpdateRequestCompletedEvent
 
|-
 
|-
| 145 || [12.0.0+]
+
| 152 || [14.0.0+] GetAudioSinkVolume
 +
|-
 +
| 153 || [14.0.0+] RequestUpdateAudioSinkVolume
 +
|-
 +
| 154 || [14.0.0+] IsAudioSinkVolumeSupported
 +
|-
 +
| 155 || [15.0.0+] IsAudioSinkVolumeSupported2
 
|-
 
|-
 
| 256 || [5.0.0+] [[#IsManufacturingMode]]
 
| 256 || [5.0.0+] [[#IsManufacturingMode]]
Line 277: Line 299:  
This is used by [[BTM_services|btm]], this should not be used by other processes.
 
This is used by [[BTM_services|btm]], this should not be used by other processes.
   −
This first initializes the funcptr table interfaces to the defaults (same as [[#DisableBluetooth]]). [[Settings_services#GetConfigurationId1|GetConfigurationId1]] is used, an error is thrown if the output string is empty, or if it matches "SDEV_00_01_00".
+
[1.0.0-11.0.1] This first initializes the funcptr table interfaces to the defaults (same as [[#DisableBluetooth]]). [[Settings_services#GetConfigurationId1|GetConfigurationId1]] is used, an error is thrown if the output string is empty, or if it matches "SDEV_00_01_00".
   −
If the flag for [[#IsManufacturingMode]] is 0, or if this cmd was already used where that flag was 1, an interface funcptr is called. This is passed a ptr to a table of funcptrs. The ret is converted to a Result and returned if needed.
+
If the flag for [[#IsManufacturingMode]] is 0, or if this cmd was already used where that flag was 1, an interface funcptr is called. This is passed a ptr to a table of funcptrs. The ret is converted to a Result and returned if needed. [12.0.0+] A normal func is called instead, with no params/ret. This cmd always returns 0.
   −
The funcptr does the following:
+
The above called func does the following:
* A func is called, which copies the input funcptr table into global state. These are used for writing events into [[#EventInfo]].
+
* [1.0.0-11.0.1] A func is called, which copies the input funcptr table into global state. These are used for writing events into [[#EventInfo]].
* A func is called 5 times with input param = [1-5]. This initializes the specified nn::bluetooth::CircularBuffer (sharedmem and internal).
+
* A func is called 5 times with input param = [1-5]. This initializes the specified nn::bluetooth::CircularBuffer (sharedmem and internal). [12.0.0+] This functionality is now inlined.
* A func is called for creating the "nn.bluetooth.HidMessageHandler" thread.
+
* A func is called for creating the "nn.bluetooth.HidMessageHandler" thread. [12.0.0+] This functionality is now inlined.
   −
Lastly, the Event is created and returned (which global state the Event is stored in depends on whether the code-path which calls the above funcptr was used).
+
Lastly, the Event is ([1.0.0-11.0.1] created and) returned (which global state the Event is stored in depends on whether the code-path which calls the above funcptr was used).
    
== EnableBluetooth ==
 
== EnableBluetooth ==
Line 293: Line 315:  
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
This first calls an interface funcptr, on failure 0xCA71 is returned.
+
[1.0.0-11.0.1] This first calls an interface funcptr, on failure 0xCA71 is returned.
   −
A global fixed [[#Address]] is copied to stack, this stack data is then overwritten with the output from [[Settings_services|GetBluetoothBdAddress]]. If GetBluetoothBdAddress fails, this will Abort. Then the same funcptr used by [[#SetAdapterProperty]] is called with this stack data, with [[#BluetoothPropertyType|type2]]. A converted error is returned if needed.
+
[1.0.0-11.0.1] A global fixed [[#Address]] is copied to stack, this stack data is then overwritten with the output from [[Settings_services|GetBluetoothBdAddress]]. If GetBluetoothBdAddress fails, this will Abort. Then the same funcptr used by [[#SetAdapterProperty]] is called with this stack data, with [[#BluetoothPropertyType|type2]]. A converted error is returned if needed.
   −
The last two bytes of the stack [[#Address]] are inverted (byteval = ~byteval), then the above funcptr is called with this for [[#BluetoothPropertyType|type3]]. Error conversion is handled if needed, then this returns 0.
+
[1.0.0-11.0.1] The last two bytes of the stack [[#Address]] are inverted (byteval = ~byteval), then the above funcptr is called with this for [[#BluetoothPropertyType|type3]]. Error conversion is handled if needed, then this returns 0.
   −
The first funcptr called above does the following:
+
The first funcptr called above does the following ([12.0.0+] this code is now inlined):
 
* Calls a GPIO func with param=0, [[SVC|sleeps]] for 10000000 nanoseconds, then calls the GPIO func again with param=1.
 
* Calls a GPIO func with param=0, [[SVC|sleeps]] for 10000000 nanoseconds, then calls the GPIO func again with param=1.
 +
* [12.0.0+] Calls a func to update an interface object ptr to use the enabled-object. A vfunc for various interface objects are called, with Result 0xCA71 being returned if the ret is non-zero (failure after the first interface object will trigger an Abort).
 +
* [12.0.0+] [[Settings_services|GetBluetoothBdAddress]] is used, on failure this will Abort. Then the same vfunc used by [[#SetAdapterProperty]] is called with the output from GetBluetoothBdAddress, with [[#AdapterPropertyType|type0]]. This will Abort on failure.
 +
* [12.0.0+] The last two bytes of the stack [[#Address]] are inverted (byteval = ~byteval), then the above vfunc is called with this for [[#AdapterPropertyType|type3]]. This will Abort on failure, otherwise 0 is returned.
 +
* [12.0.0+] Various code described below was moved into the above vfunc(s), etc.
 
* Calls a func for initializing the paired-devices table (empty).
 
* Calls a func for initializing the paired-devices table (empty).
 
* Calls a modified version of BSA_Boot, which handles BSA server initialization.
 
* Calls a modified version of BSA_Boot, which handles BSA server initialization.
Line 316: Line 342:  
* Uses SetValue with the param which was passed to this func.
 
* Uses SetValue with the param which was passed to this func.
 
* Does cleanup for the session object and exits the service.
 
* Does cleanup for the session object and exits the service.
 +
 +
[12.0.0+] The Enable vfunc called above for Audio does the following:
 +
* Calls a func which does the following:
 +
** Uses BSA to enable AV. Besides the callback, the only field in the passed struct which is set is <code>features</code>. This is ORRed to set bit0 for "remote control target", which with [13.0.0+] is only done if [[System_Settings|system-setting]] <code>bluetooth_debug!is_av_rc_tg</code> is set to true. With [14.0.0+] this is also ORRed with value 0xA (bit1/bit3) when [[System_Settings|system-setting]] <code>bluetooth_debug!is_av_rc_ct</code> is set to true (which is the case for [14.0.0+]).
 +
** Error handling + state setup is done.
 +
** Uses BSA to register AV twice, with the default input struct.
 +
** Error handling + state setup is done.
 +
* If an error occurred in a certain range, a [[#FatalReason|fatal]] is triggered and 0 is returned.
 +
* Otherwise when successful, state init is done then 0 is returned.
    
== DisableBluetooth ==
 
== DisableBluetooth ==
Line 322: Line 357:  
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
This calls an interface funcptr. On success, the funcs for updating the interface funcptr tables are called (same as [[#InitializeBluetooth]]). Then the converted ret is returned as needed.
+
[1.0.0-11.0.1] This calls an interface funcptr. On success, the funcs for updating the interface funcptr tables are called (same as [[#InitializeBluetooth]]). Then the converted ret is returned as needed.
 +
 
 +
* [12.0.0+] Vfuncs for various interface objects are called, with failure triggering an Abort in some cases.
 +
* [12.0.0+] Calls funcs to update interfaces object ptrs to use the disabled-object.
 +
* [12.0.0+] Calls the same GPIO func as [[#EnableBluetooth]] with param=0, then 0 is returned.
 +
* [12.0.0+] Various code described below was moved into the above vfunc(s), etc.
    
When bluetooth is already disabled, that funcptr just returns 0. Otherwise when it's already enabled, it does the following:
 
When bluetooth is already disabled, that funcptr just returns 0. Otherwise when it's already enabled, it does the following:
Line 374: Line 414:  
No input/output.
 
No input/output.
   −
[12.0.0+] Now takes a total of 0x10-bytes of input.
+
[12.0.0+] Takes an input BitFlagSet 32bit [[#ServiceFlag|services]] and s64 nanoseconds_duration, no output.
    
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
This starts Inquiry, the output data will be available via [[#GetEventInfo]]. Inquiry will automatically stop in 10.24 seconds.
+
This starts Inquiry, the output data will be available via [[#GetEventInfo]]. Inquiry will automatically stop in 10.24 seconds ([12.0.0+] calculated from the input duration instead).
 +
 
 +
[12.0.0+] When services is -1 the original defaults from pre-12.0.0 are used (besides duration). Otherwise, services is written into the parameter struct (masked with the all-allowed-BSA-services value), and the EventInfo for discovered devices are triggered when inquiry finishes instead of immediately.
    
== StopInquiry ==
 
== StopInquiry ==
Line 414: Line 456:     
The sysmodule impl for the funcptr used with this cmd only uses the [[#Address]] - this and hard-coded PIN "0000" are written into the parameter struct (and a size field for the PIN).
 
The sysmodule impl for the funcptr used with this cmd only uses the [[#Address]] - this and hard-coded PIN "0000" are written into the parameter struct (and a size field for the PIN).
 +
 +
[12.0.0+] The input [[#PinCode]] is now actually used and passed to BSA, instead of hard-coding the PIN.
    
== RespondToSspRequest ==
 
== RespondToSspRequest ==
 
Takes an input [[#Address]], a [[#BluetoothSspVariant]], a bool, an u32, no output.
 
Takes an input [[#Address]], a [[#BluetoothSspVariant]], a bool, an u32, no output.
   −
[12.0.0+] Now takes a total of 0x10-bytes of input instead of 0xC-bytes.
+
[12.0.0+] Takes an input [[#Address]], a bool, a [[#BluetoothSspVariant]], an u32, no output.
    
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
The sysmodule impl for the funcptr used with this cmd only uses the [[#Address]] and bool - the parameter struct size is only 0x7-bytes. The bool indicates whether the request is accepted.
+
The sysmodule impl for the funcptr/vfunc used with this cmd only uses the [[#Address]] and bool - the parameter struct size is only 0x7-bytes. The bool indicates whether the request is accepted.
    
== GetEventInfo ==
 
== GetEventInfo ==
Line 428: Line 472:     
This copies 0x400-bytes from state to the output buffer, copies the [[#EventType]] from state to output, and signals an event.
 
This copies 0x400-bytes from state to the output buffer, copies the [[#EventType]] from state to output, and signals an event.
 +
 +
[12.0.0+] Mutex locking is now used, with the code prior to the event-signal. If a size field in state is 0, writing the output [[#EventType]]/buffer is skipped. Otherwise, the size field is reset to 0, the [[#EventType]] from state is copied to output, and the original size field is used to memcpy to the output buffer from state.
    
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
Line 505: Line 551:     
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
 +
 +
[12.0.0+] If [[Settings_services#BluetoothDevicesSettings|TrustedServices]] is 0, value 0x100000 is used. When bit20 is set, HID is initialized for this device, otherwise when bitmask 0xC0000 is set (<code>if((TrustedServices & 0xC0000) != 0)</code>) [[#OpenAudioConnection|audio]] is initialized for this device.
    
== GetPairedDeviceInfo ==
 
== GetPairedDeviceInfo ==
Line 520: Line 568:     
This copies 0x480-bytes from state to the output buffer. [[#HidEventType]] is set to: stateval!=0 ? 7 : 0. Once finished, this signals an event.
 
This copies 0x480-bytes from state to the output buffer. [[#HidEventType]] is set to: stateval!=0 ? 7 : 0. Once finished, this signals an event.
 +
 +
[12.0.0+] Mutex locking is now used, with the code prior to the event-signal. If a size field in state is 0, writing the output [[#HidEventType]]/buffer is skipped. Otherwise, the size field is reset to 0, the [[#HidEventType]] from state is copied to output, and the original size field is used to memcpy to the output buffer from state.
    
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
 +
 +
See [[#HidEventInfo]].
    
== SetTsi ==
 
== SetTsi ==
Line 528: Line 580:  
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
The response will be available via [[#GetHidEventInfo]].
+
The response will be available via [[#GetHidEventInfo]] ([12.0.0+] [[#GetEventInfo]]).
    
This uses a BSA extension.
 
This uses a BSA extension.
Line 543: Line 595:  
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
The response will be available via [[#GetHidEventInfo]].
+
The response will be available via [[#GetHidEventInfo]] ([12.0.0+] [[#GetEventInfo]]).
    
This uses a BSA extension.
 
This uses a BSA extension.
Line 556: Line 608:  
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
The response will be available via [[#GetHidEventInfo]].
+
The response will be available via [[#GetHidEventInfo]] ([12.0.0+] [[#GetEventInfo]]).
    
This uses a BSA extension (message 0x8CF).
 
This uses a BSA extension (message 0x8CF).
Line 636: Line 688:  
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
   −
The output data will be available via [[#GetHidEventInfo]].
+
The output data will be available via [[#GetHidEventInfo]] ([12.0.0+] [[#GetEventInfo]]).
    
== GetChannelMap ==
 
== GetChannelMap ==
Line 759: Line 811:     
== ConnectGattServer ==
 
== ConnectGattServer ==
Takes an input u8, an [[#Address]], a bool, an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
+
Takes an input u8 client_if, an [[#Address]], a bool, an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
    
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
 +
 +
The input bool and AppletResourceUserId are unused.
 +
 +
The is_direct field passed to BSA is value 1.
    
== CancelConnectGattServer ==
 
== CancelConnectGattServer ==
Line 912: Line 968:  
== SetBleScanParameter ==
 
== SetBleScanParameter ==
 
Takes two input u16s, no output.
 
Takes two input u16s, no output.
 +
 +
The first u16 is scan_interval, the second u16 is scan_window.
    
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
Line 918: Line 976:  
Takes an input [[#Address]], no output.
 
Takes an input [[#Address]], no output.
   −
The response will be available via [[#GetHidEventInfo]].
+
The response will be available via [[#GetHidEventInfo]] ([12.0.0+] [[#GetEventInfo]]).
    
This uses a BSA extension (message 0x8D0).
 
This uses a BSA extension (message 0x8D0).
   −
== IsManufacturingMode ==
+
== IsBluetoothEnabled ==
 
No input, returns an output bool.
 
No input, returns an output bool.
   −
sdknso will Abort if this fails, the bool is returned instead of a Result. sdknso exposes this under "nn::bluetooth::debug::".
+
== AcquireAudioEvent ==
 +
No input, returns an output Event handle.
   −
This calls the same two funcs as various other cmds etc. This writes the bool returned by the second func to output, then returns 0. The second func loads the bool from [[System_Settings|system-setting]] "bluetooth_debug!skip_boot". The first func is the same as the second one, except it writes the bool into global state.
+
sdknso uses an user-specified EventClearMode.
   −
This is used by [[BTM_services|btm]].
+
This just gets a previously-initialized Event from global state, [[#IsManufacturingMode]] is used to select which Event to use.
 +
 
 +
== GetAudioEventInfo ==
 +
Takes a type-0xA output buffer, returns an output [[#AudioEventType]].
 +
 
 +
This is essentially the same as the other [12.0.0+] Get*EventInfo cmds, however in this case the output type is set to value 0 when no event is available.
 +
 
 +
See [[#AudioEventInfo]].
 +
 
 +
== OpenAudioConnection ==
 +
Takes an input [[#Address]], no output.
 +
 
 +
This goes through state and eventually uses BSA to open an AV connection. The input struct has the RC flag set to true. sec_mask is set to require authentication and encryption.
 +
 
 +
== CloseAudioConnection ==
 +
Takes an input [[#Address]], no output.
 +
 
 +
This goes through state and eventually uses BSA to close an AV connection.
 +
 
 +
== OpenAudioOut ==
 +
Takes an input [[#Address]], returns an output u32 audio_handle.
   −
== EmulateBluetoothCrash ==
+
== CloseAudioOut ==
Takes an input [[#FatalReason]], no output.
+
Takes an input u32 [[#OpenAudioOut|audio_handle]], no output.
   −
sdknso masks the FatalReason with an u16-mask before passing it to the cmd. sdknso exposes this under "nn::bluetooth::debug::".
+
== AcquireAudioOutStateChangedEvent ==
 +
Takes an input u32 [[#OpenAudioOut|audio_handle]], returns an output Event handle.
   −
This writes data into a CircularBuffer (seperate from sharedmem) with type=0x29, where the data is an u16 determined using the input [[#FatalReason]]. This is only done if a state field is value 0x3, after calling the func for this the field is set to value 0. The thread handling that sent message then converts the u16 back into a [[#FatalReason]] for writing into [[#EventInfo]].
+
sdknso uses an user-specified EventClearMode.
   −
== GetBleChannelMap ==
+
== StartAudioOut ==
Takes a type-0x16 output buffer containing a [[#ChannelMapList]].
+
Takes an input u32 [[#OpenAudioOut|audio_handle]], a [[#PcmParameter]], a nn::TimeSpan latency, returns an output nn::TimeSpan latency and u64.
   −
[12.0.0+] Takes two type-0xA output buffers, returns an output s32. The first buffer contains an array of [[#Address]], the second buffer contains an array of BitFlagSet with [[#LeChannel]] and bit-count=40.
+
This eventually uses BSA to start an AV stream. The codec is "Raw PCM". Synchronous feeding mode is used.
   −
= bt =
+
== StopAudioOut ==
This is "nn::bluetooth::IBluetoothUser".
+
Takes an input u32 [[#OpenAudioOut|audio_handle]], no output.
   −
This has max_sessions 30. IPC handling is done by the main-thread.
+
This eventually uses BSA to stop an AV stream. The pause flag is set to false.
   −
{| class="wikitable" border="1"
+
== GetAudioOutState ==
|-
+
Takes an input u32 [[#OpenAudioOut|audio_handle]], returns an output [[#AudioOutState]].
! Cmd || Name
  −
|-
  −
| 0 || [[#LeClientReadCharacteristic]]
  −
|-
  −
| 1 || [[#LeClientReadDescriptor]]
  −
|-
  −
| 2 || [[#LeClientWriteCharacteristic]]
  −
|-
  −
| 3 || [[#LeClientWriteDescriptor]]
  −
|-
  −
| 4 || [[#LeClientRegisterNotification]]
  −
|-
  −
| 5 || [[#LeClientDeregisterNotification]]
  −
|-
  −
| 6 || [[#SetLeResponse]]
  −
|-
  −
| 7 || [[#LeSendIndication]]
  −
|-
  −
| 8 || [[#GetLeEventInfo]]
  −
|-
  −
| 9 || [[#RegisterBleEvent]]
  −
|}
     −
== LeClientReadCharacteristic ==
+
== GetAudioOutFeedingCodec ==
Takes a PID, a bool, an u8, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
+
Takes an input u32 [[#OpenAudioOut|audio_handle]], returns an output [[#AudioCodec]].
   −
This is essentially the same as [[#ReadGattCharacteristic]], the AppletResourceUserId is unused.
+
== GetAudioOutFeedingParameter ==
 +
Takes an input u32 [[#OpenAudioOut|audio_handle]], returns an output [[#PcmParameter]].
   −
== LeClientReadDescriptor ==
+
== AcquireAudioOutBufferAvailableEvent ==
Takes a PID, a bool, an u8, an u32, a [[#GattId]], a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
+
Takes an input u32 [[#OpenAudioOut|audio_handle]], returns an output Event handle.
   −
This is essentially the same as [[#ReadGattDescriptor]], the AppletResourceUserId is unused.
+
sdknso uses an user-specified EventClearMode.
   −
== LeClientWriteCharacteristic ==
+
This gets an Event which was previously initialized.
Takes a PID, a type-0x9 input buffer, a bool, an u8, a bool, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
     −
This is essentially the same as [[#WriteGattCharacteristic]], the AppletResourceUserId is unused.
+
== SendAudioData ==
 +
Takes an input u32 [[#OpenAudioOut|audio_handle]], a type-0x9 input buffer, returns an output u64 transferred_size.
   −
== LeClientWriteDescriptor ==
+
This eventually uses BSA to send the specified buffer to the required UIPC channel. If transferred_size doesn't match the buffer size, error 0x177A71 is returned. transferred_size is always either 0 (error occured) or the buffer size.
Takes a PID, a type-0x9 input buffer, a bool, an u8, an u32, a [[#GattId]], a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
     −
This is essentially the same as [[#WriteGattDescriptor]], the AppletResourceUserId is unused.
+
== AcquireAudioControlInputStateChangedEvent ==
 +
No input, returns an output Event handle.
 +
 
 +
sdknso uses an user-specified EventClearMode.
 +
 
 +
This gets an Event which was previously initialized.
   −
== LeClientRegisterNotification ==
+
== GetAudioControlInputState ==
Takes a PID, an input bool, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
+
Takes a type-0xA output buffer containing an array of [[#AudioControlButtonState]], returns an output s32 total_out.
   −
This is essentially the same as [[#RegisterGattNotification]], the AppletResourceUserId is unused.
+
A maximum of 0xF entries can be returned.
   −
== LeClientDeregisterNotification ==
+
== AcquireAudioConnectionStateChangedEvent ==
Takes a PID, an input bool, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
+
No input, returns an output Event handle.
   −
This is essentially the same as [[#UnregisterGattNotification]], the AppletResourceUserId is unused.
+
sdknso uses an user-specified EventClearMode.
   −
== SetLeResponse ==
+
This gets an Event which was previously initialized.
Takes a PID, a type-0x9 input buffer, an u8, a [[#GattAttributeUuid]], a [[#GattAttributeUuid]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
     −
The AppletResourceUserId is unused.
+
== GetConnectedAudioDevice ==
 +
Takes a type-0xA output buffer containing an array of [[#Address]], returns an output s32 total_out.
   −
The buffer size must be <=0x258.
+
A maximum of 0x8 entries can be returned.
   −
== LeSendIndication ==
+
== CloseAudioControlInput ==
Takes a PID, a type-0x9 input buffer, an u8, a bool, a [[#GattAttributeUuid]], a [[#GattAttributeUuid]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
+
Takes an input [[#Address]], no output.
   −
The AppletResourceUserId is unused.
+
This uses the BSA AV API to close the AVRCP connection.
   −
The buffer size used internally is clamped to max size 0x258.
+
== RegisterAudioControlNotification ==
 +
Takes an input [[#Address]] and an u32 [[#AvrcEventType]], no output.
   −
== GetLeEventInfo ==
+
This uses the BSA AV API to send a vendor control command: ctype=0x3, label={counter which is incremented}, length=0x9, data=[0x31, 0x00, 0x00, 0x05, {u8 [[#AvrcEventType]]}, {rest is zeros}].
Takes a PID, a type-0xA output buffer, an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], returns an output [[#BleEventType]].
     −
This is identical to [[#GetLeHidEventInfo]] except different state is used. The AppletResourceUserId is unused. See [[#LeEventInfo]] for the output buffer.
+
This does nothing since BSA requires [[#EnableBluetooth|features]] bit1 and bit3 to be set in order to use this.
   −
== RegisterBleEvent ==
+
== SendAudioControlPassthroughCommand ==
Takes a PID, an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], returns an output Event handle with EventClearMode=1.
+
Takes an input [[#Address]], an u32 [[#AvrcOperationId]], an u32 [[#AvrcStateType]], no output.
   −
This is identical to [[#RegisterBleHidEvent]] except different Event state is used. The AppletResourceUserId is unused.
+
This uses the BSA AV API to send a remote control command: label={counter which is incremented}, rc_id=[[#AvrcOperationId]], key_state=[[#AvrcStateType]].
   −
= BluetoothPropertyType =
+
This does nothing since BSA requires [[#EnableBluetooth|features]] bit1 to be set in order to use this.
This is u32 enum "nn::bluetooth::BluetoothPropertyType".
     −
The sysmodule will Abort if the input type is unavailable / not recognized.
+
== SendAudioControlSetAbsoluteVolumeCommand ==
 +
Takes an input [[#Address]] and a s32, no output.
   −
{| class="wikitable" border="1"
+
This uses the BSA AV API to send a vendor control command: ctype=0x0, label={counter which is incremented}, length=0x5, data=[0x50, 0x00, 0x00, 0x01, {input s32 value written as an u8}].
|-
+
 
!  Value
+
See [[#RegisterAudioControlNotification]] regarding the usage requirement.
!  Description
  −
!  Buffer contents
  −
|-
  −
| 1 || Name || String, max length 0xF8 excluding NUL-terminator.
  −
|-
  −
| 2 || Address || [[#Address]]
  −
|-
  −
| 3 || || Only available with [[#SetAdapterProperty]]. Unknown, [[#Address]]. The default is the same as type2, with the last two bytes inverted.
  −
This uses a BSA extension (message 0x8CE), the message handler which is used here uses HCI vendor command 0xFD98 with param_len=0x7: u8 param+0 = {whether the [[#Address]] is non-zero}, +1 6-bytes = {[[#Address]] with byte-order swapped}.
  −
|-
  −
| 5 || || 3-bytes, Class of Device.
  −
|-
  −
| 6 || || 1-byte, FeatureSet. The default is value 0x68.
  −
|}
     −
= TransportType =
+
== IsManufacturingMode ==
This is u32 enum "nn::bluetooth::TransportType".
+
No input, returns an output bool.
   −
= BluetoothSspVariant =
+
sdknso will Abort if this fails, the bool is returned instead of a Result. sdknso exposes this under "nn::bluetooth::debug::".
This is u8 enum "nn::bluetooth::BluetoothSspVariant".
     −
= EventType =
+
This calls the same two funcs as various other cmds etc. This writes the bool returned by the second func to output, then returns 0. The second func loads the bool from [[System_Settings|system-setting]] "bluetooth_debug!skip_boot". The first func is the same as the second one, except it writes the bool into global state. [12.0.0+] These two funcs now additionally load [[System_Settings|system-setting]] "bluetooth_config!skip_boot", which is ORRed with the first setting, then that's used for storing in state / returning the value.
This is u32 enum "nn::bluetooth::EventType".
     −
{| class="wikitable" border="1"
+
This is used by [[BTM_services|btm]].
|-
+
 
!  Value
+
== EmulateBluetoothCrash ==
!  Name
+
Takes an input [[#FatalReason]], no output.
!  Description
+
 
 +
sdknso masks the FatalReason with an u16-mask before passing it to the cmd. sdknso exposes this under "nn::bluetooth::debug::".
 +
 
 +
This writes data into a CircularBuffer (seperate from sharedmem) with type=0x29, where the data is an u16 determined using the input [[#FatalReason]]. This is only done if a state field is value 0x3, after calling the func for this the field is set to value 0. The thread handling that sent message then converts the u16 back into a [[#FatalReason]] for writing into [[#EventInfo]].
 +
 
 +
== GetBleChannelMap ==
 +
Takes a type-0x16 output buffer containing a [[#ChannelMapList]].
 +
 
 +
[12.0.0+] Takes two type-0xA output buffers, returns an output s32. The first buffer contains an array of [[#Address]], the second buffer contains an array of BitFlagSet with [[#LeChannel]] and bit-count=40.
 +
 
 +
= bt =
 +
This is "nn::bluetooth::IBluetoothUser".
 +
 
 +
This has max_sessions 30. IPC handling is done by the main-thread.
 +
 
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0 || || The funcptr which writes the data into state for this event is not called (only checked on [10.0.0]).
+
! Cmd || Name
 
|-
 
|-
| 3 || || New device found during Inquiry.
+
| 0 || [[#LeClientReadCharacteristic]]
 
|-
 
|-
| 4 || || Inquiry status changed.
+
| 1 || [[#LeClientReadDescriptor]]
 
|-
 
|-
| 5 || || Triggered by BSA_SEC_PIN_REQ_EVT: PIN code request for pairing.
+
| 2 || [[#LeClientWriteCharacteristic]]
 
|-
 
|-
| 6 || || Triggered by BSA_SEC_SP_CFM_REQ_EVT/BSA_SEC_SP_KEY_NOTIF_EVT: SSP confirm request / SSP passkey notification.
+
| 3 || [[#LeClientWriteDescriptor]]
 
|-
 
|-
| 7 || || Connection
+
| 4 || [[#LeClientRegisterNotification]]
 
|-
 
|-
| 13 || || BluetoothCrash. Triggered by [[#EmulateBluetoothCrash]] and BSA_MGT_DISCONNECT_EVT.
+
| 5 || [[#LeClientDeregisterNotification]]
|}
  −
 
  −
= ConnectionEventType =
  −
This is the event value in [[#EventInfo]] when [[#EventType]] is type7.
  −
 
  −
{| class="wikitable" border="1"
   
|-
 
|-
!  Value
+
| 6 || [[#SetLeResponse]]
!  Name
  −
!  Description
   
|-
 
|-
| 0 || || Connection status.
+
| 7 || [[#LeSendIndication]]
 
|-
 
|-
| 1 || || Triggered by BSA_SEC_SP_CFM_REQ_EVT: SSP confirm request.
+
| 8 || [[#GetLeEventInfo]]
 
|-
 
|-
| 2 || || Triggered by BSA_SEC_SUSPENDED_EVT: ACL Link is now Suspended.
+
| 9 || [[#RegisterBleEvent]]
 
|}
 
|}
   −
= BluetoothHhReportType =
+
== LeClientReadCharacteristic ==
This is u32 enum "nn::bluetooth::BluetoothHhReportType".
+
Takes a PID, a bool, an u8, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
 +
 
 +
This is essentially the same as [[#ReadGattCharacteristic]], the AppletResourceUserId is unused.
 +
 
 +
== LeClientReadDescriptor ==
 +
Takes a PID, a bool, an u8, an u32, a [[#GattId]], a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
   −
Bit0-1 directly control the HID bluetooth transaction report-type value. Bit2-3: these directly control the Parameter Reserved field for SetReport, for GetReport these control the Parameter Reserved and Size bits.
+
This is essentially the same as [[#ReadGattDescriptor]], the AppletResourceUserId is unused.
   −
{| class="wikitable" border="1"
+
== LeClientWriteCharacteristic ==
|-
+
Takes a PID, a type-0x9 input buffer, a bool, an u8, a bool, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
!  Value
  −
!  Description
  −
|-
  −
| 0 || Other
  −
|-
  −
| 1 || Input
  −
|-
  −
| 2 || Output
  −
|-
  −
| 3 || Feature
  −
|}
     −
= HidEventType =
+
This is essentially the same as [[#WriteGattCharacteristic]], the AppletResourceUserId is unused.
This is u32 enum "nn::bluetooth::HidEventType".
     −
{| class="wikitable" border="1"
+
== LeClientWriteDescriptor ==
|-
+
Takes a PID, a type-0x9 input buffer, a bool, an u8, an u32, a [[#GattId]], a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
!  Value
  −
!  Name
  −
!  Description
  −
|-
  −
| 0 || || Connection. Only used with [[#GetHidEventInfo]].
  −
|-
  −
| 4 || || DATA report on the Interrupt channel.
  −
|-
  −
| 7 || || Response for extensions. Only used with [[#GetHidEventInfo]].
  −
|-
  −
| 8 || || Response to SET_REPORT.
  −
|-
  −
| 9 || || Response to GET_REPORT.
  −
|}
     −
= BleEventType =
+
This is essentially the same as [[#WriteGattDescriptor]], the AppletResourceUserId is unused.
This is u32 enum "nn::bluetooth::BleEventType".
     −
= FatalReason =
+
== LeClientRegisterNotification ==
This is u32 enum "nn::bluetooth::FatalReason".
+
Takes a PID, an input bool, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
   −
This determines the u16 data to write into the CircularBuffer. [[#EmulateBluetoothCrash]] handles values outside of 1-2 the same as value 3.
+
This is essentially the same as [[#RegisterGattNotification]], the AppletResourceUserId is unused.
   −
{| class="wikitable" border="1"
+
== LeClientDeregisterNotification ==
|-
+
Takes a PID, an input bool, an u32, a [[#GattId]], a [[#GattId]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
!  Value
  −
!  Description
  −
|-
  −
| 0 || Only for [[#EventInfo]]: invalid.
  −
|-
  −
| 1 || u16 data = 0x850. Can only be triggered by [[#EmulateBluetoothCrash]], not triggered by the sysmodule otherwise.
  −
|-
  −
| 2 || u16 data = 0x851. HCI command timeout.
  −
|-
  −
| 3 || u16 data = 0x852. HCI event HCI_Hardware_Error occurred.
  −
|-
  −
| 7 || Only for [[#EventInfo]]: triggered after enabling bluetooth, when a global state field is value 4 or 2.
  −
|}
     −
= AdapterProperty =
+
This is essentially the same as [[#UnregisterGattNotification]], the AppletResourceUserId is unused.
This is "nn::bluetooth::AdapterProperty". This is a 0x103-byte struct.
     −
{| class="wikitable" border="1"
+
== SetLeResponse ==
|-
+
Takes a PID, a type-0x9 input buffer, an u8, a [[#GattAttributeUuid]], a [[#GattAttributeUuid]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
! Offset
  −
! Size
  −
! Description
  −
|-
  −
| 0x0 || 0x6 || Same as the data for [[#BluetoothPropertyType]] type2.
  −
|-
  −
| 0x6 || 0x3 || Same as the data for [[#BluetoothPropertyType]] type5.
  −
|-
  −
| 0x9 || 0xF9 || Same as the data for [[#BluetoothPropertyType]] type1 (last byte is not initialized).
  −
|-
  −
| 0x102 || 0x1 || Set to hard-coded value 0x68 (same as the data for [[#BluetoothPropertyType]] type6).
  −
|}
     −
= AdapterPropertySet =
+
The AppletResourceUserId is unused.
This is "nn::bluetooth::hal::AdapterPropertySet".
     −
= Address =
+
The buffer size must be <=0x258.
This is "nn::bluetooth::Address". This is a 0x6-byte struct with 1-byte alignment.
     −
= EventInfo =
+
== LeSendIndication ==
This is the output buffer for [[#GetEventInfo]]. The data stored here depends on the [[#EventType]].
+
Takes a PID, a type-0x9 input buffer, an u8, a bool, a [[#GattAttributeUuid]], a [[#GattAttributeUuid]], an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], no output.
   −
[[#EventType|Type0]]:
+
The AppletResourceUserId is unused.
   −
{| class="wikitable" border="1"
+
The buffer size used internally is clamped to max size 0x258.
|-
+
 
! Offset
+
== GetLeEventInfo ==
! Size
+
Takes a PID, a type-0xA output buffer, an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], returns an output [[#BleEventType]].
! Description
+
 
|-
+
This is identical to [[#GetLeHidEventInfo]] except different state is used. The AppletResourceUserId is unused. See [[#LeEventInfo]] for the output buffer.
| 0x0 || 0x4 ||
+
 
|}
+
== RegisterBleEvent ==
 +
Takes a PID, an [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], returns an output Event handle with EventClearMode=1.
 +
 
 +
This is identical to [[#RegisterBleHidEvent]] except different Event state is used. The AppletResourceUserId is unused.
 +
 
 +
= BluetoothPropertyType =
 +
This is u32 enum "nn::bluetooth::BluetoothPropertyType".
   −
[[#EventType|Type3]]:
+
The sysmodule will Abort if the input type is unavailable / not recognized.
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset
+
! Value
! Size
+
! Description
! Description
+
! Buffer contents
 
|-
 
|-
| 0x0 || 0xF9 || Device name, NUL-terminated string.
+
| 1 || Name || String, max length 0xF8 excluding NUL-terminator.
 
|-
 
|-
| 0xF9 || 0x6 || Device [[#Address|address]].
+
| 2 || Address || [[#Address]]
 
|-
 
|-
| 0xFF || 0x10 || Reserved
+
| 3 || || Only available with [[#SetAdapterProperty]]. Unknown, [[#Address]]. The default is the same as type2, with the last two bytes inverted.
 +
This uses a BSA extension (message 0x8CE), the message handler which is used here uses HCI vendor command 0xFD98 with param_len=0x7: u8 param+0 = {whether the [[#Address]] is non-zero}, +1 6-bytes = {[[#Address]] with byte-order swapped}.
 
|-
 
|-
| 0x10F || 0x3 || Class of Device.
+
| 5 || || 3-bytes, Class of Device.
 
|-
 
|-
| 0x112 || 0x4 || Set to fixed value u32 0x1.
+
| 6 || || 1-byte, FeatureSet. The default is value 0x68.
 +
|}
 +
 
 +
= AdapterPropertyType =
 +
This is u32 enum "nn::bluetooth::hal::AdapterPropertyType".
 +
 
 +
The sysmodule will Abort if the input type is unavailable / not recognized.
 +
 
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0x116 || 0xFA || Reserved
+
!  Value
|-
+
!  Description
| 0x210 || 0x5C || Reserved
+
!  Data contents
 
|-
 
|-
| 0x26C || 0xF9 || Device name, NUL-terminated string. Same as name above, except starting at index 1.
+
| 0 || Address || [[#Address]]
 
|-
 
|-
| 0x365 || 0x4 || s32 RSSI
+
| 1 || Name || String, max length 0xF8 excluding NUL-terminator.
 
|-
 
|-
| 0x369 || 0x4 || Two bytes which are the same as name[11-12].
+
| 2 || || 3-bytes, Class of Device.
 
|-
 
|-
| 0x36D || 0x10 || Reserved
+
| 3 || || Only available with [[#SetAdapterProperty]]. Same as [[#BluetoothPropertyType]] type3.
 
|}
 
|}
   −
[[#EventType|Type4]]:
+
= TransportType =
 +
This is u32 enum "nn::bluetooth::TransportType".
   −
{| class="wikitable" border="1"
+
= BluetoothSspVariant =
|-
+
This is u8 enum "nn::bluetooth::BluetoothSspVariant". [12.0.0+] This is u32 enum "nn::bluetooth::hal::BluetoothSspVariant".
! Offset
  −
! Size
  −
! Description
  −
|-
  −
| 0x0 || 0x4 || Status: 0 = stopped, 1 = started.
  −
|}
     −
[[#EventType|Type5]]:
+
= EventType =
 +
This is u32 enum "nn::bluetooth::EventType".
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset
+
! Value
! Size
+
! Name
! Description
+
! Description
 
|-
 
|-
| 0x0 || 0x6 || Device [[#Address|address]].
+
| [1.0.0-11.0.1] 0 || || The funcptr which writes the data into state for this event is not called (only checked on [10.0.0]).
 
|-
 
|-
| 0x6 || 0xF9 || Device name, NUL-terminated string.
+
| 0 ([1.0.0-11.0.1] 3) || || New device found during Inquiry.
 
|-
 
|-
| 0xFF || 0x3 || Class of Device.
+
| 1 ([1.0.0-11.0.1] 4) || || Inquiry status changed.
|}
  −
 
  −
[[#EventType|Type6]]:
  −
 
  −
{| class="wikitable" border="1"
   
|-
 
|-
! Offset
+
| 2 ([1.0.0-11.0.1] 5) || || Triggered by BSA_SEC_PIN_REQ_EVT: PIN code request for pairing.
! Size
  −
! Description
   
|-
 
|-
| 0x0 || 0x6 || Device [[#Address|address]].
+
| 3 ([1.0.0-11.0.1] 6) || || Triggered by BSA_SEC_SP_CFM_REQ_EVT/BSA_SEC_SP_KEY_NOTIF_EVT: SSP confirm request / SSP passkey notification.
 +
|-
 +
| 4 ([1.0.0-11.0.1] 7) || || Connection
 +
|-
 +
| 5 || || [12.0.0+] [[#SetTsi|Tsi]]
 
|-
 
|-
| 0x6 || 0xF9 || Device name, NUL-terminated string.
+
| 6 || || [12.0.0+] [[#EnableBurstMode|BurstMode]]
 
|-
 
|-
| 0xFF || 0x3 || Class of Device.
+
| 7 || || [12.0.0+] [[#SetZeroRetransmission]]
 
|-
 
|-
| 0x102 || 0x2 || Padding
+
| 8 || || [12.0.0+] [[#GetPendingConnections]]
 
|-
 
|-
| 0x104 || 0x4 || 0 = SSP confirm request, 3 = SSP passkey notification.
+
| 9 || || [12.0.0+] [[#MoveToSecondaryPiconet]]
 
|-
 
|-
| 0x108 || 0x4 || s32 Passkey, only set when the above field is value 3.
+
| 10 ([1.0.0-11.0.1] 13) || || BluetoothCrash. Triggered by [[#EmulateBluetoothCrash]] and BSA_MGT_DISCONNECT_EVT.
 
|}
 
|}
   −
[[#EventType|Type7]]:
+
= ConnectionEventType =
 +
This is the event value in [[#EventInfo]] when [[#EventType]] is type4 ([1.0.0-11.0.1] type7).
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset
+
! Value
! Size
+
! Name
! Description
+
! Description
 
|-
 
|-
| 0x0 || 0x4 || Status, always 0 except with [[#ConnectionEventType|event0]]: 2 = ACL Link is now Resumed (BSA_SEC_RESUMED_EVT), 9 = connection failed (pairing/authentication failed, or opening the hid connection failed).
+
| 0 || || [1.0.0-11.0.1] Connection status.
 
|-
 
|-
| 0x4 || 0x6 || Device [[#Address|address]].
+
| 1 || || [1.0.0-11.0.1] Triggered by BSA_SEC_SP_CFM_REQ_EVT: SSP confirm request.
 
|-
 
|-
| 0xA || 0x2 || Padding
+
| 2 || || [12.0.0+] Triggered by BSA_SEC_RESUMED_EVT: ACL Link is now Resumed.
 
|-
 
|-
| 0xC || 0x4 || [[#ConnectionEventType]]
+
| 3 ([1.0.0-11.0.1] 2) || || Triggered by BSA_SEC_SUSPENDED_EVT: ACL Link is now Suspended.
 
|}
 
|}
   −
[[#EventType|Type13]]:
+
= BluetoothHhReportType =
 +
This is u32 enum "nn::bluetooth::BluetoothHhReportType".
 +
 
 +
Bit0-1 directly control the HID bluetooth transaction report-type value. Bit2-3: these directly control the Parameter Reserved field for SetReport, for GetReport these control the Parameter Reserved and Size bits.
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset
+
! Value
! Size
+
! Description
! Description
   
|-
 
|-
| 0x0 || 0x2 || [[#FatalReason]]
+
| 0 || Other
|}
  −
 
  −
= BluetoothPinCode =
  −
This is "nn::bluetooth::BluetoothPinCode". This is a 0x10-byte struct with 1-byte alignment.
  −
 
  −
= PinCode =
  −
This is "nn::bluetooth::hal::PinCode". This is a 0x11-byte struct with 1-byte alignment.
  −
 
  −
= HidData =
  −
This is "nn::bluetooth::HidData". This is a 0x282-byte struct.
  −
 
  −
{| class="wikitable" border="1"
   
|-
 
|-
! Offset
+
| 1 || Input
! Size
  −
! Description
   
|-
 
|-
| 0x0 || 0x2 || Size of the following data.
+
| 2 || Output
 
|-
 
|-
| 0x2 || 0x280 || Data
+
| 3 || Feature
 
|}
 
|}
   −
= HidReport =
+
= HidEventType =
This is "nn::bluetooth::HidReport". This is a 0x2BE-byte struct.
+
This is u32 enum "nn::bluetooth::HidEventType".
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset
+
! Value
! Size
+
! Name
! Description
+
! Description
 +
|-
 +
| 0 || || Connection. Only used with [[#GetHidEventInfo]].
 +
|-
 +
| 1 ([1.0.0-11.0.1] 4) || || DATA report on the Interrupt channel.
 +
|-
 +
| 2 ([1.0.0-11.0.1] 8) || || Response to SET_REPORT.
 
|-
 
|-
| 0x0 || 0x2 || Size of the following data.
+
| 3 ([1.0.0-11.0.1] 9) || || Response to GET_REPORT.
 
|-
 
|-
| 0x2 || 0x2BC || Data
+
| [1.0.0-11.0.1] 7 || || Response for extensions. Only used with [[#GetHidEventInfo]].
 
|}
 
|}
   −
= PlrStatistics =
+
= BleEventType =
This is "nn::bluetooth::PlrStatistics". This is a 0x84-byte struct.
+
This is u32 enum "nn::bluetooth::BleEventType".
   −
= PlrList =
+
= FatalReason =
This is "nn::bluetooth::PlrList". This is a 0xA4-byte struct.
+
This is u32 enum "nn::bluetooth::FatalReason".
   −
= PacketLostRate =
+
This determines the u16 data to write into the CircularBuffer. [[#EmulateBluetoothCrash]] handles values outside of 1-2 the same as value 3.
This is "nn::bluetooth::hal::PacketLostRate".
     −
= ChannelMapList =
+
{| class="wikitable" border="1"
This is "nn::bluetooth::ChannelMapList". This is a 0x88-byte struct.
+
|-
 
+
!  Value
= Channel =
+
!  Description
This is "nn::bluetooth::hal::Channel".
+
|-
 +
| 0 || Only for [[#EventInfo]]: invalid.
 +
|-
 +
| 1 || u16 data = 0x850. Can only be triggered by [[#EmulateBluetoothCrash]], not triggered by the sysmodule otherwise.
 +
|-
 +
| 2 || u16 data = 0x851. HCI command timeout.
 +
|-
 +
| 3 || u16 data = 0x852. HCI event HCI_Hardware_Error occurred.
 +
|-
 +
| 7 || Only for [[#EventInfo]]: triggered after enabling bluetooth, when a global state field is value 4 or 2.
 +
|-
 +
| 9 || [12.0.0+] Only for [[#EventInfo]]: triggered when bluetooth errors occur in a certain range, with various Audio interface vfuncs.
 +
|}
   −
= LeChannel =
+
= AdapterProperty =
This is "nn::bluetooth::hal::LeChannel".
+
This is "nn::bluetooth::AdapterProperty" ([12.0.0+] "nn::bluetooth::hal::AdapterProperty"). This is a 0x103-byte ([12.0.0+] 0x102-byte) struct.
 
  −
= LeConnectionParams =
  −
This is "nn::bluetooth::LeConnectionParams". This is a 0x14-byte struct with 2-byte alignment.
  −
 
  −
= BleConnectionParameter =
  −
This is "nn::bluetooth::BleConnectionParameter". This is a 0xC-byte struct with 2-byte alignment.
  −
 
  −
= BleAdvertisePacketData =
  −
This is "nn::bluetooth::BleAdvertisePacketData" ([5.0.0-8.1.1] "nn::bluetooth::LeAdvertiseData"). This is a 0xCC-byte struct.
      
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,370: Line 1,379:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x4 ||  
+
| 0x0 || 0x6 || Same as the data for [[#BluetoothPropertyType]] type2.
 
|-
 
|-
| 0x4 || 0x1 ||  
+
| 0x6 || 0x3 || Same as the data for [[#BluetoothPropertyType]] type5.
 
|-
 
|-
| 0x5 || 0x1 || Size of the data at +0x6.
+
| 0x9 || 0xF9 || Same as the data for [[#BluetoothPropertyType]] type1 (last byte is not initialized).
 
|-
 
|-
| 0x6 || 0x1F ||  
+
| 0x102 || 0x1 || Set to hard-coded value 0x68 (same as the data for [[#BluetoothPropertyType]] type6).
 +
|}
 +
 
 +
[12.0.0+]:
 +
 
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0x25 || 0x3 || Padding
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 0x28 || 0x1 || Total array entries for the below array, can be 0.
+
| 0x0 || 0x1 || [[#AdapterPropertyType]]
 
|-
 
|-
| 0x29 || 0x7 || Padding
+
| 0x1 || 0x1 || Data size
 
|-
 
|-
| 0x30 || count*0x14 || Array entries, see below.
+
| 0x2 || {Above size} || Data, as specified by the type.
 +
|}
 +
 
 +
= AdapterPropertySet =
 +
This is "nn::bluetooth::hal::AdapterPropertySet". This is a 0x102-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0xA4 || 0x1 || Size of the data at +0xA8.
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 0xA5 || 0x1 ||  
+
| 0x0 || 0x6 || Same as the data for [[#AdapterPropertyType]] type0.
 
|-
 
|-
| 0xA6 || 0x2 || Padding
+
| 0x6 || 0x3 || Same as the data for [[#AdapterPropertyType]] type2.
 
|-
 
|-
| 0xA8 || 0x1F ||  
+
| 0x9 || 0xF9 || Same as the data for [[#AdapterPropertyType]] type1.
|-
  −
| 0xC7 || 0x1 ||
  −
|-
  −
| 0xC8 || 0x1 ||
  −
|-
  −
| 0xC9 || 0x3 || Padding
   
|}
 
|}
   −
Array entry:
+
= Address =
 +
This is "nn::bluetooth::Address". This is a 0x6-byte struct with 1-byte alignment.
 +
 
 +
= EventInfo =
 +
This is the output buffer for [[#GetEventInfo]]. The data stored here depends on the [[#EventType]].
 +
 
 +
[[#EventType|Type0]]:
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,409: Line 1,433:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x2 ||  
+
| 0x0 || 0x4 ||  
|-
  −
| 0x2 || 0x12 || Unused
   
|}
 
|}
   −
= BleAdvertiseFilter =
+
[12.0.0+] [[#EventType|Type0]]:
This is "nn::bluetooth::BleAdvertiseFilter". This is a 0x3E-byte struct.
  −
 
  −
= BleAdvertisePacketParameter =
  −
This is "nn::bluetooth::BleAdvertisePacketParameter". This is a 8-byte struct with 1-byte alignment.
  −
 
  −
= BleScanResult =
  −
This is "nn::bluetooth::BleScanResult". This is a 0x148-byte struct.
      
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,429: Line 1,444:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x1 ||  
+
| 0x0 || 0x6 || Device [[#Address|address]].
 
|-
 
|-
| 0x1 || 0x6 || [[#Address]]
+
| 0x6 || 0xF9 || Device name, NUL-terminated string.
 
|-
 
|-
| 0x7 || 0x139 ||  
+
| 0xFF || 0x3 || Class of Device.
 
|-
 
|-
| 0x140 || 0x4 || s32
+
| 0x102 || 0x6 || Reserved
|-
  −
| 0x144 || 0x4 || s32
   
|}
 
|}
   −
= BleConnectionInfo =
+
[12.0.0+] [[#EventType|Type1]]:
This is "nn::bluetooth::BleConnectionInfo". This is a 0xC-byte struct.
      
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,449: Line 1,461:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x4 || ConnectionHandle, 0xFFFFFFFF ([5.0.0-5.0.2] 0xFFFF) is invalid.
+
| 0x0 || 0x1 || Status: 0 = stopped, 1 = started.
 
|-
 
|-
| 0x4 || 0x6 || [[#Address]]
+
| 0x1 || 0x3 || Padding
|-
  −
| 0xA || 0x2 || Padding
   
|-
 
|-
 +
| 0x4 || 0x4 || services value from [[#StartInquiry]] when starting, otherwise this is value 0.
 
|}
 
|}
   −
= GattAttributeUuid =
+
[1.0.0-11.0.1] [[#EventType|Type3]]:
This is "nn::bluetooth::GattAttributeUuid". This is a 0x14-byte struct with 4-byte alignment.
      
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,466: Line 1,476:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x4 || UUID size, must be 0x2, 0x4, or 0x10.
+
| 0x0 || 0xF9 || Device name, NUL-terminated string.
 
|-
 
|-
| 0x4 || 0x10 || UUID with the above size.
+
| 0xF9 || 0x6 || Device [[#Address|address]].
|}
  −
 
  −
= GattId =
  −
This is "nn::bluetooth::GattId". This is a 0x18-byte struct with 4-byte alignment.
  −
 
  −
{| class="wikitable" border="1"
   
|-
 
|-
! Offset
+
| 0xFF || 0x10 || Reserved
! Size
  −
! Description
   
|-
 
|-
| 0x0 || 0x1 || InstanceId
+
| 0x10F || 0x3 || Class of Device.
 +
|-
 +
| 0x112 || 0x4 || Set to fixed value u32 0x1.
 +
|-
 +
| 0x116 || 0xFA || Reserved
 +
|-
 +
| 0x210 || 0x5C || Reserved
 +
|-
 +
| 0x26C || 0xF9 || Device name, NUL-terminated string. Same as name above, except starting at index 1.
 +
|-
 +
| 0x365 || 0x4 || s32 RSSI
 
|-
 
|-
| 0x1 || 0x3 || Padding
+
| 0x369 || 0x4 || Two bytes which are the same as name[11-12].
 
|-
 
|-
| 0x4 || 0x14 || [[#GattAttributeUuid]]
+
| 0x36D || 0x10 || Reserved
 
|}
 
|}
   −
= LeEventInfo =
+
[1.0.0-11.0.1] [[#EventType|Type4]]:
This is a 0x400-byte struct.
      
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,496: Line 1,507:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x4 ||  
+
| 0x0 || 0x4 || Status: 0 = stopped, 1 = started.
 +
|}
 +
 
 +
[[#EventType|Type2]] ([1.0.0-11.0.1] type5):
 +
 
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0x4 || 0x4 ||
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 0x8 || 0x1 ||  
+
| 0x0 || 0x6 || Device [[#Address|address]].
 
|-
 
|-
| 0x9 || 0x3 || Padding
+
| 0x6 || 0xF9 || Device name, NUL-terminated string.
 +
|-
 +
| 0xFF || 0x3 || Class of Device.
 +
|}
 +
 
 +
[1.0.0-11.0.1] [[#EventType|Type6]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x6 || Device [[#Address|address]].
 
|-
 
|-
| 0xC || 0x14 || [[#GattAttributeUuid]]
+
| 0x6 || 0xF9 || Device name, NUL-terminated string.
 
|-
 
|-
| 0x20 || 0x14 || [[#GattAttributeUuid]]
+
| 0xFF || 0x3 || Class of Device.
 
|-
 
|-
| 0x34 || 0x14 || [[#GattAttributeUuid]]
+
| 0x102 || 0x2 || Padding
 
|-
 
|-
| 0x48 || 0x2 || Size of the below data.
+
| 0x104 || 0x4 || 0 = SSP confirm request, 3 = SSP passkey notification.
 
|-
 
|-
| 0x4A || {above size} || Data.
+
| 0x108 || 0x4 || s32 Passkey, only set when the above field is value 3.
 
|}
 
|}
   −
= BleClientGattOperationInfo =
+
[12.0.0+] [[#EventType|Type3]]:
This is "nn::bluetooth::BleClientGattOperationInfo". This is converted from [[#LeEventInfo]].
      
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,524: Line 1,554:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0x1 || Converted from [[#LeEventInfo]]+0x0.
+
| 0x0 || 0x6 || Device [[#Address|address]].
 
|-
 
|-
| 0x1 || 0x3 || Padding
+
| 0x6 || 0xF9 || Device name, NUL-terminated string.
 
|-
 
|-
| 0x4 || 0x4 || Same as [[#LeEventInfo]]+0x4.
+
| 0xFF || 0x3 || Class of Device.
 
|-
 
|-
| 0x8 || 0x1 || Same as [[#LeEventInfo]]+0x8.
+
| 0x102 || 0x1 || bool flag for Just Works. With SSP passkey notification this is always 0.
 
|-
 
|-
| 0x9 || 0x3 || Padding
+
| 0x103 || 0x1 || Padding
 
|-
 
|-
| 0xC || 0x14 || Same as [[#LeEventInfo]]+0xC.
+
| 0x104 || 0x4 || s32 Passkey
|-
+
|}
| 0x20 || 0x14 || Same as [[#LeEventInfo]]+0x20.
+
 
|-
+
[1.0.0-8.1.1] [[#EventType|Type7]]:
| 0x34 || 0x14 || Same as [[#LeEventInfo]]+0x34.
+
 
|-
+
{| class="wikitable" border="1"
| 0x48 || 0x8 || Same as [[#LeEventInfo]]+0x48.
+
|-
|-
+
! Offset
| 0x50 || {above size} || Same as [[#LeEventInfo]]+0x4A.
+
! Size
|}
+
! Description
 
+
 
= Notes =
+
|-
The output from <code>sudo hcitool info {BDADDR}</code> is identical for [1.0.0-11.0.0]:
+
| 0x0 || 0x6 || Device [[#Address|address]].
 
+
|-
   BD Address:  {BDADDR}
+
| 0x6 || 0x2 || Padding
   OUI Company: Nintendo Co.,Ltd (98-B6-E9)
+
|-
   Device Name: Nintendo Switch
+
| 0x8 || 0x4 || Status, always 0 except with [[#ConnectionEventType|event0]]: 2 = ACL Link is now Resumed (BSA_SEC_RESUMED_EVT), 9 = connection failed (pairing/authentication failed, or opening the hid connection failed).
   LMP Version: 4.2 (0x8) LMP Subversion: 0x2409
+
|-
   Manufacturer: Broadcom Corporation (15)
+
| 0xC || 0x4 || [[#ConnectionEventType]]
   Features page 0: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
+
|}
     <3-slot packets> <5-slot packets> <encryption> <slot offset>  
+
 
     <timing accuracy> <role switch> <sniff mode> <RSSI>  
+
[9.0.0-11.0.1] [[#EventType|Type7]]:
     <channel quality> <SCO link> <HV2 packets> <HV3 packets>  
+
 
     <u-law log> <A-law log> <CVSD> <paging scheme> <power control>  
+
{| class="wikitable" border="1"
     <transparent SCO> <broadcast encrypt> <EDR ACL 2 Mbps>  
+
|-
     <EDR ACL 3 Mbps> <enhanced iscan> <interlaced iscan>  
+
! Offset
     <interlaced pscan> <inquiry with RSSI> <extended SCO>  
+
! Size
     <EV4 packets> <EV5 packets> <AFH cap. slave>  
+
! Description
     <AFH class. slave> <LE support> <3-slot EDR ACL>  
+
|-
     <5-slot EDR ACL> <sniff subrating> <pause encryption>  
+
| 0x0 || 0x4 || Status, always 0 except with [[#ConnectionEventType|event0]]: 2 = ACL Link is now Resumed (BSA_SEC_RESUMED_EVT), 9 = connection failed (pairing/authentication failed, or opening the hid connection failed).
     <AFH cap. master> <AFH class. master> <EDR eSCO 2 Mbps>  
+
|-
     <EDR eSCO 3 Mbps> <3-slot EDR eSCO> <extended inquiry>  
+
| 0x4 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0xA || 0x2 || Padding
 +
|-
 +
| 0xC || 0x4 || [[#ConnectionEventType]]
 +
|}
 +
 
 +
[12.0.0+] [[#EventType|Type4]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || [[#ConnectionEventType]]
 +
|-
 +
| 0x4 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0xA || 0xFE || Reserved
 +
|}
 +
 
 +
[12.0.0+] [[#EventType|Type5]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0x6 || 0x1 || Status flag: 1 = success, 0 = failure.
 +
|-
 +
| 0x7 || 0x1 || Tsi value, when the above indicates success.
 +
|}
 +
 
 +
 
 +
[12.0.0+] [[#EventType|Type6]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0x6 || 0x1 || Status flag: 1 = success, 0 = failure.
 +
|-
 +
| 0x7 || 0x1 || Input bool value from [[#EnableBurstMode]], when the above indicates success.
 +
|}
 +
 
 +
 
 +
[12.0.0+] [[#EventType|Type7]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0x6 || 0x1 || Status flag: 1 = success, 0 = failure.
 +
|-
 +
| 0x7 || 0x1 || Bool flag, when the above indicates success.
 +
|}
 +
 
 +
[12.0.0+] [[#EventType|Type8]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x1 || Status flag: 0 = failure, 1 = success.
 +
|-
 +
| 0x1 || 0x3 || Padding
 +
|-
 +
| 0x4 || 0x4 || Count value.
 +
|}
 +
 
 +
[12.0.0+] [[#EventType|Type9]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0x6 || 0x1 || Status flag: 1 = success, 0 = failure.
 +
|}
 +
 
 +
[[#EventType|Type10]] ([1.0.0-11.0.1] type13):
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x2 || [[#FatalReason]]
 +
|}
 +
 
 +
= HidEventInfo =
 +
This is the output buffer for [[#GetHidEventInfo]] / events in sharedmem. The data stored here depends on the [[#HidEventType]].
 +
 
 +
[[#HidEventType|Type0]], for [[#GetHidEventInfo]]:
 +
 
 +
[1.0.0-11.0.1]
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0x6 || 0x2 || Padding
 +
|-
 +
| 0x8 || 0x4 || Status: 0 = hid connection opened, 2 = hid connection closed, 8 = failed to open hid connection.
 +
|}
 +
 
 +
[12.0.0+]
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || Status: 0 = hid connection closed, 1 = hid connection opened, 2 = failed to open hid connection.
 +
|-
 +
| 0x4 || 0x6 || Device [[#Address|address]].
 +
|}
 +
 
 +
= BluetoothPinCode =
 +
This is "nn::bluetooth::BluetoothPinCode". This is a 0x10-byte struct with 1-byte alignment.
 +
 
 +
= PinCode =
 +
This is "nn::bluetooth::hal::PinCode". This is a 0x11-byte struct with 1-byte alignment.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0xF || PinCode
 +
|-
 +
| 0xF || 0x1 || PinCode length, must be 0x1-0xF otherwise the sysmodule will Abort.
 +
|}
 +
 
 +
= ServiceFlag =
 +
This is "nn::bluetooth::hal::ServiceFlag". This is the same as the BSA service-mask.
 +
 
 +
= HidData =
 +
This is "nn::bluetooth::HidData". This is a 0x282-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x2 || Size of the following data.
 +
|-
 +
| 0x2 || 0x280 || Data
 +
|}
 +
 
 +
= HidReport =
 +
This is "nn::bluetooth::HidReport". This is a 0x2BE-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x2 || Size of the following data.
 +
|-
 +
| 0x2 || 0x2BC || Data
 +
|}
 +
 
 +
= PlrStatistics =
 +
This is "nn::bluetooth::PlrStatistics". This is a 0x84-byte struct.
 +
 
 +
= PlrList =
 +
This is "nn::bluetooth::PlrList". This is a 0xA4-byte struct.
 +
 
 +
= PacketLostRate =
 +
This is "nn::bluetooth::hal::PacketLostRate".
 +
 
 +
= ChannelMapList =
 +
This is "nn::bluetooth::ChannelMapList". This is a 0x88-byte struct.
 +
 
 +
= Channel =
 +
This is "nn::bluetooth::hal::Channel".
 +
 
 +
= LeChannel =
 +
This is "nn::bluetooth::hal::LeChannel".
 +
 
 +
= LeConnectionParams =
 +
This is "nn::bluetooth::LeConnectionParams". This is a 0x14-byte struct with 2-byte alignment.
 +
 
 +
= BleConnectionParameter =
 +
This is "nn::bluetooth::BleConnectionParameter". This is a 0xC-byte struct with 2-byte alignment.
 +
 
 +
= BleAdvertisePacketData =
 +
This is "nn::bluetooth::BleAdvertisePacketData" ([5.0.0-8.1.1] "nn::bluetooth::LeAdvertiseData"). This is a 0xCC-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 ||
 +
|-
 +
| 0x4 || 0x1 ||
 +
|-
 +
| 0x5 || 0x1 || Size of the data at +0x6.
 +
|-
 +
| 0x6 || 0x1F ||
 +
|-
 +
| 0x25 || 0x3 || Padding
 +
|-
 +
| 0x28 || 0x1 || Total array entries for the below array, can be 0.
 +
|-
 +
| 0x29 || 0x7 || Padding
 +
|-
 +
| 0x30 || count*0x14 || Array entries, see below.
 +
|-
 +
| 0xA4 || 0x1 || Size of the data at +0xA8.
 +
|-
 +
| 0xA5 || 0x1 ||
 +
|-
 +
| 0xA6 || 0x2 || Padding
 +
|-
 +
| 0xA8 || 0x1F ||
 +
|-
 +
| 0xC7 || 0x1 ||
 +
|-
 +
| 0xC8 || 0x1 ||
 +
|-
 +
| 0xC9 || 0x3 || Padding
 +
|}
 +
 
 +
Array entry:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x2 ||
 +
|-
 +
| 0x2 || 0x12 || Unused
 +
|}
 +
 
 +
= BleAdvertiseFilter =
 +
This is "nn::bluetooth::BleAdvertiseFilter". This is a 0x3E-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x1 || FilterId
 +
|-
 +
| 0x1 || 0x1 || CondDataSize. Only used with CondType Manu.
 +
|-
 +
| 0x2 || 0x1 || CondType
 +
|-
 +
| 0x3 || 0x1D || CondData, content depends on CondType.
 +
|-
 +
| 0x20 || 0x1D || Mask. Only used with CondType Manu. +0 = u16 CompanyIdMask, then {pattern mask}.
 +
|-
 +
| 0x3D || 0x1 || MaskSize. Only used with CondType Manu.
 +
|}
 +
 
 +
CondType:
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Value
 +
!  Name
 +
!  Description
 +
|-
 +
| 2-3 || || ServiceUuid16. CondData = 16bit UUID which is byteswapped.
 +
|-
 +
| 4-5 || || ServiceUuid32. CondData = 32bit UUID which is byteswapped.
 +
|-
 +
| 6-7 || || ServiceUuid128. CondData = 128bit UUID which is copied raw into the param struct.
 +
|-
 +
| 255 || || Manu. CondData: u16 CompanyId, then {pattern data}.
 +
|}
 +
 
 +
To pass filtering, the BLE advert data should be: data & Mask == CondData (following the type field in the advert entry with the matching type).
 +
 
 +
= BleAdvertisePacketParameter =
 +
This is "nn::bluetooth::BleAdvertisePacketParameter". This is a 8-byte struct with 1-byte alignment.
 +
 
 +
[[BTM_services#StartBleScanForGeneral|StartBleScanForGeneral]] generates a [[#BleAdvertiseFilter]] from this. CondType = Manu, CondDataSize = 0xA. CondData: +0 = u16 CompanyId, u8 +2 = 0x1, +3 = {data copied from PatternData, then an u8 with value 0x0}. MaskSize = 0x9, Mask = {all 0xFF}.
 +
 
 +
[[BTM_services#StartBleScanForPaired|StartBleScanForPaired]] generates a [[#BleAdvertiseFilter]] from this, similar to the above. CondType = Manu, CondDataSize = 0x11. CondData: +0 = u16 CompanyId, u8 +2 = 0x1, +3 = {data copied from PatternData, then an u8 with value 0x0, then {6-byte system btaddr}}. MaskSize = 0x10, Mask = {all 0xFF except u8 +0x9 which is 0x0}.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x2 || CompanyId
 +
|-
 +
| 0x2 || 0x6 || PatternData
 +
|}
 +
 
 +
= BleScanResult =
 +
This is "nn::bluetooth::BleScanResult". This is a 0x148-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x1 ||
 +
|-
 +
| 0x1 || 0x6 || [[#Address]]
 +
|-
 +
| 0x7 || || Array of entries where each entry is 0x1F-bytes. hid compares +1 with 0xFF and +0x2 with the cached output from [[#BTM_services#GetBleScanParameterGeneral|GetBleScanParameterGeneral]] (entry+0x4 is skipped over).
 +
|-
 +
| 0x140 || 0x4 || s32 Total entries in the array at 0x8.
 +
|-
 +
| 0x144 || 0x4 || s32
 +
|}
 +
 
 +
= BleConnectionInfo =
 +
This is "nn::bluetooth::BleConnectionInfo". This is a 0xC-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || ConnectionHandle, 0xFFFFFFFF ([5.0.0-5.0.2] 0xFFFF) is invalid.
 +
|-
 +
| 0x4 || 0x6 || [[#Address]]
 +
|-
 +
| 0xA || 0x2 || Padding
 +
|-
 +
|}
 +
 
 +
= GattAttributeUuid =
 +
This is "nn::bluetooth::GattAttributeUuid". This is a 0x14-byte struct with 4-byte alignment.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || [[#BleGattUuid]] size. Must be 0x2, 0x4, or 0x10.
 +
|-
 +
| 0x4 || 0x10 || [[#BleGattUuid]] with the above size.
 +
|}
 +
 
 +
= GattId =
 +
This is "nn::bluetooth::GattId". This is a 0x18-byte struct with 4-byte alignment.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x1 || InstanceId
 +
|-
 +
| 0x1 || 0x3 || Padding
 +
|-
 +
| 0x4 || 0x14 || [[#GattAttributeUuid]]
 +
|}
 +
 
 +
= BleGattUuid =
 +
This is an enum of u16, u32 and u128 values.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Value
 +
!  Description
 +
|-
 +
| 0x2902 || ClientConfigUuid16
 +
|-
 +
| 0x2908 || ReportReferenceUuid16
 +
|-
 +
| 0x1B666C080A578E83994EA7F7BF50DDA3 || PalmaOtafuControlPointUuid128
 +
|-
 +
| 0x26FE2EE709244FB7914061D97A6CE8A2 || PalmaOtafuDataUuid128
 +
|-
 +
| 0x45CEF889AF8E0784664404737C7FBE2B || NbatUuid128
 +
|-
 +
| 0x46CEF889AF8E0784664404737C7FBE2B || BatteryLevelUuid128
 +
|-
 +
| 0x47CEF889AF8E0784664404737C7FBE2B || BatteryStateUuid128
 +
|-
 +
| 0xD88B7646729DBDA17A4425F4101126C7 || PalmaOtafuUuid128
 +
|-
 +
| 0xE5237AE2516B55BB67456DF36CE17566 || NhogUuid128
 +
|-
 +
| 0xE6237AE2516B55BB67456DF36CE17566 || InputReportUuid128
 +
|-
 +
| 0xE7237AE2516B55BB67456DF36CE17566 || OutputCommandUuid128
 +
|-
 +
| 0xE8237AE2516B55BB67456DF36CE17566 || CommandResponseUuid128
 +
|}
 +
 
 +
= BleClientGattOperationStatus =
 +
This is an u8 enum. This is converted from the [[#LeEventInfo]] status field.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Value
 +
!  Name
 +
!  Description
 +
|-
 +
| 0 || || Same as [[#LeEventInfo]] status 0.
 +
|-
 +
| 1 || || Same as [[#LeEventInfo]] status 55.
 +
|-
 +
| 2 || || Same as [[#LeEventInfo]] status 25, 52.
 +
|-
 +
| 3 || || Same as [[#LeEventInfo]] status 4, 16, 21, 50.
 +
|-
 +
| 4 || || Same as [[#LeEventInfo]] status 5.
 +
|-
 +
| 5 || || Same as [[#LeEventInfo]] status 6.
 +
|-
 +
| 6 || || Same as [[#LeEventInfo]] status 7.
 +
|-
 +
| 7 || || Same as [[#LeEventInfo]] status 9.
 +
|-
 +
| 8 || || Same as [[#LeEventInfo]] status 13.
 +
|-
 +
| 9 || || Used as the default case when the [[#LeEventInfo]] status is unrecognized.
 +
|-
 +
| 10 || || Same as [[#LeEventInfo]] status 35.
 +
|}
 +
 
 +
= LeEventInfo =
 +
This is a 0x400-byte struct.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || Status. 0 = success, non-zero = error.
 +
|-
 +
| 0x4 || 0x4 || ConnectionId
 +
|-
 +
| 0x8 || 0x1 || Flags. Bit0 = IsWrite, bit1 = IsDescriptor, bit2 = IsNotify.
 +
When bit2 is set, bit0 = IsIndication.
 +
|-
 +
| 0x9 || 0x3 || Padding
 +
|-
 +
| 0xC || 0x14 || Service [[#GattAttributeUuid]]
 +
|-
 +
| 0x20 || 0x14 || Characteristic [[#GattAttributeUuid]]
 +
|-
 +
| 0x34 || 0x14 || Descriptor [[#GattAttributeUuid]]
 +
|-
 +
| 0x48 || 0x2 || Size of the below data.
 +
|-
 +
| 0x4A || 0x200 || Data with the above size.
 +
|}
 +
 
 +
= BleClientGattOperationInfo =
 +
This is "nn::bluetooth::BleClientGattOperationInfo". This is converted from [[#LeEventInfo]].
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x1 || [[#BleClientGattOperationStatus]]
 +
|-
 +
| 0x1 || 0x3 || Padding
 +
|-
 +
| 0x4 || 0x4 || Same as [[#LeEventInfo]]+0x4.
 +
|-
 +
| 0x8 || 0x1 || Same as [[#LeEventInfo]]+0x8.
 +
|-
 +
| 0x9 || 0x3 || Padding
 +
|-
 +
| 0xC || 0x14 || Same as [[#LeEventInfo]]+0xC.
 +
|-
 +
| 0x20 || 0x14 || Same as [[#LeEventInfo]]+0x20.
 +
|-
 +
| 0x34 || 0x14 || Same as [[#LeEventInfo]]+0x34.
 +
|-
 +
| 0x48 || 0x8 || Same as [[#LeEventInfo]]+0x48.
 +
|-
 +
| 0x50 || {above size} || Same as [[#LeEventInfo]]+0x4A.
 +
|}
 +
 
 +
= AudioEventType =
 +
This is "nn::bluetooth::hal::AudioEventType". This is an u32 enum.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Value
 +
!  Name
 +
!  Description
 +
|-
 +
| 0 || || None
 +
|-
 +
| 1 || || Connection
 +
|}
 +
 
 +
= AudioEventInfo =
 +
This is the output buffer for [[#GetAudioEventInfo]]. The data stored here depends on the [[#AudioEventType]].
 +
 
 +
[[#AudioEventType|Type1]]:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || Status: 0 = AV connection closed, 1 = AV connection opened, 2 = failed to open AV connection.
 +
|-
 +
| 0x4 || 0x6 || Device [[#Address|address]].
 +
|-
 +
| 0xA || 0x2 || Padding
 +
|}
 +
 
 +
= PcmParameter =
 +
This is "nn::bluetooth::system::PcmParameter". This is a 0xC-byte struct with 4-byte alignment.
 +
 
 +
The sysmodule will Abort if any of these fields are invalid.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0 || 0x4 || Must be 0-3. Controls number of channels: 0 = mono, non-zero = stereo.
 +
|-
 +
| 0x4 || 0x4 || s32 SampleRate. Must be one of the following: 16000, 32000, 44100, 48000.
 +
|-
 +
| 0x8 || 0x4 || Bits per sample. Must be 8 or 16.
 +
|}
 +
 
 +
= AudioOutState =
 +
This is "nn::bluetooth::system::AudioOutState". This is an u32 enum.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Value
 +
!  Description
 +
|-
 +
| 0 || Stopped
 +
|-
 +
| 1 || Started
 +
|}
 +
 
 +
= AudioCodec =
 +
This is "nn::bluetooth::system::AudioCodec". This is an u32 enum.
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Value
 +
!  Description
 +
|-
 +
| 0 || Raw PCM
 +
|}
 +
 
 +
= AudioControlButtonState =
 +
This is "nn::bluetooth::system::AudioControlButtonState". This is a 0x10-byte struct.
 +
 
 +
= AvrcEventType =
 +
This is "nn::bluetooth::hal::AvrcEventType".
 +
 
 +
= AvrcOperationId =
 +
This is "nn::bluetooth::hal::AvrcOperationId". This is the same as tBSA_AV_RC.
 +
 
 +
= AvrcStateType =
 +
This is "nn::bluetooth::hal::AvrcStateType". This is the same as tBSA_AV_STATE.
 +
 
 +
= Notes =
 +
The output from <code>sudo hcitool info {BDADDR}</code> is identical for [1.0.0-11.0.0]:
 +
 
 +
   BD Address:  {BDADDR}
 +
   OUI Company: Nintendo Co.,Ltd (98-B6-E9)
 +
   Device Name: Nintendo Switch
 +
   LMP Version: 4.2 (0x8) LMP Subversion: 0x2409
 +
   Manufacturer: Broadcom Corporation (15)
 +
   Features page 0: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
 +
     <3-slot packets> <5-slot packets> <encryption> <slot offset>  
 +
     <timing accuracy> <role switch> <sniff mode> <RSSI>  
 +
     <channel quality> <SCO link> <HV2 packets> <HV3 packets>  
 +
     <u-law log> <A-law log> <CVSD> <paging scheme> <power control>  
 +
     <transparent SCO> <broadcast encrypt> <EDR ACL 2 Mbps>  
 +
     <EDR ACL 3 Mbps> <enhanced iscan> <interlaced iscan>  
 +
     <interlaced pscan> <inquiry with RSSI> <extended SCO>  
 +
     <EV4 packets> <EV5 packets> <AFH cap. slave>  
 +
     <AFH class. slave> <LE support> <3-slot EDR ACL>  
 +
     <5-slot EDR ACL> <sniff subrating> <pause encryption>  
 +
     <AFH cap. master> <AFH class. master> <EDR eSCO 2 Mbps>  
 +
     <EDR eSCO 3 Mbps> <3-slot EDR eSCO> <extended inquiry>  
 
     <LE and BR/EDR> <simple pairing> <encapsulated PDU>  
 
     <LE and BR/EDR> <simple pairing> <encapsulated PDU>  
 
     <err. data report> <non-flush flag> <LSTO> <inquiry TX power>  
 
     <err. data report> <non-flush flag> <LSTO> <inquiry TX power>  
Line 1,576: Line 2,225:  
The bluetooth stack is Broadcom/Cypress brcm BSA (for example, see [https://github.com/hardkernel/buildroot_linux_amlogic_brcm-bsa here]).
 
The bluetooth stack is Broadcom/Cypress brcm BSA (for example, see [https://github.com/hardkernel/buildroot_linux_amlogic_brcm-bsa here]).
   −
Various btdrv service commands use a custom BSA extension (message-ids based at 0x8CA/2250), this is referred to as "robson".
+
Various btdrv service commands use a custom BSA extension (message-ids based at 0x8CA/2250), this is referred to as "robson". The following BSA modules are supported by the BSA server task thread (including the aforementioned robson): sys, dm, disc, sec, hh, [12.0.0+] av, dg, tm, ble.
   −
The following L2CAP services are registered (dynamic channels): SDP, ATT (GATT), RFCOMM, HID (PSMs: 0x11, 0x13, 0x8001, 0x8003).
+
The following L2CAP services are registered (dynamic channels): SDP, ATT (GATT), RFCOMM, HID (PSMs: 0x11, 0x13, 0x8001, 0x8003), [12.0.0+] AVCTP/AVCTP_Browsing (only when the features bitfield passed to BSA_AvEnable by [[#EnableBluetooth]] has bit0 ("remote control target") or bit1 set), [12.0.0+] AVDTP.
    
<code>l2cu_send_peer_echo_rsp</code> is called with p_data=NULL and data_len=0, therefore no data is returned in the L2CAP ECHO response.
 
<code>l2cu_send_peer_echo_rsp</code> is called with p_data=NULL and data_len=0, therefore no data is returned in the L2CAP ECHO response.
Line 1,643: Line 2,292:  
| CYW4356A3_001.004.009.0092.0095
 
| CYW4356A3_001.004.009.0092.0095
 
|-
 
|-
| [12.0.0]
+
| [12.0.0-14.1.2]
 
| BSA0106_01.60.00_
 
| BSA0106_01.60.00_
 
| Hayward_T3_RC_20210224
 
| Hayward_T3_RC_20210224
 
| CYW4356A3_001.004.009.0092.0095
 
| CYW4356A3_001.004.009.0092.0095
 +
|-
 +
| [15.0.0-18.0.0]
 +
| BSA0106_01.60.00_
 +
| Hayward_T3_RC_20210224
 +
| BCM4356A3 UART 37.4 MHz wlbga_bu
 
|}
 
|}
    
<code>bsa_sv_tm_read_version_excback</code> copies bsa_version_string and concats with bsa_version_info_string to generate <code>tBSA_TM_READ_VERSION.bsa_server_version</code>.
 
<code>bsa_sv_tm_read_version_excback</code> copies bsa_version_string and concats with bsa_version_info_string to generate <code>tBSA_TM_READ_VERSION.bsa_server_version</code>.
 +
 +
* [15.0.0]: In the HCI memwrite data, only config data was changed, no code changes.
    
[[Category:Services]]
 
[[Category:Services]]