iOS corebluetooth data send issue

被刻印的时光 ゝ 提交于 2020-01-05 07:28:35

问题


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

来源:https://stackoverflow.com/questions/42713531/ios-corebluetooth-data-send-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!