예제 #1
0
 public GattDescriptor(IGattCharacteristic characteristic,
                       PeripheralContext context,
                       BluetoothGattDescriptor native) : base(characteristic, native.Uuid.ToString())
 {
     this.context = context;
     this.native  = native;
 }
예제 #2
0
 public Peripheral(
     ManagerContext centralContext,
     BluetoothDevice native
     ) : base(
         native.Name,
         ToDeviceId(native.Address).ToString()
         )
 {
     this.connSubject = new Subject <ConnectionState>();
     this.Context     = new PeripheralContext(centralContext, native);
 }
예제 #3
0
 public GattService(
     IPeripheral peripheral,
     PeripheralContext context,
     BluetoothGattService native
     ) : base(
         peripheral,
         native.Uuid.ToString(),
         native.Type == GattServiceType.Primary
         )
 {
     this.context = context;
     this.native  = native;
 }
예제 #4
0
 public GattCharacteristic(
     PeripheralContext context,
     Native native,
     IGattService service
     ) : base(
         service,
         native.Uuid.ToString(),
         (CharacteristicProperties)native.CharacteristicProperties
         )
 {
     this.context = context;
     this.Native  = native;
 }
예제 #5
0
 public GattCharacteristic(
     IGattService service,
     PeripheralContext context,
     BluetoothGattCharacteristic native
     )
     : base(
         service,
         native.Uuid.ToString(),
         (CharacteristicProperties)(int)native.Properties
         )
 {
     this.context = context;
     this.native  = native;
 }
예제 #6
0
        // BluetoothLEAdvertisementWatcher

        private void OnWatcherReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs args)
        {
            // Utils.Info("OnWatcherReceived: {0}", args.Advertisement.ManufacturerData.Count);

            lock (mLockObject)
            {
                if (mStatus != Status.Scan)
                {
                    Utils.Error("invalid status: {0}", mStatus.ToString());
                    return;
                }

                if (mDiscoveredPeripherals.Exists(ctx => ctx.Address == args.BluetoothAddress))
                {
                    return;
                }

                string deviceName = args.Advertisement.LocalName;
                if (string.IsNullOrEmpty(deviceName))
                {
                    // HACK: ScanResponseが取得できないので暫定
                    deviceName = args.BluetoothAddress.ToString();

                    /*
                     * Utils.Error("device-name not exists");
                     * return;
                     */
                }

                var context = new PeripheralContext(args.BluetoothAddress, mNextPeripheralId++, deviceName);
                mDiscoveredPeripherals.Add(context);

                Utils.Info("discover deviceName: {0} deviceId: {1}", context.Name, context.Id);

                mCallback.OnDiscover(context.Name, context.Id);
            }
        }
예제 #7
0
 public GattService(PeripheralContext context, Native native) : base(context.Peripheral, native.Uuid.ToString(), false)
 {
     this.context = context;
     this.native  = native;
 }
예제 #8
0
 public Peripheral(ManagerContext managerContext, BluetoothLEDevice native)
 {
     this.context = new PeripheralContext(managerContext, this, native);
     this.Name    = native.Name;
     this.Uuid    = native.GetDeviceId().ToString();
 }
 public GattReliableWriteTransaction(PeripheralContext context)
 {
     this.context = context;
     this.context.Gatt.BeginReliableWrite();
 }