/// <summary>
        /// Sends a message to the Pebble.
        /// </summary>
        /// <param name="message">The message to send.</param>
        /// <returns>An async task to wait</returns>
        public Task WriteMessage(P3bbleMessage message)
        {
            return Task.Factory.StartNew(() =>
            {
                try
                {
                    this._mutex.WaitOne();

                    byte[] package = message.ToBuffer();

                    ServiceLocator.Logger.WriteLine("<< SEND MESSAGE FOR ENDPOINT " + ((Endpoint)message.Endpoint).ToString() + " (" + ((int)message.Endpoint).ToString() + ")");
                    ServiceLocator.Logger.WriteLine("<< PAYLOAD: " + BitConverter.ToString(package).Replace("-", ":"));

                    System.Diagnostics.Debug.WriteLine("<< SEND MESSAGE FOR ENDPOINT " + ((Endpoint)message.Endpoint).ToString() + " (" + ((int)message.Endpoint).ToString() + ")");
                    System.Diagnostics.Debug.WriteLine("<< PAYLOAD: " + BitConverter.ToString(package).Replace("-",":"));

                    this._writer.WriteBytes(package);
                    this._writer.StoreAsync().AsTask().Wait();

                    this._mutex.ReleaseMutex();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("<< EXCEPTION: " + e.Message);
                }
            });
        }
Beispiel #2
0
        public void WriteMessage(P3bbleMessage message)
        {
            _mutex.WaitOne();

            byte[] package = message.ToBuffer();
            Debug.WriteLine("Write Package: " + BitConverter.ToString(package));

            _writer.WriteBytes(package);
            _writer.StoreAsync().AsTask().Wait();

            _mutex.ReleaseMutex();
        }
Beispiel #3
0
        /// <summary>
        /// Sends a message to the Pebble.
        /// </summary>
        /// <param name="message">The message to send.</param>
        /// <returns>An async task to wait</returns>
        public Task WriteMessage(P3bbleMessage message)
        {
            return Task.Factory.StartNew(() =>
            {
                this._mutex.WaitOne();

                byte[] package = message.ToBuffer();
                Logger.WriteLine("<< SEND MESSAGE FOR ENDPOINT " + ((Endpoint)message.Endpoint).ToString() + " (" + ((int)message.Endpoint).ToString() + ")");
                Logger.WriteLine("<< PAYLOAD: " + BitConverter.ToString(package));

                this._writer.WriteBytes(package);
                this._writer.StoreAsync().AsTask().Wait();

                this._mutex.ReleaseMutex();
            });
        }
Beispiel #4
0
        /// <summary>
        /// Sends a message to the Pebble.
        /// </summary>
        /// <param name="message">The message to send.</param>
        /// <returns>An async task to wait</returns>
        public Task WriteMessage(P3bbleMessage message)
        {
            return Task.Factory.StartNew(() =>
            {
                this._mutex.WaitOne();

                byte[] package = message.ToBuffer();
                ServiceLocator.Logger.WriteLine("<< SEND MESSAGE FOR ENDPOINT " + ((Endpoint)message.Endpoint).ToString() + " (" + ((int)message.Endpoint).ToString() + ")");
                ServiceLocator.Logger.WriteLine("<< PAYLOAD: " + BitConverter.ToString(package));

                this._writer.WriteBytes(package);
                this._writer.StoreAsync().AsTask().Wait();

                this._mutex.ReleaseMutex();
            });
        }