Core-Bluetooth-Transfer-Demo icon indicating copy to clipboard operation
Core-Bluetooth-Transfer-Demo copied to clipboard

didUpdateValueForCharacteristic not called

Open anitalanet opened this issue 9 years ago • 5 comments

Hello there..

I am new bie for bluetooth configuration... i am working from last two days on bluetooth communication...

but i am stuck on one point : according to my understanding the "didUpdateValueForCharacteristic" will calls when the characteristic value got changed but it will not call

I am making one function for writing data on characteristic but i am unable to get call of mention method//

At my device console : BSA_BleSeSendRsp (Which send responce after writing value) method call but i am unable to read the value...

one more thing when i write this : "readValueForCharacteristic" " arrPheriphals.objectAtIndex(0).readValueForCharacteristic(characteristic)" didUpdateValueForCharacteristic will get called on continues level

Can u please help me that

Thanks in advance

anitalanet avatar Apr 04 '16 07:04 anitalanet

@ananarola You don't have to invoke didUpdateValueForCharacteristic explicitly. In the configuration I've provided, the characteristic is configured to "notify" which will handle calling that method on the central whenever the receiver updates that characteristic's value.

transferCharacteristic = CBMutableCharacteristic(
    type: transferCharacteristicUUID,
    properties: CBCharacteristicProperties.Notify,
    value: nil,
    permissions: CBAttributePermissions.Readable
)

So, inside the sendData method, you'll find this:

didSend = peripheralManager!.updateValue(
    chunk,
    forCharacteristic: transferCharacteristic!,
    onSubscribedCentrals: nil
)

Which effectively transmits the current chunk of data. If everything else is configured correctly and the central and peripheral have connected to each other, each invocation of this method should cause didUpdateValueForCharacteristic to be called on the central.

mickmaccallum avatar Apr 04 '16 17:04 mickmaccallum

Hi i want to read values which is written on characteristic...how can i do this...i want it on specific button eevnt and same way i want to create function which write data on characteristic..how can i achive this....

One more question..i am lil bit confuisng about avertisment data.. what it actually ? need ur help and its really appriciated...

Thanks in advance

anitalanet avatar Apr 05 '16 08:04 anitalanet

anyone in @anitalanet 's position should start with Apple's core Core Bluetooth documentation

Fehrox avatar Apr 12 '18 11:04 Fehrox

This was an awesome code. Can anyone point me to an android equivalent for this code? Thank you!

yrvlucero avatar Jun 07 '18 06:06 yrvlucero

@yrvlucero, I've found the Android Bluetooth documentation very clear, and the libraries much easier to work with.

Fehrox avatar Jun 07 '18 10:06 Fehrox