iOS corebluetooth data send issue

2019-08-04 06:57发布

I am using corebluetooh api to send data to Bluetooth device . on android its working fine but on ios its not working.

I am sending data as follows

 public override void DiscoveredCharacteristic(CBPeripheral peripheral, CBService service, NSError error)
            {
                System.Console.WriteLine("Discovered characteristics of " + peripheral);

                foreach (var characteristic in service.Characteristics)
                {
                    Console.WriteLine("Write Value of characteristic " + characteristic.ToString() + " is " + characteristic.Value);
                    var str = characteristic.UUID.ToString();
                    if (str.ToLower() == "00C957FB-8F6F-4E08-9ACB-000000000004".ToLower())
                    {

                        var hh1 = NSData.FromArray(new byte[] { 0x03, 0x1d, 0x00, 0x32, 0xb1, 0xc0 });

                        peripheral.WriteValue(hh1, characteristic, CBCharacteristicWriteType.WithResponse);
                     }

                    if (str.ToLower() == "00C957FB-8F6F-4E08-9ACB-000000000002".ToLower())
                    {
                        var hh = NSData.FromArray(new byte[] { 3, 29, 0, 50, 177, 192 });

                        peripheral.WriteValue(hh, characteristic, CBCharacteristicWriteType.WithResponse);
                     }                   
                }}

after writing the data WroteCharacteristicValue is getting called but under UpdatedCharacterteristicValue method characteristic. Value is null

Please help

0条回答
登录 后发表回答