예제 #1
0
파일: Features.cs 프로젝트: jesumarquez/lt
        public bool ReportTemperatureStop(ulong messageId)
        {
            var config = new StringBuilder();

            config.AppendLine(Mensaje.Factory(TemperatureActivateReports, 0));
            SendMessages(config.ToString(), messageId, null);
            return(true);
        }
예제 #2
0
파일: Features.cs 프로젝트: jesumarquez/lt
        public bool ReportTemperature(ulong messageId, int timerInterval)
        {
            var config = new StringBuilder();

            config.AppendLine(Mensaje.Factory(TemperatureActivateReports, 1));
            config.AppendLine(Mensaje.Factory("STD07{0:D6}000000", timerInterval));
            SendMessages(config.ToString(), messageId, null);
            return(true);
        }
예제 #3
0
파일: IFoteable.cs 프로젝트: jesumarquez/lt
        private String CheckConditionsBeforeSendPending(String pending)
        {
            if (!LastSent.IsOnTheFly())
            {
                string md = GetMessagingDevice();
                if (md == MessagingDevice.Garmin && BaseDeviceCommand.createFrom(pending, this, null).isGarminMessage())
                {
                    if (IsGarminConnected == null || !IsGarminConnected.Value)
                    {
                        // var mid = NextSequence;
                        // pending = GarminFmi.EncodePing().ToTraxFm<String>(mid, this);
                        // LastSent = new INodeMessage(mid, pending, DateTime.UtcNow) { IsOnTheFly = true };
                        // STrace.Debug(typeof(IFoteable).FullName, this.GetDeviceId(), "GARMIN PING Sent");
                        LastSent = null;
                        return(null);
                    }
                }
                else
                {
                    ulong mid = ParserUtils.GetMsgIdTaip(pending);

                    if (pending.StartsWith(Reporte.WriteGgPrefix) &&
                        !_sdSession)
                    {
                        //si quiero escribir en la sd tengo que abrir sesion antes, y antes tengo que pedir la password para abrir sesion
                        STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd QUERING");
                        mid      = NextSequence;
                        pending  = Mensaje.Factory(mid, this, Reporte.QuerySdSessionPassword.TrimStart('>'));
                        LastSent = new INodeMessage(mid, pending, DateTime.UtcNow)
                        {
                            IsOnTheFly = true
                        };
                    }
                }
            }
            return(pending);
        }
예제 #4
0
파일: IFoteable.cs 프로젝트: jesumarquez/lt
        private bool CheckLastSentAndDequeueIt(String buffer, ulong msgId, ref IMessage salida)
        {
            var    result  = true;
            string LastCmd = LastSent.GetText(String.Empty);
            ulong  LastId  = LastSent.GetId();

            if (buffer.StartsWith(Reporte.SdLocked))
            {
                _sdSession = false;
                STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd BORRANDO_POR_LOCKED");
            }
            else if (buffer.StartsWith(Reporte.SdPassword))
            {
                //Debug.Assert(LastSent.IsOnTheFly() == true);
                if (LastCmd.StartsWith(Reporte.StartGgWriteSession) && (LastId == msgId))
                {
                    LastSent   = null;
                    _sdSession = true;
                    STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd ABIERTA");
                }
                else if (_sdSession)
                {
                    STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd NO_MANEJADO");
                }
                else if (LastId == msgId)
                {
                    ulong mid = NextSequence;


                    LastSent = new INodeMessage(mid,
                                                Mensaje.Factory(mid, this,
                                                                String.Format("{0}{1}",
                                                                              Reporte.StartGgWriteSession.TrimStart('>'),
                                                                              buffer.Substring(8, 8))),

                                                DateTime.MinValue)
                    {
                        IsOnTheFly = true
                    };

                    salida.AddStringToSend(LastSent.Text);

                    STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd ABRIENDO");
                }
                else
                {
                    STrace.Debug(typeof(Parser).FullName, Id,
                                 String.Format("Sesion de escritura en sd NADA (LastSent.GetId()={0} msgId={1})",
                                               LastSent.GetId(), msgId));
                }
            }
            else

            if (LastSent != null)
            {
                if (LastSent.IsExpired())
                {
                    LastSent = null;
                }
                else
                {
                    var lastDC     = BaseDeviceCommand.createFrom(LastCmd, this, null);
                    var respStatus = lastDC.isExpectedResponse(BaseDeviceCommand.createFrom(buffer, this, null));
                    switch (respStatus)
                    {
                    case DeviceCommandResponseStatus.Valid:
                        result = true;
                        Fota.Dequeue(this, lastDC.MessageId ?? null);
                        break;

                    case DeviceCommandResponseStatus.Invalid:
                        result = false;
                        break;

                    case DeviceCommandResponseStatus.Exception:
                        Fota.RollbackLastTransaction(this, lastDC.MessageId ?? null);
                        result = false;
                        break;
                    }
                }
            }
            return(result);
        }
예제 #5
0
파일: GarminFmi.cs 프로젝트: jesumarquez/lt
 public static T ToTraxFmTR1 <T>(this byte[] message, ulong mid, INode node)
 {
     //Debug.Assert(node != null);
     return(Mensaje.Factory <T>(mid, node, Mensaje.GarminFmTR1, encodeByteArrayForFmTr(message)));
 }
예제 #6
0
파일: Features.cs 프로젝트: jesumarquez/lt
 public bool Reboot(ulong messageId)
 {
     SendMessages(Mensaje.Factory("SSR55AA"), messageId, null);
     return(true);
 }
예제 #7
0
파일: Features.cs 프로젝트: jesumarquez/lt
 public bool RetrievePictures(ulong messageId, string from, string to)
 {
     STrace.Debug(GetType().FullName, Id, String.Format("RetrievePictures: MessageId:{0}; from:{1}; to:{2}", messageId, from, to));
     SendMessages(Mensaje.Factory((ulong)messageId, this, "QSDI,P,I{0},E{1}", from, to), messageId, null);
     return(true);
 }