libnx  v4.6.0
bt.h
Go to the documentation of this file.
1 /**
2  * @file bt.h
3  * @brief Bluetooth user (bt) service IPC wrapper.
4  * @note See also btdev.
5  * @author yellows8
6  * @copyright libnx Authors
7  */
8 #pragma once
9 #include "../types.h"
10 #include "../kernel/event.h"
11 #include "../services/btdrv.h"
12 #include "../sf/service.h"
13 
14 /// Initialize bt. Only available on [5.0.0+].
16 
17 /// Exit bt.
18 void btExit(void);
19 
20 /// Gets the Service object for the actual bt service session.
22 
23 /**
24  * @brief LeClientReadCharacteristic
25  * @note This is essentially the same as \ref btdrvReadGattCharacteristic.
26  * @param[in] connection_handle ConnectionHandle
27  * @param[in] primary_service PrimaryService
28  * @param[in] id0 \ref BtdrvGattId
29  * @param[in] id1 \ref BtdrvGattId
30  * @param[in] unk Unknown
31  */
32 Result btLeClientReadCharacteristic(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, u8 unk);
33 
34 /**
35  * @brief LeClientReadDescriptor
36  * @note This is essentially the same as \ref btdrvReadGattDescriptor.
37  * @param[in] connection_handle ConnectionHandle
38  * @param[in] primary_service PrimaryService
39  * @param[in] id0 \ref BtdrvGattId
40  * @param[in] id1 \ref BtdrvGattId
41  * @param[in] id2 \ref BtdrvGattId
42  * @param[in] unk Unknown
43  */
44 Result btLeClientReadDescriptor(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, const BtdrvGattId *id2, u8 unk);
45 
46 /**
47  * @brief LeClientWriteCharacteristic
48  * @note This is essentially the same as \ref btdrvWriteGattCharacteristic.
49  * @param[in] connection_handle ConnectionHandle
50  * @param[in] primary_service PrimaryService
51  * @param[in] id0 \ref BtdrvGattId
52  * @param[in] id1 \ref BtdrvGattId
53  * @param[in] buffer Input buffer.
54  * @param[in] size Input buffer size, must be <=0x258.
55  * @param[in] unk Unknown
56  * @param[in] flag Flag
57  */
58 Result btLeClientWriteCharacteristic(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, const void* buffer, size_t size, u8 unk, bool flag);
59 
60 /**
61  * @brief LeClientWriteDescriptor
62  * @note This is essentially the same as \ref btdrvWriteGattDescriptor.
63  * @param[in] connection_handle ConnectionHandle
64  * @param[in] primary_service PrimaryService
65  * @param[in] id0 \ref BtdrvGattId
66  * @param[in] id1 \ref BtdrvGattId
67  * @param[in] id2 \ref BtdrvGattId
68  * @param[in] buffer Input buffer.
69  * @param[in] size Input buffer size, must be <=0x258.
70  * @param[in] unk Unknown
71  */
72 Result btLeClientWriteDescriptor(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, const BtdrvGattId *id2, const void* buffer, size_t size, u8 unk);
73 
74 /**
75  * @brief LeClientRegisterNotification
76  * @note This is essentially the same as \ref btdrvRegisterGattNotification.
77  * @param[in] connection_handle ConnectionHandle
78  * @param[in] primary_service PrimaryService
79  * @param[in] id0 \ref BtdrvGattId
80  * @param[in] id1 \ref BtdrvGattId
81  */
82 Result btLeClientRegisterNotification(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1);
83 
84 /**
85  * @brief LeClientDeregisterNotification
86  * @note This is essentially the same as \ref btdrvUnregisterGattNotification.
87  * @param[in] connection_handle ConnectionHandle
88  * @param[in] primary_service PrimaryService
89  * @param[in] id0 \ref BtdrvGattId
90  * @param[in] id1 \ref BtdrvGattId
91  */
92 Result btLeClientDeregisterNotification(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1);
93 
94 /**
95  * @brief SetLeResponse
96  * @param[in] unk Unknown
97  * @param[in] uuid0 \ref BtdrvGattAttributeUuid
98  * @param[in] uuid1 \ref BtdrvGattAttributeUuid
99  * @param[in] buffer Input buffer.
100  * @param[in] size Input buffer size, must be <=0x258.
101  */
102 Result btSetLeResponse(u8 unk, const BtdrvGattAttributeUuid *uuid0, const BtdrvGattAttributeUuid *uuid1, const void* buffer, size_t size);
103 
104 /**
105  * @brief LeSendIndication
106  * @param[in] unk Unknown
107  * @param[in] uuid0 \ref BtdrvGattAttributeUuid
108  * @param[in] uuid1 \ref BtdrvGattAttributeUuid
109  * @param[in] buffer Input buffer.
110  * @param[in] size Input buffer size, clamped to max size 0x258.
111  * @param[in] flag Flag
112  */
113 Result btLeSendIndication(u8 unk, const BtdrvGattAttributeUuid *uuid0, const BtdrvGattAttributeUuid *uuid1, const void* buffer, size_t size, bool flag);
114 
115 /**
116  * @brief GetLeEventInfo
117  * @note This is identical to \ref btdrvGetLeHidEventInfo except different state is used.
118  * @note The state used by this is reset after writing the data to output.
119  * @param[in] buffer Output buffer. 0x400-bytes from state is written here. See \ref BtdrvLeEventInfo.
120  * @param[in] size Output buffer size.
121  * @param[out] type Output BleEventType.
122  */
123 Result btGetLeEventInfo(void* buffer, size_t size, u32 *type);
124 
125 /**
126  * @brief RegisterBleEvent
127  * @note This is identical to \ref btdrvRegisterBleHidEvent except different state is used.
128  * @note The Event must be closed by the user once finished with it.
129  * @param[out] out_event Output Event with autoclear=true.
130  */
132 
Result btLeClientWriteCharacteristic(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, const void *buffer, size_t size, u8 unk, bool flag)
LeClientWriteCharacteristic.
Result btLeClientWriteDescriptor(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, const BtdrvGattId *id2, const void *buffer, size_t size, u8 unk)
LeClientWriteDescriptor.
Result btLeClientRegisterNotification(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1)
LeClientRegisterNotification.
Result btInitialize(void)
Initialize bt. Only available on [5.0.0+].
Result btLeClientReadCharacteristic(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, u8 unk)
LeClientReadCharacteristic.
Result btGetLeEventInfo(void *buffer, size_t size, u32 *type)
GetLeEventInfo.
Result btLeClientDeregisterNotification(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1)
LeClientDeregisterNotification.
void btExit(void)
Exit bt.
Result btLeSendIndication(u8 unk, const BtdrvGattAttributeUuid *uuid0, const BtdrvGattAttributeUuid *uuid1, const void *buffer, size_t size, bool flag)
LeSendIndication.
Service * btGetServiceSession(void)
Gets the Service object for the actual bt service session.
Result btSetLeResponse(u8 unk, const BtdrvGattAttributeUuid *uuid0, const BtdrvGattAttributeUuid *uuid1, const void *buffer, size_t size)
SetLeResponse.
Result btLeClientReadDescriptor(u32 connection_handle, bool primary_service, const BtdrvGattId *id0, const BtdrvGattId *id1, const BtdrvGattId *id2, u8 unk)
LeClientReadDescriptor.
Result btRegisterBleEvent(Event *out_event)
RegisterBleEvent.
GattAttributeUuid.
Definition: btdrv_types.h:370
GattId.
Definition: btdrv_types.h:376
Kernel-mode event structure.
Definition: event.h:13
Service object structure.
Definition: service.h:14
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
u32 Result
Function error code result type.
Definition: types.h:44
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21