9#include <QtCore/qoperatingsystemversion.h>
10#include <QtCore/qendian.h>
11#include <QtCore/qstring.h>
13#ifndef QT_IOS_BLUETOOTH
15#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
16#import <CoreFoundation/CoreFoundation.h>
17#import <CoreBluetooth/CBUUID.h>
39 NSString *
const fixed = [
address stringByReplacingOccurrencesOfString:
@"-" withString:
@":"];
40 return QString::fromNSString(fixed);
46#ifndef QT_IOS_BLUETOOTH
67 BluetoothDeviceAddress
a = {};
68 if (!qAddress.isNull()) {
70 a.data[0] = (
val >> 40) & 0xff;
71 a.data[1] = (
val >> 32) & 0xff;
72 a.data[2] = (
val >> 24) & 0xff;
73 a.data[3] = (
val >> 16) & 0xff;
74 a.data[4] = (
val >> 8) & 0xff;
75 a.data[5] =
val & 0xff;
83 const unsigned nBytes = 128 / std::numeric_limits<unsigned char>::digits;
87 length:nBytes], RetainPolicy::doInitialRetain);
94 if (!uuid || [uuid
length] != 16)
107 case kIOReturnSuccess:
110 case kIOReturnNoMemory:
112 case kIOReturnNoResources:
116 case kIOReturnStillOpen:
131 if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
132 qCWarning(QT_BT_DARWIN) <<
"IOBluetooth works only on the main thread or a"
133 <<
"thread with a running CFRunLoop";
153 if (uuid.data.length == 2) {
156 const uchar *
const src =
static_cast<const uchar *
>(uuid.data.bytes);
158 }
else if (uuid.data.length == 4) {
159 const uchar *
const src =
static_cast<const uchar *
>(uuid.data.bytes);
161 }
else if (uuid.data.length == 16) {
169 qCDebug(QT_BT_DARWIN) <<
"qt_uuid, invalid CBUUID, 2, 4, or 16 bytes expected, but got "
170 << uuid.data.length <<
" bytes length";
178 const auto asUInt128 = qtUuid.
toBytes();
181 const void *bytes = &asUInt128;
185 NSData *uuidData = [NSData dataWithBytes:bytes
length:
length];
193 return qtUuid == qtUuid2;
208 const char *
const src =
static_cast<const char *
>(
data.bytes);
214template<
class Integer>
219 const char *
const src =
reinterpret_cast<char *
>(&
n);
231 NSData *
const utf8Data = [
string dataUsingEncoding:NSUTF8StringEncoding];
258 if ([
obj isKindOfClass:[NSData
class]]) {
260 }
else if ([
obj isKindOfClass:[NSString
class]]) {
262 }
else if ([
obj isKindOfClass:[NSNumber
class]]) {
263 NSNumber *
const nsNumber =
static_cast<NSNumber *
>(
obj);
286 return MutableData([[NSMutableData alloc]
init], RetainPolicy::noInitialRetain);
288 MutableData
result([[NSMutableData alloc] initWithLength:qtData.
size()], RetainPolicy::noInitialRetain);
289 [
result replaceBytesInRange:NSMakeRange(0, qtData.
size())
302 queue = dispatch_queue_create(
label, DISPATCH_QUEUE_SERIAL);
304 qCCritical(QT_BT_DARWIN) <<
"failed to create dispatch queue with label"
311 dispatch_release(
queue);
319 dispatch_queue_t
queue;
327 return leQueue.
data();
#define QT_BT_MAC_AUTORELEASEPOOL
SerialDispatchQueue(const char *label)
dispatch_queue_t data() const
quint16 toUInt16(bool *ok=nullptr) const
Returns the 16 bit representation of this UUID.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QChar * data()
Returns a pointer to the data stored in the QString.
Id128Bytes toBytes(QSysInfo::Endian order=QSysInfo::BigEndian) const noexcept
ObjCStrongReference< CBUUID > cb_uuid(const QBluetoothUuid &qtUuid)
const int defaultLEScanTimeoutMS
bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid)
ObjCStrongReference< NSMutableData > mutable_data_from_bytearray(const QByteArray &qtData)
BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &qAddress)
QByteArray qt_bytearray(NSData *data)
QBluetoothUuid qt_uuid(NSUUID *nsUuid)
QString qt_address(NSString *address)
void qt_test_iobluetooth_runloop()
ObjCStrongReference< NSData > data_from_bytearray(const QByteArray &qtData)
ObjCStrongReference< IOBluetoothSDPUUID > iobluetooth_uuid(const QBluetoothUuid &uuid)
dispatch_queue_t qt_LE_queue()
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr T qToBigEndian(T source)
Q_DECL_COLD_FUNCTION Q_CORE_EXPORT QString qt_error_string(int errorCode=-1)
#define Q_LOGGING_CATEGORY(name,...)
#define qCCritical(category,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLuint GLsizei const GLchar * label
[43]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLchar * source
GLuint GLuint64EXT address
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
unsigned long long quint64