Closed JLdevFr closed 1 year ago
I dont see any errors in your logs?
from your logs, the only service found is "[FBP-iOS] Found service: 0000FFF0-0000-1000-8000-00805F9B34FB"
with the example code, the error appear on the screen with a snackbar. On my app, the try cath return error since the last update of FBP : [FBP-iOS] handleMethodCall: writeCharacteristic flutter: communication error: PlatformException(writeCharacteristic, service not found 'fff0', null, null)
The ESPRESSIF modules are mounted on systems that were working very well until the latest updates of FBP. We have three types of modules installed on our products: BM71, Minew, and ESPRESSIF. Indeed, there is an error only on iOS and only with the ESPRESSIF modules.
try adding logs to this.
- (CBService *)getServiceFromArray:(NSString *)uuid array:(NSArray<CBService *> *)array
{
for (CBService *s in array)
{
NSLog(@"%@ %@", [s.UUID uuidStr], uuid); // add this log
if ([[s.UUID uuidStr] isEqualToString:uuid])
{
return s;
}
}
return nil;
}
i think these three functions need to be this.
you can try it and let me know.
- (CBService *)getServiceFromArray:(NSString *)uuid array:(NSArray<CBService *> *)array
{
for (CBService *s in array)
{
if ([s.UUID isEqual:[CBUUID UUIDWithString:uuid]])
{
return s;
}
}
return nil;
}
- (CBCharacteristic *)getCharacteristicFromArray:(NSString *)uuid array:(NSArray<CBCharacteristic *> *)array
{
for (CBCharacteristic *c in array)
{
if ([c.UUID isEqual:[CBUUID UUIDWithString:uuid]])
{
return c;
}
}
return nil;
}
- (CBDescriptor *)getDescriptorFromArray:(NSString *)uuid array:(NSArray<CBDescriptor *> *)array
{
for (CBDescriptor *d in array)
{
if ([d.UUID isEqual:[CBUUID UUIDWithString:uuid]])
{
return d;
}
}
return nil;
}
iv only use service and characteristics functions : flutter: ///// flutter: BluetoothService{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, isPrimary: true, characteristics: [BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff2, descriptors: [BluetoothDescriptor{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, characteristicUuid: fff2, descriptorUuid: 2902, lastValue: []}], properties: CharacteristicProperties{broadcast: false, read: false, writeWithoutResponse: false, write: true, notify: true, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []}, BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff1, descriptors: [], properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: false, notify: false, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []}], includedServices: []} flutter: BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff2, descriptors: [BluetoothDescriptor{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, characteristicUuid: fff2, descriptorUuid: 2902, lastValue: []}], properties: CharacteristicProperties{broadcast: false, read: false, writeWithoutResponse: false, write: true, notify: true, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []} flutter: /////
All the detection of service and characteristics is okay; however, as soon as there is an attempt to write or read, the 'service not found' error occurs : flutter: communication error: PlatformException(writeCharacteristic, service not found 'fff0', null, null)
i think these three functions need to be this.
you can try it and let me know.
see above ^^
i think these three functions need to be this. you can try it and let me know.
see above ^^
flutter: BluetoothService{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, isPrimary: true, characteristics: [BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff2, descriptors: [BluetoothDescriptor{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, characteristicUuid: fff2, descriptorUuid: 2902, lastValue: []}], properties: CharacteristicProperties{broadcast: false, read: false, writeWithoutResponse: false, write: true, notify: true, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []}, BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff1, descriptors: [], properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: false, notify: false, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []}], includedServices: []} flutter: BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff2, descriptors: [BluetoothDescriptor{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, characteristicUuid: fff2, descriptorUuid: 2902, lastValue: []}], properties: CharacteristicProperties{broadcast: false, read: false, writeWithoutResponse: false, write: true, notify: true, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []} flutter: BluetoothCharacteristic{remoteId: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, serviceUuid: fff0, secondaryServiceUuid: null, characteristicUuid: fff1, descriptors: [], properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: false, notify: false, indicate: false, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, value: []} [FBP-iOS] handleMethodCall: setNotifyValue flutter: PlatformException(setNotifyValue, service not found 'fff0', null, null)
?
- (CBService )getServiceFromArray:(NSString )uuid array:(NSArray<CBService > )array { for (CBService *s in array) { NSLog(@"%@ %@", [s.UUID uuidStr], uuid); // add this log if ([[s.UUID uuidStr] isEqualToString:uuid]) { return s; } } return nil; }
Sorry, I didn't understand what you were asking.
Here are the logs:
[FBP-iOS] didConnectPeripheral
flutter: [FBP] \^[[1;30m[[ OnConnectionStateChanged ]]\^[[0m result: \^[[1;33m{remote_id: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, connection_state: 1, disconnect_reason_code: null, disconnect_reason_string: nul
flutter: [FBP] \^[[1;30m[[ OnMtuChanged ]]\^[[0m result: \^[[1;33m{remote_id: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, success: 1, error_string: success, error_code: 0, mtu: 2
flutter: [FBP] \^[[1;30m[[ OnMtuChanged ]]\^[[0m result: \^[[1;33m{remote_id: DD017D95-5AD9-E191-11A4-6A0358E5F0C7, success: 1, error_string: success, error_code: 0, mtu: 50
flutter: [FBP] \^[[1;30m
thanks.
0000fff0-0000-1000-8000-00805f9b34fb fff0
yes this log confirms the issue, the fix here should fix it
(CBService )getServiceFromArray:(NSString )uuid array:(NSArray<CBService > )array { for (CBService *s in array) { if ([s.UUID isEqual:[CBUUID UUIDWithString:uuid]]) { return s; } } return nil; }
(CBCharacteristic )getCharacteristicFromArray:(NSString )uuid array:(NSArray<CBCharacteristic > )array { for (CBCharacteristic *c in array) { if ([c.UUID isEqual:[CBUUID UUIDWithString:uuid]]) { return c; } } return nil; }
(CBDescriptor )getDescriptorFromArray:(NSString )uuid array:(NSArray<CBDescriptor > )array { for (CBDescriptor *d in array) { if ([d.UUID isEqual:[CBUUID UUIDWithString:uuid]]) { return d; } } return nil; }
Indeed, this has resolved my issue. Thank you very much for your prompt responses!
fixed in 1.29.5
Requirements
Have you checked this problem on the example app?
Yes
FlutterBluePlus Version
1.29.4
Flutter Version
3.13.9
What OS?
iOS
OS Version
17.1.1
Bluetooth Module
Espressif esp32-c3 mini
What is your problem?
Communication with iOS with certain BLE modules has stopped for some time. The UUIDs have been shortened, which does not pose any issues. However, with certain BLE modules, we are able to connect to the BLE module, read its services and characteristics, but when we attempt to communicate, we encounter a 'service not found' error. I am using ESPRESSIF BLE modules. It's worth noting that this issue does not arise with Microchip or Minew modules. Additionally, I have also tried with the example application with DART 3.1.5.
Logs