Exemple #1
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     UrbetrackCodec.EncodeString(ref buffer, ref pos, IMEI);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, Password);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, Firmware);
     UrbetrackCodec.EncodeShort(ref buffer, ref pos, ConfigRevision);
 }
Exemple #2
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     UrbetrackCodec.EncodeString(ref buffer, ref pos, Identifier);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, Description);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, File);
     UrbetrackCodec.EncodeInteger(ref buffer, ref pos, Revision);
     UrbetrackCodec.EncodeByte(ref buffer, ref pos, Flags);
 }
Exemple #3
0
            void SendFile(string order, string signature, string src_file, string path)
            {
                var full_file = String.Format(@"{0}\{1}", path, src_file);
                var fota_file = String.Format(@"{0}\{1}.l4pnp", path, src_file);

                if (!File.Exists(full_file))
                {
                    send("E");
                    return;
                }

                IO.PadFile(full_file, fota_file, 512, 0x00, true);

                using (var fs = File.OpenRead(fota_file))
                {
                    var filesize = (int)fs.Length;
                    if (filesize % 512 != 0)
                    {
                        send("E");
                        return;
                    }
                    var filepages = filesize / 512;
                    var md5Hasher = MD5.Create();
                    var b         = md5Hasher.ComputeHash(fs);
                    if (b.GetLength(0) != 16)
                    {
                        throw new Exception("el hash md5 no retorna 16 bytes.");
                    }
                    var buffer = new byte[256];
                    var pos    = 0;
                    send("D");
                    UrbetrackCodec.EncodeByte(ref buffer, ref pos, (byte)(Convert.ToInt16(order) & 0xFF));
                    UrbetrackCodec.EncodeString(ref buffer, ref pos, signature);
                    UrbetrackCodec.EncodeInteger(ref buffer, ref pos, filepages);
                    UrbetrackCodec.EncodeBytes(ref buffer, ref pos, b);
                    send(buffer, pos);
                }

                using (var fs = File.OpenRead(fota_file))
                {
                    var b = new byte[512];
                    while (fs.Read(b, 0, 512) > 0)
                    {
                        send(b, 512);
                    }
                }

                var cpos   = 0;
                var commit = new byte[3];

                UrbetrackCodec.EncodeByte(ref commit, ref cpos, (byte)'A');
                UrbetrackCodec.EncodeByte(ref commit, ref cpos, (byte)(Convert.ToInt16(order) & 0xFF));
                UrbetrackCodec.EncodeByte(ref commit, ref cpos, (byte)'R');
                send(commit, 3);
            }
Exemple #4
0
            bool SendFile(Device d, string name, string src_file, string path)
            {
                // var path = Process.GetApplicationFolder("temp");
                var full_file = String.Format(@"{0}\{1}", path, src_file);
                var fota_file = String.Format(@"{0}\{1}.l4pnp", path, src_file);

                if (!File.Exists(full_file))
                {
                    Send("E");
                    //T.ERROR("DEVICE[{0}]/FOTA: el archivo '{1}' no existe o no hay permisos.", d.LogId, full_file);
                    return(false);
                }

                IO.PadFile(full_file, fota_file, 512, 0x00, true);

                using (var fs = File.OpenRead(fota_file))
                {
                    var filesize = (int)fs.Length;
                    if (filesize % 512 != 0)
                    {
                        //T.ERROR("DEVICE[{0}]/FOTA: el archivo '{1}' no existe o no hay permisos.", d.LogId, full_file);
                        Send("C");
                        return(false);
                    }
                    var filepages = filesize / 512;
                    var md5Hasher = MD5.Create();
                    var b         = md5Hasher.ComputeHash(fs);
                    if (b.GetLength(0) != 16)
                    {
                        throw new Exception("el hash md5 no retorna 16 bytes.");
                    }
                    var buffer = new byte[256];
                    var pos    = 0;
                    Send("D");
                    UrbetrackCodec.EncodeString(ref buffer, ref pos, name);
                    UrbetrackCodec.EncodeInteger(ref buffer, ref pos, filepages);
                    UrbetrackCodec.EncodeBytes(ref buffer, ref pos, b);
                    Send(buffer, pos);
                }

                using (var fs = File.OpenRead(fota_file))
                {
                    var b = new byte[512];
                    while (fs.Read(b, 0, 512) > 0)
                    {
                        Send(b, 512);
                    }
                }

                return(true);
            }
Exemple #5
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     switch (CL)
     {
     case 0x00:     // SET/MODIFY
     case 0x01:     // DELETE
     case 0x02:     // DELETE ALL
     case 0x03:     // SET LOGISTIC STATE
     case 0x04:     // SHOW DRAFT
     case 0x05:     // SHOW CUSTOM
     case 0x06:     // DELIVER
     case 0x07:     // READ RECEIPT
         UrbetrackCodec.EncodeInteger(ref buffer, ref pos, Revision);
         UrbetrackCodec.EncodeByte(ref buffer, ref pos, Convert.ToByte(Code & 0xFF));
         UrbetrackCodec.EncodeByte(ref buffer, ref pos, Convert.ToByte((Source == 'M' ? 0x1 : 0) & (Destination == 'M' ? 0x02 : 0)));
         UrbetrackCodec.EncodeString(ref buffer, ref pos, Message);
         UrbetrackCodec.EncodeString(ref buffer, ref pos, ReplyFilter);
         UrbetrackCodec.EncodeInteger(ref buffer, ref pos, Session);
         break;
     }
 }
Exemple #6
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     UrbetrackCodec.EncodeString(ref buffer, ref pos, IdTarjeta);
     UrbetrackCodec.EncodeGPSPoint(ref buffer, ref pos, Posicion);
 }
Exemple #7
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     UrbetrackCodec.EncodeString(ref buffer, ref pos, signature);
 }
Exemple #8
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     UrbetrackCodec.EncodeInteger(ref buffer, ref pos, Order);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, CommandLine);
 }
Exemple #9
0
 public override void FinalEncode(ref byte[] buffer, ref int pos)
 {
     UrbetrackCodec.EncodeInteger(ref buffer, ref pos, Revision);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, Parameter);
     UrbetrackCodec.EncodeString(ref buffer, ref pos, Value);
 }