Ejemplo n.º 1
0
        public AdvertisementData(SR result)
        {
            this.result = result;

            this.manufacturerData = new Lazy <ManufacturerData>(() =>
            {
                var manufacturerId = (ushort)this.result.ScanRecord.ManufacturerSpecificData.KeyAt(0);
                if (manufacturerId == 0)
                {
                    return(null);
                }

                var data = this.result.ScanRecord.GetManufacturerSpecificData(manufacturerId);
                return(new ManufacturerData(manufacturerId, data));
            });

            this.serviceUuids = new Lazy <Guid[]>(() =>
                                                  result
                                                  .ScanRecord
                                                  .ServiceUuids?
                                                  .Select(x => x.Uuid.ToGuid())
                                                  .ToArray()
                                                  );

            this.serviceData = new Lazy <AdvertisementServiceData[]>(() =>
                                                                     result
                                                                     .ScanRecord
                                                                     .ServiceData
                                                                     .Select(x => new AdvertisementServiceData(x.Key.Uuid.ToGuid(), x.Value))
                                                                     .ToArray()
                                                                     );
        }
Ejemplo n.º 2
0
        public AdvertisementData(SR result)
        {
            this.result = result;

            this.manufacturerData = new Lazy <ManufacturerData[]>(() =>
            {
                var md    = this.result.ScanRecord.ManufacturerSpecificData;
                var mdata = new ManufacturerData[md.Size()];
                //for (var i = 0; i < md.Size(); i++)
                //{
                //    var companyId = mdata.KeyAt(i);

                //    mdata[i] = null;
                //}

                return(mdata);
            });

            this.serviceUuids = new Lazy <Guid[]>(() =>
                                                  result
                                                  .ScanRecord
                                                  .ServiceUuids?
                                                  .Select(x => x.Uuid.ToGuid())
                                                  .ToArray()
                                                  );

            this.serviceData = new Lazy <AdvertisementServiceData[]>(() =>
                                                                     result
                                                                     .ScanRecord
                                                                     .ServiceData
                                                                     .Select(x => new AdvertisementServiceData(x.Key.Uuid.ToGuid(), x.Value))
                                                                     .ToArray()
                                                                     );
        }
Ejemplo n.º 3
0
        public AdvertisementData(SR result)
        {
            this.result = result;

            this.manufacturerData = new Lazy <ManufacturerData?>(() =>
            {
                var md = this.result.ScanRecord?.ManufacturerSpecificData;
                if (md == null || md.Size() == 0)
                {
                    return(null);
                }

                var manufacturerId = (ushort)md.KeyAt(0);
                if (manufacturerId == 0)
                {
                    return(null);
                }

                var data = this.result.ScanRecord !.GetManufacturerSpecificData(manufacturerId);
                return(new ManufacturerData(manufacturerId, data !));
            });

            this.serviceUuids = new Lazy <string[]?>(() =>
                                                     result
                                                     .ScanRecord?
                                                     .ServiceUuids?
                                                     .Select(x => x.Uuid.ToString())
                                                     .ToArray()
                                                     );

            this.serviceData = new Lazy <AdvertisementServiceData[]?>(() =>
                                                                      result
                                                                      .ScanRecord?
                                                                      .ServiceData?
                                                                      .Select(x => new AdvertisementServiceData(x.Key.Uuid.ToString(), x.Value))
                                                                      .ToArray() ?? Array.Empty <AdvertisementServiceData>()
                                                                      );
        }