Beispiel #1
0
        void OnDiscoveredCharacteristic(object sender, CBServiceEventArgs e)
        {
            BLEService service = null;

            foreach (BLEService bles in services)
            {
                if (bles.UUID.StringValue == e.Service.UUID.ToString(true))
                {
                    service = bles;

                    break;
                }
            }

            foreach (CBCharacteristic cbc in e.Service.Characteristics)
            {
                BLECharacteristic blec = new BLECharacteristic(cbc);

                service.Characteristics.Add(blec);
            }

            EventHandler <BLEServiceEventArgs> handler = DiscoveredCharacteristic;

            if (handler != null)
            {
                BLEServiceEventArgs args = new BLEServiceEventArgs();
                args.Service = service;
                args.Error   = e.Error?.ToString();

                handler(this, args);
            }
        }
Beispiel #2
0
        void OnDiscoveredService(object sender, NSErrorEventArgs e)
        {
            foreach (CBService cbs in nativePeripheral.Services)
            {
                BLEService bles = new BLEService(cbs);

                services.Add(bles);
            }

            EventHandler <BLEErrorEventArgs> handler = DiscoveredService;

            if (handler != null)
            {
                BLEErrorEventArgs args = new BLEErrorEventArgs();
                args.Error = e.Error?.ToString();

                handler(this, args);
            }
        }