iOS corebluetooth数据发送问题

时间:2017-03-10 08:20:47

标签: ios visual-studio-2015 xamarin.ios core-bluetooth

我正在使用corebluetooh api将数据发送到蓝牙设备。在Android上它的工作正常,但在ios上它不起作用。

我发送的数据如下

 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);
                     }                   
                }}

写入数据后WroteCharacteristicValue被调用但在UpdatedCharacterteristicValue方法特征下。值为空

请帮忙

0 个答案:

没有答案