Exemplo n.º 1
0
        public LoginRequest(byte[] buffer, int pos)
        {
            PDU this_pdu = this;

            Entrante = true;
            UrbetrackCodec.DecodeHeaders(buffer, ref this_pdu, ref pos);
            IMEI           = UrbetrackCodec.DecodeString(buffer, ref pos);
            Password       = UrbetrackCodec.DecodeString(buffer, ref pos);
            Firmware       = UrbetrackCodec.DecodeString(buffer, ref pos);
            ConfigRevision = UrbetrackCodec.DecodeShort(buffer, ref pos);
            var d = Fleet.Devices.I().FindById(IdDispositivo);

            switch (CL)
            {
            case 0x00:
                DetectedDeviceType = DeviceTypes.Types.SISTELCOM_v1;
                break;

            case 0x01:
                PendingMessages    = UrbetrackCodec.DecodeShort(buffer, ref pos);
                DetectedDeviceType = DeviceTypes.Types.SISTELCOM_v2;
                break;

            case 0x02:
                DetectedDeviceType = DeviceTypes.Types.URB_v0_5;
                break;

            case 0x04:
                DetectedDeviceType = DeviceTypes.Types.URBMOBILE_v0_1;
                break;

            case 0x06:
                DetectedDeviceType = DeviceTypes.Types.URB_v0_7;
                QTreeRevision      = UrbetrackCodec.DecodeInteger(buffer, ref pos);
                XbeeHardware       = UrbetrackCodec.DecodeString(buffer, ref pos);
                XbeeFirmware       = UrbetrackCodec.DecodeString(buffer, ref pos);
                break;

            case 0x10:
                DetectedDeviceType = DeviceTypes.Types.URBETRACK_v0_8n;
                QTreeRevision      = UrbetrackCodec.DecodeInteger(buffer, ref pos);
                XbeeHardware       = UrbetrackCodec.DecodeString(buffer, ref pos);
                XbeeFirmware       = UrbetrackCodec.DecodeString(buffer, ref pos);
                SecureId           = UrbetrackCodec.DecodeString(buffer, ref pos);
                break;

            case 0x11:
            case 0x12:
            case 0x13:
            case 0x14:
                DetectedDeviceType = CL <= 0x12 ? DeviceTypes.Types.URBETRACK_v0_8 : DeviceTypes.Types.URBETRACK_v1_0;
                QTreeRevision      = UrbetrackCodec.DecodeInteger(buffer, ref pos);
                if (CL > 0x12)
                {
                    MessagesRevision = UrbetrackCodec.DecodeInteger(buffer, ref pos);
                }
                XbeeHardware = UrbetrackCodec.DecodeString(buffer, ref pos);
                XbeeFirmware = UrbetrackCodec.DecodeString(buffer, ref pos);
                SecureId     = UrbetrackCodec.DecodeString(buffer, ref pos);
                if (CL == 0x11 || CL == 0x13)
                {
                    GPSPoint        = UrbetrackCodec.DecodeGPSPointEx(buffer, ref pos, d);
                    RiderIdentifier = Encoding.ASCII.GetString(UrbetrackCodec.DecodeBytes(buffer, ref pos, 10));
                }
                break;

            default:
                DetectedDeviceType = DeviceTypes.Types.UNKNOW_DEVICE;
                break;
            }
        }