大气网络公司网站模板,长链接转短链接,制作二维码的平台,德州核酸检测最新公告我们正在将MTU请求从Android发送到iOSAndroid-从此函数onServicesDiscovered回调请求MTU但是我不知道如何确定对等设备支持是否请求了MTU#xff0c;以及如何实际协商的MTU。 仅在API级别22(Android L 5.1)中添加了必需的函数#xff1a;BluetoothGattCallback.onMtuChanged(…我们正在将MTU请求从Android发送到iOSAndroid-从此函数onServicesDiscovered回调请求MTU但是我不知道如何确定对等设备支持是否请求了MTU以及如何实际协商的MTU。 仅在API级别22(Android L 5.1)中添加了必需的函数BluetoothGattCallback.onMtuChanged(BluetoothGatt gattint mtuint状态)。我的问题是我不知道我可以发送多少个字节的数据包。Overridepublic void onServicesDiscovered(BluetoothGatt gatt, int status) {if (status BluetoothGatt.GATT_SUCCESS) {//requestPriorityHigh();gatt.requestMtu(182);broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);List Services gatt.getServices();for (BluetoothGattService gattService : Services) {if (SERVICE_UUID.equals(gattService.getUuid())) {List gattCharacteristics gattService.getCharacteristics();for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {if (CHARACTERISTIC_UUID.equals(gattCharacteristic.getUuid())) {gatt.writeCharacteristic(gattCharacteristic);List gattDescriptors gattCharacteristic.getDescriptors();for (BluetoothGattDescriptor gattDescriptor : gattDescriptors) {gatt.readDescriptor(gattDescriptor);}}}}}} else {Log.w(MainActivity.TAG, onServicesDiscovered received: status);}}例如gatt.requestMtu(182)iOS-未触发didSubscribeTo特征回调- (void)peripheralManager:(CBPeripheralManager )peripheral central:(CBCentral )central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic{NOTIFY_MTU central.maximumUpdateValueLength;NSLog(Central subscribed to characteristic);NSLog(Supported to BLE Device Info:-- %lu,(unsigned long)[central maximumUpdateValueLength]);[peripheral setDesiredConnectionLatency:CBPeripheralManagerConnectionLatencyLow forCentral:central];}我们需要根据连接的BLE Devices.U设置数据包大小如果未请求MTU则对didSubscribeTo特性进行回调最小MTU大小为20。如何从android获取和设置此mtu大小。我们如何设置MTU