L'envoi de données via la méthode iOS (writeValue: forCharacteristic: type :) fonctionne correctement sans erreur, mais la valeur ne change pas. Est-ce que tu sais pourquoi?iOS ble write not change value
> 2017-06-27 14:53:54.846963+0900 BluetoothSample[12662:5477661] Did
> write characteristic <CBCharacteristic: 0x1700ad500, UUID =
> 2A588021-4FB2-40F5- 8204-85315DEF11C5, properties = 0xA, value =
> <1357>, notifying = NO>
uint8_t val = 123;
NSData * valData = [NSData dataWithBytes:(void*)&val length:sizeof(val)];
[self.discoveredPeripheral writeValue:valData forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
- (void) peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
if (error) {
NSLog(@"didWriteValueForCharacteristic With error: %@", [error localizedDescription]);
self.receivePaketDataTextView.text = [[NSString alloc] initWithFormat:@"%@",[error localizedDescription]];
return ;
}
self.receivePaketDataTextView.text = [[NSString alloc] initWithFormat:@"%@",characteristic.value];
}
Lorsque j'essaie d'écrire, seuls les mêmes journaux sont imprimés.
Quelle valeur ne change pas? La valeur dans votre périphérique? Quel est votre périphérique? – Paulw11
J'essaie de changer la valeur caractéristique de ble à 123, mais cela ne change pas. – leptir
Je comprends cela, mais * où * ne voyez-vous pas le changement? Sur votre périphérique? Quel est votre périphérique? Un autre appareil iOS? Un autre appareil? Comment lisez-vous la valeur? Avez-vous un appel à votre méthode 'didWriteValueFor'' CBPeripheralDelegate'? Avez-vous une erreur dans cette méthode? – Paulw11