Пример #1
0
 static void pingReceived(object sender, MessageReceivedEventArgs e)
 {
     Console.WriteLine("Received a ping through generic endpoint handler");
 }
Пример #2
0
 void VersionReceived(object sender, MessageReceivedEventArgs e)
 {
     this.Firmware = Pebble.ParseVersion(e.Payload.Skip(1).Take(47).ToArray());
     this.RecoveryFirmware = Pebble.ParseVersion(e.Payload.Skip(48).Take(47).ToArray());
 }
Пример #3
0
 static void pebble_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     // Method for testing anything.
 }
Пример #4
0
 private void AppbankStatusResponseReceived(object sender, MessageReceivedEventArgs e)
 {
     switch (e.Payload[0])
     {
         case 1:
             EventHandler<AppbankContentsReceivedEventArgs> h = AppbankContentsReceived;
             if (h != null)
             {
                 h(this, new AppbankContentsReceivedEventArgs(e.Payload));
             }
             break;
         case 2:
             EventHandler<AppbankInstallMessageEventArgs> ih = AppbankInstallMessage;
             if (ih != null)
             {
                 ih(this, new AppbankInstallMessageEventArgs(e.Payload));
             }
             break;
     }
 }
Пример #5
0
        void PhoneVersionReceived(object sender, MessageReceivedEventArgs e)
        {
            byte[] prefix = { 0x01, 0xFF, 0xFF, 0xFF, 0xFF };
            byte[] session = BitConverter.GetBytes(sessionCaps);
            byte[] remote = BitConverter.GetBytes(remoteCaps);
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(session);
                Array.Reverse(remote);
            }

            byte[] msg = new byte[0];
            msg = msg.Concat(prefix).Concat(session).Concat(remote).ToArray();
            sendMessage(Endpoints.PHONE_VERSION, msg);
        }
Пример #6
0
 void PhoneVersionReceived(object sender, MessageReceivedEventArgs e)
 {
     var msg = Util.Pack("!bBBBBII",0x01,0xFF,0xFF,0xFF,0xFF,sessionCaps,remoteCaps);
     sendMessage(Endpoints.PHONE_VERSION, msg);
 }
Пример #7
0
            void PutBytesReceived(object sender, MessageReceivedEventArgs e)
            {
                switch (state_)
                {
                    case PutBytesState.WaitForToken:
                        {
                            var unpacked = Util.Unpack("!bI", e.Payload);
                            byte res = Convert.ToByte(unpacked[0]);
                            if (res != 1)
                            {
                                //throw new Exception("failed to wait");
                                HasError = true;
                            }
                            token_ = (uint)unpacked[1];
                            left_ = buffer_.Length;
                            state_ = PutBytesState.InProgress;
                            send();
                        }
                        break;
                    case PutBytesState.InProgress:
                        {
                            var unpacked = Util.Unpack("!b", e.Payload);
                            byte res = Convert.ToByte(unpacked[0]);
                            if (res != 1)
                            {
                                abort();
                                return;
                            }
                            if (left_ > 0)
                                send();
                            else
                            {
                                state_ = PutBytesState.Commit;
                                commit();
                            }
                        }
                        break;
                    case PutBytesState.Commit:
                        {
                            var unpacked = Util.Unpack("!b", e.Payload);
                            byte res = Convert.ToByte(unpacked[0]);
                            if (res != 1)
                            {
                                abort();
                                return;
                            }
                            state_ = PutBytesState.Complete;
                            complete();
                        }
                        break;
                    case PutBytesState.Complete:
                        {
                            var unpacked = Util.Unpack("!b", e.Payload);
                            byte res = Convert.ToByte(unpacked[0]);
                            if (res != 1)
                            {
                                abort();
                                return;
                            }
                            IsDone = true;
                        }
                        break;

                }
            }
Пример #8
0
            void PutBytesReceived(object sender, MessageReceivedEventArgs e)
            {
                switch (state_)
                {
                case PutBytesState.WaitForToken:
                {
                    var  unpacked = Util.Unpack("!bI", e.Payload);
                    byte res      = Convert.ToByte(unpacked[0]);
                    if (res != 1)
                    {
                        //throw new Exception("failed to wait");
                        HasError = true;
                    }
                    token_ = (uint)unpacked[1];
                    left_  = buffer_.Length;
                    state_ = PutBytesState.InProgress;
                    send();
                }
                break;

                case PutBytesState.InProgress:
                {
                    var  unpacked = Util.Unpack("!b", e.Payload);
                    byte res      = Convert.ToByte(unpacked[0]);
                    if (res != 1)
                    {
                        abort();
                        return;
                    }
                    if (left_ > 0)
                    {
                        send();
                    }
                    else
                    {
                        state_ = PutBytesState.Commit;
                        commit();
                    }
                }
                break;

                case PutBytesState.Commit:
                {
                    var  unpacked = Util.Unpack("!b", e.Payload);
                    byte res      = Convert.ToByte(unpacked[0]);
                    if (res != 1)
                    {
                        abort();
                        return;
                    }
                    state_ = PutBytesState.Complete;
                    complete();
                }
                break;

                case PutBytesState.Complete:
                {
                    var  unpacked = Util.Unpack("!b", e.Payload);
                    byte res      = Convert.ToByte(unpacked[0]);
                    if (res != 1)
                    {
                        abort();
                        return;
                    }
                    IsDone = true;
                }
                break;
                }
            }
Пример #9
0
 void PutBytesReceived(object sender, MessageReceivedEventArgs e)
 {
 }
Пример #10
0
 void trigger(object sender, MessageReceivedEventArgs e)
 {
     pebble.DeregisterEndpointCallback(endpoint, trigger);
     Result    = (T)Activator.CreateInstance(typeof(T), endpoint, e.Payload);
     Triggered = true;
 }