コード例 #1
0
        public override void OnReadRemoteRssi(BluetoothGatt gatt, int rssi, GattStatus status)
        {
            base.OnReadRemoteRssi(gatt, rssi, status);

            Mvx.Trace("OnReadRemoteRssi: device {0} status {1} value {2}", gatt.Device.Name, status, rssi);

            //ToDo add device id, or some link between this callback and the corresponding device
            var args = new RssiReadEventArgs()
            {
                Rssi = rssi
            };

            switch (status)
            {
            case GattStatus.Failure:
            case GattStatus.InsufficientAuthentication:
            case GattStatus.InsufficientEncryption:
            case GattStatus.InvalidAttributeLength:
            case GattStatus.InvalidOffset:
            case GattStatus.ReadNotPermitted:
            case GattStatus.RequestNotSupported:
            case GattStatus.WriteNotPermitted:
                args.Error = new Exception(status.ToString());
                break;

            case GattStatus.Success:
                break;
            }

            RemoteRssiRead(this, args);
        }
コード例 #2
0
ファイル: Device.cs プロジェクト: cqllzp/xamarin-bluetooth-le
        private void OnRemoteRssiRead(object sender, RssiReadEventArgs e)
        {
            _gattCallback.RemoteRssiRead -= OnRemoteRssiRead;
            if (e.Error == null)
            {
                _rssi = e.Rssi;
            }

            RaiseRssiRead(e);
        }