예제 #1
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(() =>
            {
                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);
                }
            });
        }
예제 #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();
        }
예제 #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();
            });
        }
예제 #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();
            });
        }