libnx v4.9.0
Loading...
Searching...
No Matches
btm.h
Go to the documentation of this file.
1/**
2 * @file btm.h
3 * @brief btm service IPC wrapper.
4 * @note See also: https://switchbrew.org/wiki/BTM_services
5 * @author yellows8
6 */
7#pragma once
8#include "../types.h"
9#include "../kernel/event.h"
10#include "../services/btdrv_types.h"
11#include "../services/btm_types.h"
12#include "../sf/service.h"
13
14/// Initialize btm.
16
17/// Exit btm.
18void btmExit(void);
19
20/// Gets the Service object for the actual btm service session.
22
23/**
24 * @brief GetState
25 * @param[out] out \ref BtmState
26 */
28
29/**
30 * @brief GetHostDeviceProperty
31 * @param[out] out \ref BtmHostDeviceProperty
32 */
34
35/**
36 * @brief AcquireDeviceConditionEvent
37 * @note The Event must be closed by the user once finished with it.
38 * @param[out] out_event Output Event with autoclear=true.
39 */
41
42/**
43 * @brief GetDeviceCondition [1.0.0-12.1.0]
44 * @param[out] out \ref BtmDeviceCondition
45 */
47
48/**
49 * @brief GetDeviceCondition [13.0.0+]
50 * @param[in] profile \ref BtmProfile, when not ::BtmProfile_None entries are only returned which match this profile.
51 * @param[out] out \ref BtmConnectedDeviceV13
52 * @param[in] count Size of the out array in entries.
53 * @param[out] total_out Total output entries.
54 */
55Result btmGetDeviceCondition(BtmProfile profile, BtmConnectedDeviceV13 *out, size_t count, s32 *total_out);
56
57/**
58 * @brief SetBurstMode
59 * @param[in] addr \ref BtdrvAddress
60 * @param[in] flag Flag
61 */
63
64/**
65 * @brief SetSlotMode
66 * @param[in] list \ref BtmDeviceSlotModeList
67 */
69
70/**
71 * @brief SetBluetoothMode
72 * @note Only available on pre-9.0.0.
73 * @param[in] mode \ref BtmBluetoothMode
74 */
76
77/**
78 * @brief SetWlanMode
79 * @param[in] mode \ref BtmWlanMode
80 */
82
83/**
84 * @brief AcquireDeviceInfoEvent
85 * @note The Event must be closed by the user once finished with it.
86 * @param[out] out_event Output Event with autoclear=true.
87 */
89
90/**
91 * @brief GetDeviceInfo [1.0.0-12.1.0]
92 * @param[out] out \ref BtmDeviceInfoList
93 */
95
96/**
97 * @brief GetDeviceInfo [13.0.0+]
98 * @param[in] profile \ref BtmProfile, when not ::BtmProfile_None entries are only returned which match this profile.
99 * @param[out] out \ref BtmDeviceInfoV13
100 * @param[in] count Size of the out array in entries.
101 * @param[out] total_out Total output entries.
102 */
103Result btmGetDeviceInfo(BtmProfile profile, BtmDeviceInfoV13 *out, size_t count, s32 *total_out);
104
105/**
106 * @brief AddDeviceInfo
107 * @param[in] info \ref BtmDeviceInfo
108 */
110
111/**
112 * @brief RemoveDeviceInfo
113 * @param[in] addr \ref BtdrvAddress
114 */
116
117/**
118 * @brief IncreaseDeviceInfoOrder
119 * @param[in] addr \ref BtdrvAddress
120 */
122
123/**
124 * @brief LlrNotify
125 * @param[in] addr \ref BtdrvAddress
126 * @param[in] unk [9.0.0+] Unknown
127 */
129
130/**
131 * @brief EnableRadio
132 */
134
135/**
136 * @brief DisableRadio
137 */
139
140/**
141 * @brief HidDisconnect
142 * @param[in] addr \ref BtdrvAddress
143 */
145
146/**
147 * @brief HidSetRetransmissionMode
148 * @param[in] addr \ref BtdrvAddress
149 * @param[in] list \ref BtmZeroRetransmissionList
150 */
152
153/**
154 * @brief AcquireAwakeReqEvent
155 * @note Only available on [2.0.0+].
156 * @note The Event must be closed by the user once finished with it.
157 * @param[out] out_event Output Event with autoclear=true.
158 */
160
161
162/**
163 * @brief AcquireLlrStateEvent
164 * @note Only available on [4.0.0+].
165 * @note The Event must be closed by the user once finished with it.
166 * @param[out] out_event Output Event with autoclear=true.
167 */
169
170/**
171 * @brief IsLlrStarted
172 * @note Only available on [4.0.0+].
173 * @param[out] out Output flag.
174 */
176
177/**
178 * @brief EnableSlotSaving
179 * @note Only available on [4.0.0+].
180 * @param[in] flag Flag
181 */
183
184/**
185 * @brief ProtectDeviceInfo
186 * @note Only available on [5.0.0+].
187 * @param[in] addr \ref BtdrvAddress
188 * @param[in] flag Flag
189 */
191
192/**
193 * @brief AcquireBleScanEvent
194 * @note Only available on [5.0.0+].
195 * @note The Event must be closed by the user once finished with it.
196 * @param[out] out_event Output Event with autoclear=true.
197 */
199
200/**
201 * @brief GetBleScanParameterGeneral
202 * @note Only available on [5.1.0+].
203 * @param[in] parameter_id Must be value 0x1 or 0xFFFF.
204 * @param[out] out \ref BtdrvBleAdvertisePacketParameter
205 */
207
208/**
209 * @brief GetBleScanParameterSmartDevice
210 * @note Only available on [5.1.0+].
211 * @param[in] parameter_id Must be value 0x2.
212 * @param[out] out \ref BtdrvGattAttributeUuid. The first 4-bytes is always 0.
213 */
215
216/**
217 * @brief StartBleScanForGeneral
218 * @note Only available on [5.1.0+].
219 * @param[in] param \ref BtdrvBleAdvertisePacketParameter
220 */
222
223/**
224 * @brief StopBleScanForGeneral
225 * @note Only available on [5.1.0+].
226 */
228
229/**
230 * @brief GetBleScanResultsForGeneral
231 * @note Only available on [5.1.0+].
232 * @param[out] results Output array of \ref BtdrvBleScanResult.
233 * @param[in] count Size of the results array in entries. The max is 10.
234 * @param[out] total_out Total output entries.
235 */
237
238/**
239 * @brief StartBleScanForPaired
240 * @note Only available on [5.1.0+].
241 * @param[in] param \ref BtdrvBleAdvertisePacketParameter
242 */
244
245/**
246 * @brief StopBleScanForPaired
247 * @note Only available on [5.1.0+].
248 */
250
251/**
252 * @brief StartBleScanForSmartDevice
253 * @note Only available on [5.1.0+].
254 * @param[in] uuid \ref BtdrvGattAttributeUuid
255 */
257
258/**
259 * @brief StopBleScanForSmartDevice
260 * @note Only available on [5.1.0+].
261 */
263
264/**
265 * @brief GetBleScanResultsForSmartDevice
266 * @note Only available on [5.1.0+].
267 * @param[out] results Output array of \ref BtdrvBleScanResult.
268 * @param[in] count Size of the results array in entries. The max is 10.
269 * @param[out] total_out Total output entries.
270 */
272
273/**
274 * @brief AcquireBleConnectionEvent
275 * @note Only available on [5.1.0+].
276 * @note The Event must be closed by the user once finished with it.
277 * @param[out] out_event Output Event with autoclear=true.
278 */
280
281/**
282 * @brief BleConnect
283 * @note Only available on [5.0.0+].
284 * @note The \ref BtdrvAddress must not be already connected. A maximum of 4 devices can be connected.
285 * @param[in] addr \ref BtdrvAddress
286 */
288
289/**
290 * @brief BleOverrideConnection
291 * @note Only available on [5.1.0+].
292 * @param[in] id Same as \ref btmBleDisconnect.
293 */
295
296/**
297 * @brief BleDisconnect
298 * @note Only available on [5.0.0+].
299 * @param[in] connection_handle This must match a BtdrvBleConnectionInfo::id from \ref btmBleGetConnectionState. [5.1.0+] 0xFFFFFFFF is invalid.
300 */
301Result btmBleDisconnect(u32 connection_handle);
302
303/**
304 * @brief BleGetConnectionState
305 * @note Only available on [5.0.0+].
306 * @param[out] info Output array of \ref BtdrvBleConnectionInfo.
307 * @param[in] count Size of the info array in entries. Other cmds which use this internally use count=4.
308 * @param[out] total_out Total output entries.
309 */
311
312/**
313 * @brief BleGetGattClientConditionList
314 * @note Only available on [5.0.0+].
315 * @param[out] list \ref BtmGattClientConditionList
316 */
318
319/**
320 * @brief AcquireBlePairingEvent
321 * @note Only available on [5.0.0+].
322 * @note The Event must be closed by the user once finished with it.
323 * @param[out] out_event Output Event with autoclear=true.
324 */
326
327/**
328 * @brief BlePairDevice
329 * @note Only available on [5.1.0+].
330 * @param[in] connection_handle Same as \ref btmBleDisconnect.
331 * @param[in] param \ref BtdrvBleAdvertisePacketParameter
332 */
334
335/**
336 * @brief BleUnpairDeviceOnBoth
337 * @note Only available on [5.1.0+].
338 * @param[in] connection_handle Same as \ref btmBleDisconnect.
339 * @param[in] param \ref BtdrvBleAdvertisePacketParameter
340 */
342
343/**
344 * @brief BleUnPairDevice
345 * @note Only available on [5.1.0+].
346 * @param[in] addr \ref BtdrvAddress
347 * @param[in] param \ref BtdrvBleAdvertisePacketParameter
348 */
350
351/**
352 * @brief BleGetPairedAddresses
353 * @note Only available on [5.1.0+].
354 * @param[in] param \ref BtdrvBleAdvertisePacketParameter
355 * @param[out] addrs Output array of \ref BtdrvAddress.
356 * @param[in] count Size of the addrs array in entries.
357 * @param[out] total_out Total output entries. The max is 10.
358 */
360
361/**
362 * @brief AcquireBleServiceDiscoveryEvent
363 * @note Only available on [5.1.0+].
364 * @note The Event must be closed by the user once finished with it.
365 * @param[out] out_event Output Event with autoclear=true.
366 */
368
369/**
370 * @brief GetGattServices
371 * @note Only available on [5.0.0+].
372 * @param[in] connection_handle Same as \ref btmBleDisconnect.
373 * @param[out] services Output array of \ref BtmGattService.
374 * @param[in] count Size of the services array in entries. The max is 100.
375 * @param[out] total_out Total output entries.
376 */
377Result btmGetGattServices(u32 connection_handle, BtmGattService *services, u8 count, u8 *total_out);
378
379/**
380 * @brief Same as \ref btmGetGattServices except this only returns the \ref BtmGattService which matches the input \ref BtdrvGattAttributeUuid.
381 * @note Only available on [5.0.0+].
382 * @param[in] connection_handle Same as \ref btmBleDisconnect.
383 * @param[in] uuid \ref BtdrvGattAttributeUuid
384 * @param[out] service \ref BtmGattService
385 * @param[out] flag Whether a \ref BtmGattService was returned.
386 */
387Result btmGetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtmGattService *service, bool *flag);
388
389/**
390 * @brief Same as \ref btmGetGattServices except this only returns \ref BtmGattService entries where various checks pass with u16 fields.
391 * @note Only available on [5.0.0+].
392 * @param[in] connection_handle Same as \ref btmBleDisconnect.
393 * @param[in] service_handle ServiceHandle
394 * @param[out] services \ref BtmGattService
395 * @param[in] count Size of the services array in entries. The max is 100.
396 * @param[out] out Output value.
397 */
398Result btmGetGattIncludedServices(u32 connection_handle, u16 service_handle, BtmGattService *services, u8 count, u8 *out);
399
400/**
401 * @brief This is similar to \ref btmGetGattIncludedServices except this only returns 1 \ref BtmGattService.
402 * @note Only available on [5.0.0+].
403 * @param[in] connection_handle Same as \ref btmBleDisconnect.
404 * @param[in] attribute_handle AttributeHandle
405 * @param[out] service \ref BtmGattService
406 * @param[out] flag Whether a \ref BtmGattService was returned.
407 */
408Result btmGetBelongingService(u32 connection_handle, u16 attribute_handle, BtmGattService *service, bool *flag);
409
410/**
411 * @brief GetGattCharacteristics
412 * @note Only available on [5.0.0+].
413 * @param[in] connection_handle Same as \ref btmBleDisconnect.
414 * @param[in] service_handle This controls which \ref BtmGattCharacteristic entries to return.
415 * @param[out] characteristics \ref BtmGattCharacteristic
416 * @param[in] count Size of the characteristics array in entries. The max is 100.
417 * @param[out] total_out Total output entries.
418 */
419Result btmGetGattCharacteristics(u32 connection_handle, u16 service_handle, BtmGattCharacteristic *characteristics, u8 count, u8 *total_out);
420
421/**
422 * @brief GetGattDescriptors
423 * @note Only available on [5.0.0+].
424 * @param[in] connection_handle Same as \ref btmBleDisconnect.
425 * @param[in] char_handle Characteristic handle. This controls which \ref BtmGattDescriptor entries to return.
426 * @param[out] descriptors \ref BtmGattDescriptor
427 * @param[in] count Size of the descriptors array in entries. The max is 100.
428 * @param[out] total_out Total output entries.
429 */
430Result btmGetGattDescriptors(u32 connection_handle, u16 char_handle, BtmGattDescriptor *descriptors, u8 count, u8 *total_out);
431
432/**
433 * @brief AcquireBleMtuConfigEvent
434 * @note Only available on [5.0.0+].
435 * @note The Event must be closed by the user once finished with it.
436 * @param[out] out_event Output Event with autoclear=true.
437 */
439
440/**
441 * @brief ConfigureBleMtu
442 * @note Only available on [5.0.0+].
443 * @param[in] connection_handle Same as \ref btmBleDisconnect.
444 * @param[in] mtu MTU
445 */
446Result btmConfigureBleMtu(u32 connection_handle, u16 mtu);
447
448/**
449 * @brief GetBleMtu
450 * @note Only available on [5.0.0+].
451 * @param[in] connection_handle Same as \ref btmBleDisconnect.
452 * @param[out] out Output MTU.
453 */
454Result btmGetBleMtu(u32 connection_handle, u16 *out);
455
456/**
457 * @brief RegisterBleGattDataPath
458 * @note Only available on [5.0.0+].
459 * @param[in] path \ref BtmBleDataPath
460 */
462
463/**
464 * @brief UnregisterBleGattDataPath
465 * @note Only available on [5.0.0+].
466 * @param[in] path \ref BtmBleDataPath
467 */
469
470/**
471 * @brief RegisterAppletResourceUserId
472 * @note Only available on [5.0.0+].
473 * @param[in] AppletResourceUserId AppletResourceUserId
474 * @param[in] unk Unknown
475 */
477
478/**
479 * @brief UnregisterAppletResourceUserId
480 * @note Only available on [5.0.0+].
481 * @param[in] AppletResourceUserId AppletResourceUserId
482 */
484
485/**
486 * @brief SetAppletResourceUserId
487 * @note Only available on [5.0.0+].
488 * @param[in] AppletResourceUserId AppletResourceUserId
489 */
491
Result btmAddDeviceInfo(const BtmDeviceInfo *info)
AddDeviceInfo.
Result btmLlrNotify(BtdrvAddress addr, s32 unk)
LlrNotify.
Result btmBleUnPairDevice(BtdrvAddress addr, BtdrvBleAdvertisePacketParameter param)
BleUnPairDevice.
Result btmBleUnpairDeviceOnBoth(u32 connection_handle, BtdrvBleAdvertisePacketParameter param)
BleUnpairDeviceOnBoth.
Result btmBleGetGattClientConditionList(BtmGattClientConditionList *list)
BleGetGattClientConditionList.
Result btmSetBluetoothMode(BtmBluetoothMode mode)
SetBluetoothMode.
Result btmRegisterAppletResourceUserId(u64 AppletResourceUserId, u32 unk)
RegisterAppletResourceUserId.
Result btmGetBleScanParameterSmartDevice(u16 parameter_id, BtdrvGattAttributeUuid *out)
GetBleScanParameterSmartDevice.
Result btmHidSetRetransmissionMode(BtdrvAddress addr, const BtmZeroRetransmissionList *list)
HidSetRetransmissionMode.
Result btmSetWlanMode(BtmWlanMode mode)
SetWlanMode.
Result btmStartBleScanForGeneral(BtdrvBleAdvertisePacketParameter param)
StartBleScanForGeneral.
Result btmDisableRadio(void)
DisableRadio.
Result btmGetDeviceInfo(BtmProfile profile, BtmDeviceInfoV13 *out, size_t count, s32 *total_out)
GetDeviceInfo [13.0.0+].
Result btmAcquireDeviceConditionEvent(Event *out_event)
AcquireDeviceConditionEvent.
Result btmAcquireBlePairingEvent(Event *out_event)
AcquireBlePairingEvent.
Result btmLegacyGetDeviceCondition(BtmDeviceCondition *out)
GetDeviceCondition [1.0.0-12.1.0].
Result btmGetGattService(u32 connection_handle, const BtdrvGattAttributeUuid *uuid, BtmGattService *service, bool *flag)
Same as btmGetGattServices except this only returns the BtmGattService which matches the input BtdrvG...
Result btmInitialize(void)
Initialize btm.
Service * btmGetServiceSession(void)
Gets the Service object for the actual btm service session.
Result btmStartBleScanForSmartDevice(const BtdrvGattAttributeUuid *uuid)
StartBleScanForSmartDevice.
Result btmRemoveDeviceInfo(BtdrvAddress addr)
RemoveDeviceInfo.
Result btmBleConnect(BtdrvAddress addr)
BleConnect.
Result btmSetAppletResourceUserId(u64 AppletResourceUserId)
SetAppletResourceUserId.
Result btmHidDisconnect(BtdrvAddress addr)
HidDisconnect.
Result btmEnableSlotSaving(bool flag)
EnableSlotSaving.
Result btmGetBelongingService(u32 connection_handle, u16 attribute_handle, BtmGattService *service, bool *flag)
This is similar to btmGetGattIncludedServices except this only returns 1 BtmGattService.
Result btmGetGattIncludedServices(u32 connection_handle, u16 service_handle, BtmGattService *services, u8 count, u8 *out)
Same as btmGetGattServices except this only returns BtmGattService entries where various checks pass ...
Result btmAcquireBleConnectionEvent(Event *out_event)
AcquireBleConnectionEvent.
Result btmLegacyGetDeviceInfo(BtmDeviceInfoList *out)
GetDeviceInfo [1.0.0-12.1.0].
Result btmIsLlrStarted(bool *out)
IsLlrStarted.
Result btmGetBleScanResultsForSmartDevice(BtdrvBleScanResult *results, u8 count, u8 *total_out)
GetBleScanResultsForSmartDevice.
Result btmStartBleScanForPaired(BtdrvBleAdvertisePacketParameter param)
StartBleScanForPaired.
Result btmGetBleMtu(u32 connection_handle, u16 *out)
GetBleMtu.
Result btmGetGattServices(u32 connection_handle, BtmGattService *services, u8 count, u8 *total_out)
GetGattServices.
Result btmUnregisterAppletResourceUserId(u64 AppletResourceUserId)
UnregisterAppletResourceUserId.
Result btmGetState(BtmState *out)
GetState.
Result btmSetBurstMode(BtdrvAddress addr, bool flag)
SetBurstMode.
Result btmSetSlotMode(const BtmDeviceSlotModeList *list)
SetSlotMode.
Result btmAcquireBleScanEvent(Event *out_event)
AcquireBleScanEvent.
Result btmAcquireAwakeReqEvent(Event *out_event)
AcquireAwakeReqEvent.
Result btmRegisterBleGattDataPath(const BtmBleDataPath *path)
RegisterBleGattDataPath.
Result btmConfigureBleMtu(u32 connection_handle, u16 mtu)
ConfigureBleMtu.
Result btmAcquireBleServiceDiscoveryEvent(Event *out_event)
AcquireBleServiceDiscoveryEvent.
Result btmBleOverrideConnection(u32 id)
BleOverrideConnection.
Result btmAcquireLlrStateEvent(Event *out_event)
AcquireLlrStateEvent.
void btmExit(void)
Exit btm.
Result btmBleGetPairedAddresses(BtdrvBleAdvertisePacketParameter param, BtdrvAddress *addrs, u8 count, u8 *total_out)
BleGetPairedAddresses.
Result btmBleGetConnectionState(BtdrvBleConnectionInfo *info, u8 count, u8 *total_out)
BleGetConnectionState.
Result btmGetGattDescriptors(u32 connection_handle, u16 char_handle, BtmGattDescriptor *descriptors, u8 count, u8 *total_out)
GetGattDescriptors.
Result btmAcquireDeviceInfoEvent(Event *out_event)
AcquireDeviceInfoEvent.
Result btmBlePairDevice(u32 connection_handle, BtdrvBleAdvertisePacketParameter param)
BlePairDevice.
Result btmGetHostDeviceProperty(BtmHostDeviceProperty *out)
GetHostDeviceProperty.
Result btmIncreaseDeviceInfoOrder(BtdrvAddress addr)
IncreaseDeviceInfoOrder.
Result btmUnregisterBleGattDataPath(const BtmBleDataPath *path)
UnregisterBleGattDataPath.
Result btmGetBleScanParameterGeneral(u16 parameter_id, BtdrvBleAdvertisePacketParameter *out)
GetBleScanParameterGeneral.
Result btmGetGattCharacteristics(u32 connection_handle, u16 service_handle, BtmGattCharacteristic *characteristics, u8 count, u8 *total_out)
GetGattCharacteristics.
Result btmGetDeviceCondition(BtmProfile profile, BtmConnectedDeviceV13 *out, size_t count, s32 *total_out)
GetDeviceCondition [13.0.0+].
Result btmEnableRadio(void)
EnableRadio.
Result btmStopBleScanForPaired(void)
StopBleScanForPaired.
Result btmStopBleScanForGeneral(void)
StopBleScanForGeneral.
Result btmStopBleScanForSmartDevice(void)
StopBleScanForSmartDevice.
Result btmAcquireBleMtuConfigEvent(Event *out_event)
AcquireBleMtuConfigEvent.
Result btmProtectDeviceInfo(BtdrvAddress addr, bool flag)
ProtectDeviceInfo.
Result btmBleDisconnect(u32 connection_handle)
BleDisconnect.
Result btmGetBleScanResultsForGeneral(BtdrvBleScanResult *results, u8 count, u8 *total_out)
GetBleScanResultsForGeneral.
BtmBluetoothMode
BluetoothMode.
Definition btm_types.h:23
BtmProfile
Profile.
Definition btm_types.h:60
BtmState
BtmState.
Definition btm_types.h:11
BtmWlanMode
WlanMode.
Definition btm_types.h:29
Address.
Definition btdrv_types.h:245
BleAdvertisePacketParameter.
Definition btdrv_types.h:396
BleConnectionInfo.
Definition btdrv_types.h:411
BleScanResult.
Definition btdrv_types.h:402
GattAttributeUuid.
Definition btdrv_types.h:315
BleDataPath.
Definition btm_types.h:295
BtmConnectedDevice [13.0.0+].
Definition btm_types.h:119
DeviceInfoList.
Definition btm_types.h:233
DeviceInfo [13.0.0+].
Definition btm_types.h:211
DeviceSlotModeList.
Definition btm_types.h:189
GattCharacteristic.
Definition btm_types.h:276
GattClientConditionList.
Definition btm_types.h:259
GattDescriptor.
Definition btm_types.h:287
GattService.
Definition btm_types.h:264
HostDeviceProperty.
Definition btm_types.h:88
ZeroRetransmissionList.
Definition btm_types.h:253
Kernel-mode event structure.
Definition event.h:13
Service object structure.
Definition service.h:14
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
uint8_t u8
8-bit unsigned integer.
Definition types.h:19
uint16_t u16
16-bit unsigned integer.
Definition types.h:20
u32 Result
Function error code result type.
Definition types.h:44
int32_t s32
32-bit signed integer.
Definition types.h:27
uint32_t u32
32-bit unsigned integer.
Definition types.h:21
DeviceCondition [1.0.0-12.1.0].
Definition btm_types.h:174
DeviceInfo [1.0.0-13.0.0].
Definition btm_types.h:227