iOS-MTU大小,用于在iOS设备和外部配件之间进行BLE数据传输(BluetoothWatch) [英] iOS - MTU Size for BLE data transfer between iOS device and External Accessory(BluetoothWatch)

查看:548
本文介绍了iOS-MTU大小,用于在iOS设备和外部配件之间进行BLE数据传输(BluetoothWatch)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为使用BLE(CoreBluetooth)的蓝牙手表开发iOS应用程序(Objective-C),并且我的手表具有GATT蓝牙配置文件,iOS应用程序最低支持来自iOS7.

I'm Working on iOS Application(Objective-C) for Bluetooth watch which using BLE(CoreBluetooth), and my watch is having GATT Bluetooth Profile, iOS application minimum support is from iOS7.

我想知道我们如何使用Core Bluetooth框架在iOS设备和外部设备之间进行数据传输.

I wants to know How can we do data transfer between iOS device and external device using Core Bluetooth framework.

实际上,我正在研究蓝牙手表的固件升级"部分,每当收到任何更新时,我的iOS应用程序将从Web服务获取固件代码(二进制数据),然后将数据发送至蓝牙手表.

Actually I'm working on the Firmware upgrade section of my Bluetooth watch, My iOS application will get Firmware code (binary data) from web service whenever any update received and then it will send data to Bluetooth watch.

我已经搜索并获得了一个Apple示例代码:BTLE_Transfer: https://developer.apple.com/Library/ios/samplecode/BTLE_Transfer/Introduction/Intro.html

I have searched and got one Apple Sample code: BTLE_Transfer: https://developer.apple.com/Library/ios/samplecode/BTLE_Transfer/Introduction/Intro.html

我想示例代码在我的案例中没有用,因为它同时具有Central和Peripheral两个代码并在两个iOS设备之间传输数据.

I guess sample code was not useful in my case as its having Central and Peripheral both code and transferring data between two iOS device.

除了此示例代码之外,还有其他方法可以进行BLE数据传输吗?还是仅可以使用此示例代码?(如果是,怎么办?)

is there any other way apart from this sample code for BLE data transfer? or it's possible with this sample code only?(if yes how?)

已更新:

我的设备有1个服务,具有2个特征,一个特征为读取,另一特征为写入.

My device have 1 service which have 2 characteristic one for read and one for write.

根据我的工作流程,使用写特征:

According to my workflow using write charateristic:

  1. 使用WRITECHARACTERISTIC,我以大块形式发送固件代码的数据

[MYDEVICEINSTANCE writeValue:NSDATACHUNKforCharacteristic:WRITECHARACTERISTIC类型:CBCharacteristicWriteWithResponse];

[MYDEVICEINSTANCE writeValue:NSDATACHUNK forCharacteristic:WRITECHARACTERISTIC type:CBCharacteristicWriteWithResponse];

  1. 和委托方法" didWriteValueForCharacteristic "方法中,我正在通知读取特征,如下所示:
  1. and in delegate method "didWriteValueForCharacteristic" method I'm notifying read characteristic as below

[MYDEVICEINSTANCE setNotifyValue:TRUEforCharacteristic:READCHARACTERISTIC];

[MYDEVICEINSTANCE setNotifyValue:TRUE forCharacteristic:READCHARACTERISTIC];

  1. 在其中调用" didUpdateNotificationStateForCharacteristic "委托方法的地方,我正在检查READCHARACTERISTIC 是否正在通知,然后我调用
  1. which calls "didUpdateNotificationStateForCharacteristic" delegate method inside that I'm checking if READCHARACTERISTIC isNotifying or not then I call

[MYDEVICEINSTANCE readValueForCharacteristic:READCHARACTERISTIC];

  1. 调用委托方法" didUpdateValueForCharacteristic ",并且我正在使用 READCHARACTERISTIC.value
  2. 读取响应
  1. which call delegate method "didUpdateValueForCharacteristic" and I'm reading response using READCHARACTERISTIC.value

我的查询:

我想确认苹果允许的 MTU最大限制,用于从iOS应用程序进行外部设备通信,这是我从步骤1开始通过将 NSDATACHUNK 发送到BLE Watch进行的操作在iOS应用中使用 writeValue

I wants to confirm MTU maximum limit allowed by Apple for External device communication from iOS application, which I'm starting in step-1 by sending NSDATACHUNK to BLE Watch from iOS app using writeValue

我已经测试过可以发送 MTU = 255 大小的NSDATACHUNK,并且BLE手表也已成功接收到该数据.

I have tested that I can send NSDATACHUNK of MTU=255 size and BLE watch is receiving same successfully.

我在" Apple示例代码:BTLE_Transfer "中发现他们正在使用 MTU = 20 ,但是,我猜示例代码是针对iOS设备到iOS设备的通讯(请,如果我错了,请纠正我)

I have found in "Apple Sample code: BTLE_Transfer" they are using MTU=20 but, I guess that sample code is for iOS device to iOS device communication (Please, correct me if I'm wrong)

因此,如果我在iOS应用程序中使用 MTU = 250 进行BLE通信,那么苹果是否有可能拒绝我的应用程序?

So, If I use MTU=250 in my iOS application for BLE communication is there any chance that apple will reject my Application?

或者有没有人可以说 Apple允许的最大传输单元限制是多少?

每个建议都值得赞赏,

预先感谢

推荐答案

您可以使用所需的任何MTU大小(最大512).

You can use whatever MTU size you want (up to 512).

连接将使用的值始终是您和他们之间的最小值.

The value that the connection will use is always the minimum between yours and theirs.

因此,例如,如果他们要使用等于50的MTU,那么如果您的MTU小于50,则将使用该MTU;如果您的MTU小于50,则将使用该MTU.否则,选择50以上的任何值都是没有意义的,因为选择了50.

So, if for example they want to use MTU equal to, let's say, 50, then if your MTU is lower than 50, that one will be used; otherwise, whichever value you select above 50 is meaningless, as 50 gets picked.

这篇关于iOS-MTU大小,用于在iOS设备和外部配件之间进行BLE数据传输(BluetoothWatch)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆