Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS示例中自定义UUID对于BLE的含义是什么?_Ios_Objective C_Bluetooth_Bluetooth Lowenergy_Core Bluetooth - Fatal编程技术网

IOS示例中自定义UUID对于BLE的含义是什么?

IOS示例中自定义UUID对于BLE的含义是什么?,ios,objective-c,bluetooth,bluetooth-lowenergy,core-bluetooth,Ios,Objective C,Bluetooth,Bluetooth Lowenergy,Core Bluetooth,我是iOS开发新手,学习iOS的蓝牙低能耗(BLE,Bluetooth 4.0) 我研究了这个链接的示例代码 在这个链接中还有另一个类似的示例 上述两个链接上的应用程序讨论基于BLE的两台IOS设备之间的发送和接收文本数据。 应用程序可以选择是中央或外围,而中央将接收从外围发送的文本数据 它定义了UUID,就像头文件中的以下代码一样 #define TRANSFER_CHARACTERISTIC_UUID @"08590F7E-DB05-467E-8757-72F6FAEB13D4" 在

我是iOS开发新手,学习iOS的蓝牙低能耗(BLE,Bluetooth 4.0)

我研究了这个链接的示例代码

在这个链接中还有另一个类似的示例

上述两个链接上的应用程序讨论基于
BLE
的两台IOS设备之间的
发送和接收文本数据。
应用程序可以选择是
中央
外围
,而
中央
将接收从
外围
发送的文本数据

它定义了
UUID
,就像
头文件中的以下代码一样

#define TRANSFER_CHARACTERISTIC_UUID    @"08590F7E-DB05-467E-8757-72F6FAEB13D4"
中央
连接到
外设
后,它会从
外设
中发现特征

如果
UUID
等于
传输特性\u UUID
,则使用
设置通知值:YES
订阅它,如以下代码所示

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
{
    // Again, we loop through the array, just in case.
    for (CBCharacteristic *characteristic in service.characteristics) {

        // And check if it's the right one
        if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:TRANSFER_CHARACTERISTIC_UUID]]) {

            // If it is, subscribe to it
            [peripheral setNotifyValue:YES forCharacteristic:characteristic];
        }
    }

    // Once this is complete, we just need to wait for the data to come in.
}
问题如下:

第一个问题:

我在中找不到此UUID:@“08590F7E-DB05-467E-8757-72F6FAEB13D4”
。 这是由
终端中的
创建的吗

第二个问题:

如果我是
Central
,并且我已经通过使用
设置NotifyValue订阅了
特性
:是
,就像上面的代码一样

BLE将通过以下代码告知
中央
有新数据从
外围设备发送,概念正确吗

-(void)peripheral:(CBPeripheral*)peripheral didUpdateValueForCharacteristic:(CBCharacteristic*)特征错误:(NSError*)错误

我是IOS开发和BLE方面的新手

提前感谢。

第一个问题:

  • 是的,苹果甚至建议在各种WWDC视频中使用
    uuidgen
    生成这些uuid。128位UUID不是蓝牙SIG标准化的,您可以使用它们来运行自己的配置文件
第二个问题:

  • 是的,首先查找服务,然后查找特征,然后
    setNotifyValue:Yes
    。从现在起,您将通过
    [-cbperipheraldegate didUpdateValueForCharacteristic:error://接收来自外围设备的通知。当您手动读取特征时,将调用相同的回调(无法区分读取响应和核心蓝牙中的通知)

关于第一个问题:长UUID是自定义UUID(而标准UUID使用4hex)。这意味着他们不遵守任何标准,因为他们还不存在,或者因为他们是特殊的/适当的。此外,为了避免被所有不同类型的ID混淆: