Beispiel #1
0
 public EndpointSync(Pebble pebble, Pebble.Endpoints endpoint)
 {
     this.pebble   = pebble;
     this.endpoint = endpoint;
     Triggered     = false;
     pebble.RegisterEndpointCallback(endpoint, trigger);
 }
Beispiel #2
0
 /// <summary> Create new eventargs for a PING. </summary>
 /// <param name="payload">The payload. Has to be five bytes long,
 /// otherwise something's wrong.</param>
 public PingReceivedEventArgs(Pebble.Endpoints endpoint, byte[] payload)
     : base(endpoint, payload)
 {
     if (Payload.Length != 5)
     {
         throw new ArgumentOutOfRangeException("payload", "Payload for PING must be five bytes");
     }
     // No need to worry about endianness as ping cookies are echoed byte for byte.
     Cookie = BitConverter.ToUInt32(Payload, 1);
 }
Beispiel #3
0
        public AppbankInstallMessageEventArgs(Pebble.Endpoints endpoint, byte[] payload)
            : base(endpoint, payload)
        {
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(Payload, 1, 4);
            }
            uint result = BitConverter.ToUInt32(Payload, 1);

            MsgType = (MessageType)result;
        }
Beispiel #4
0
        /// <summary> Create a new TimeReceivedEventArgs.
        /// </summary>
        /// <param name="payload">Must be 5 bytes long.  The latter four are interpreted as a timestamp.</param>
        public TimeReceivedEventArgs(Pebble.Endpoints endpoint, byte[] payload)
            : base(endpoint, payload)
        {
            if (Payload.Length != 5)
            {
                throw new ArgumentOutOfRangeException("payload", "TIME payload must be 5 bytes, the latter four being the timestamp.");
            }

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(Payload, 1, 4);
            }

            int timestamp = BitConverter.ToInt32(Payload, 1);

            Time = Util.TimestampToDateTime(timestamp);
        }
Beispiel #5
0
        public LogReceivedEventArgs(Pebble.Endpoints endpoint, byte[] payload)
            : base(endpoint, payload)
        {
            byte[] metadata = new byte[8];
            byte   msgsize;

            Array.Copy(Payload, metadata, 8);

            /*
             * Unpack the metadata.  Eight bytes:
             * 0..3 -> integer timestamp
             * 4    -> Message level (severity)
             * 5    -> Size of the message
             * 6..7 -> Line number (?)
             */
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(metadata);
                Timestamp = Util.TimestampToDateTime(BitConverter.ToInt32(metadata, 4));
                Level     = metadata[3];
                msgsize   = metadata[2];
                LineNo    = BitConverter.ToInt16(metadata, 0);
            }
            else
            {
                Timestamp = Util.TimestampToDateTime(BitConverter.ToInt32(metadata, 0));
                Level     = metadata[4];
                msgsize   = metadata[5];
                LineNo    = BitConverter.ToInt16(metadata, 6);
            }
            // Now to extract the actual data
            byte[] _filename = new byte[16];
            byte[] _data     = new byte[msgsize];
            Array.Copy(Payload, 8, _filename, 0, 16);
            Array.Copy(Payload, 24, _data, 0, msgsize);

            Filename = Encoding.UTF8.GetString(_filename);
            Message  = Encoding.UTF8.GetString(_data);
        }
Beispiel #6
0
 public AppbankContentsReceivedEventArgs(Pebble.Endpoints endpoint, byte[] payload)
     : base(endpoint, payload)
 {
     AppBank = new AppBank(Payload);
 }
Beispiel #7
0
 /// <summary> Create a new media control event.  The payload should be
 /// 1 byte long.
 /// </summary>
 /// <param name="payload"></param>
 public MediaControlReceivedEventArgs(Pebble.Endpoints endpoint, byte[] payload)
     : base(endpoint, payload)
 {
     Command = (Pebble.MediaControls)Payload[0];
 }
Beispiel #8
0
 public MessageReceivedEventArgs(Pebble.Endpoints endpoint, byte[] payload)
 {
     Endpoint = endpoint;
     Payload  = new byte[payload.Length];
     payload.CopyTo(Payload, 0);
 }