Example #1
0
        public Task <IQApplicationInfoResult> GetApplicationInfoAsync(string appId, IQDevice device)
        {
            var completionSource = new TaskCompletionSource <IQApplicationInfoResult>();

            MainThreadHandler.Post(() => GetApplicationInfo(appId, device, new IQApplicationInfoListenerImpl(completionSource)));
            return(completionSource.Task);
        }
Example #2
0
        public Task <IQOpenApplicationResult> OpenApplicationAsync(IQDevice device, IQApp app)
        {
            var completionSource = new TaskCompletionSource <IQOpenApplicationResult>();

            MainThreadHandler.Post(() => OpenApplication(device, app, new IQOpenApplicationListenerImpl(completionSource)));
            return(completionSource.Task);
        }
Example #3
0
 public void OnMessageStatus(IQDevice paramIQDevice, IQApp paramIQApp, IQMessageStatus paramIQMessageStatus)
 {
     Debug.Assert(_completionSource != null && _objectPool != null);
     _completionSource.SetResult(new IQSendMessageResult(paramIQDevice, paramIQApp, paramIQMessageStatus));
     _completionSource = null;
     _objectPool.Free(this);
 }
Example #4
0
        public Task <IQSendMessageResult> SendMessageAsync(IQDevice device, IQApp app, Java.Lang.Object message)
        {
            var completionSource = new TaskCompletionSource <IQSendMessageResult>();

            MainThreadHandler.Post(() =>
            {
                IQSendMessageListenerImpl listener = ObjectPool.Allocate();
                listener.CompletionSource          = completionSource;
                SendMessage(device, app, message, listener);
            });
            return(completionSource.Task);
        }
        async void InitGarmin()
        {
            var commStrategy = IQ.IQConnectType.Wireless;

            _iq = IQ.GetInstance(this, commStrategy);
            var initStatus = await _iq.InitializeAsync(this, autoUI : true);

            if (initStatus.HasError)
            {
                Log.Error("BindingTest", $"Received garmin SDK error {initStatus.ErrorStatus}");
                return;
            }

            var knownDevices = _iq.KnownDevices;

            _device = knownDevices.First(dev => dev.FriendlyName == "vivoactive HR");
            IQDevice.IQDeviceStatus status = _iq.GetDeviceStatus(_device);
            if (status != IQDevice.IQDeviceStatus.Connected)
            {
                return;
            }

            var appInfo = await _iq.GetApplicationInfoAsync("fc4cdb94-9339-44e4-ad86-2d235312f0e7", _device);

            if (!appInfo.Installed)
            {
                Log.Error("BindingTest", "Application not installed");
                return;
            }

            _app = appInfo.App;
            var javaMap = new Java.Util.HashMap();

            javaMap.Put(1, 6);
            var messageStatus = await _iq.SendMessageAsync(_device, _app, javaMap);

            Log.Info("BindingTest", $"Message status {messageStatus.MessageStatus}");
        }
Example #6
0
 public IQOpenApplicationResult(IQDevice device, IQApp app, IQOpenApplicationStatus status)
 {
     Device = device;
     App    = app;
     Status = status;
 }
Example #7
0
 public void OnOpenApplicationResponse(IQDevice paramIQDevice,
                                       IQApp paramIQApp,
                                       IQOpenApplicationStatus paramIQOpenApplicationStatus)
 {
     _completionSource.SetResult(new IQOpenApplicationResult(paramIQDevice, paramIQApp, paramIQOpenApplicationStatus));
 }
Example #8
0
 public IQSendMessageResult(IQDevice device, IQApp app, IQMessageStatus messageStatus)
 {
     Device        = device;
     App           = app;
     MessageStatus = messageStatus;
 }