ajustes nos parametros lora

This commit is contained in:
Diego Freitas 2025-05-19 07:35:58 -03:00
parent 1cee55d867
commit a48eb9b90d
25 changed files with 79 additions and 31 deletions

Binary file not shown.

View File

@ -892,7 +892,23 @@ namespace AgroBase.Models.Modules
},
Conectado = false,
Configurado = false,
Parametros = new LoRaParametrosModel()
ParametrosSet = new LoRaParametrosModel()
{
address = 2,
airRate = 0,
baudRate = 96,
parity = 0,
packetSize = 192,
power = 0,
tranMode = 64,
worCycle = 3,
channelRssi = 0,
lbt = 0,
packetRssi = 0,
channel = 23,
key = 0
},
ParametrosGet = new LoRaParametrosModel()
},
};
@ -919,7 +935,7 @@ namespace AgroBase.Models.Modules
});
loRaService.Conectado = false;
loRaService.Configurado = false;
loRaService.Parametros.UltimaLeitura = DateTime.MinValue;
loRaService.ParametrosGet.UltimaLeitura = DateTime.MinValue;
ReiniciarLeituras(Dados);
}
@ -3207,6 +3223,7 @@ namespace AgroBase.Models.Modules
}
case S_Code.sLRA:
{
var loraService = Variaveis.OperacaoEmAndamento.DispSen.Dados.loRaService;
switch (posicao)
{
case CanMessagePosicaoDados.Status:
@ -3214,10 +3231,8 @@ namespace AgroBase.Models.Modules
bool Conectado = data[2] == 1;
bool Configurado = data[3] == 1;
Console.WriteLine($"[LRA] Resposta {ID_Num} recebida. Conectado={Conectado}, Configurado={Configurado}");
var loraService = Variaveis.OperacaoEmAndamento.DispSen.Dados.loRaService;
loraService.Conectado = Conectado;
loraService.Configurado = Configurado;
loraService.Parametros.UltimaLeitura = DateTime.Now;
break;
}
case CanMessagePosicaoDados.Dados1:
@ -3233,17 +3248,15 @@ namespace AgroBase.Models.Modules
byte tranModeAndWorCycle = data[6];
byte tranMode = (byte)(tranModeAndWorCycle & 0b01000000);
byte worCycle = (byte)(tranModeAndWorCycle & 0b00000111);
var loraService = Variaveis.OperacaoEmAndamento.DispSen.Dados.loRaService;
Console.WriteLine($"[LRA] Resposta {ID_Num} recebida. Address={address.ToString("X")}, BaudRate={baud.ToString("X")}, AirRate={airRate.ToString("X")}, PacketSize={packetSize.ToString("X")}, Power={power.ToString("X")}, Channel={channel.ToString("X")}, transMode={tranMode.ToString("X")}, WorCycle={worCycle.ToString("X")}");
loraService.Parametros.address = address;
loraService.Parametros.baudRate = baud;
loraService.Parametros.airRate = airRate;
loraService.Parametros.packetSize = packetSize;
loraService.Parametros.power = power;
loraService.Parametros.channel = channel;
loraService.Parametros.worCycle = worCycle;
loraService.Parametros.tranMode = tranMode;
loraService.Parametros.UltimaLeitura = DateTime.Now;
loraService.ParametrosGet.address = address;
loraService.ParametrosGet.baudRate = baud;
loraService.ParametrosGet.airRate = airRate;
loraService.ParametrosGet.packetSize = packetSize;
loraService.ParametrosGet.power = power;
loraService.ParametrosGet.channel = channel;
loraService.ParametrosGet.worCycle = worCycle;
loraService.ParametrosGet.tranMode = tranMode;
break;
}
default:
@ -3323,6 +3336,7 @@ namespace AgroBase.Models.Modules
break;
}
}
loraService.ParametrosGet.UltimaLeitura = DateTime.Now;
break;
}
case S_Code.sTOD:

View File

@ -22,7 +22,8 @@ namespace AgroBase.Services
return Conectado && Configurado;
}
}
public LoRaParametrosModel Parametros { get; set; }
public LoRaParametrosModel ParametrosSet { get; set; }
public LoRaParametrosModel ParametrosGet { get; set; }
public List<FuncoesPinout> Funcoes { get; set; }
public List<(int, CanMessagePosicaoDados, byte[])> ProtocoloConfiguracao(PinoutDataModel Pinout, bool conectar)
@ -41,11 +42,11 @@ namespace AgroBase.Services
List<byte> config2 = new List<byte>
{
Parametros.address,
Parametros.baudAndAirRate,
Parametros.packetSizeAndPower,
Parametros.channel,
Parametros.tranModeAndWorCycle
ParametrosSet.address,
ParametrosSet.baudAndAirRate,
ParametrosSet.packetSizeAndPower,
ParametrosSet.channel,
ParametrosSet.tranModeAndWorCycle
};
Console.WriteLine($"Parametros de configuracao LoRa: {FuncoesGlobais.ConverterComandoBytesParaTexto(config2.ToArray())}");
@ -65,23 +66,21 @@ namespace AgroBase.Services
while (!sucesso && inicio.AddMilliseconds(2000) > DateTime.Now)
{
await Task.Delay(10);
sucesso = Parametros.UltimaLeitura < inicio;
sucesso = ParametrosGet.UltimaLeitura < inicio;
}
return (sucesso, Parametros);
return (sucesso, ParametrosGet);
}
public async Task<(bool, LoRaParametrosModel)> RedefinirParametros(LoRaParametrosModel parametros)
{
Parametros = parametros.Clone();
ParametrosSet = parametros.Clone();
Configurado = false;
DateTime inicio = DateTime.Now;
Variaveis.OperacaoEmAndamento.DispSen?.EnviarProtocolosConfiguracao(true);
while (!Configurado && inicio.AddMilliseconds(2000) > DateTime.Now)
{
await Task.Delay(10);
}
return (Configurado, Parametros);
bool configurado() => Configurado;
await FuncoesGlobais.AguardarCondicaoAsync(configurado, 2000, 100);
return (Configurado, ParametrosGet);
}
public bool EnviarDadosLoRaViaCAN(byte[] payload)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -160,7 +160,7 @@ namespace AgroMonitor.Forms
bool Conectado = Equipamento.RecebidoEm.AddMilliseconds(VariaveisEquipamento.TempoEntrePingsConexao) > DateTime.Now;
txtCarroConectado.Text = Conectado ? "Sim" : "Não";
if (Equipamento.Momento > MomentoLog)
if (Equipamento.RecebidoEm > MomentoLog)
{
MomentoLog = Equipamento.Momento;

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,27 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1 @@
[{"description":"treehash per file","signed_content":{"payload":"eyJjb250ZW50X2hhc2hlcyI6W3siYmxvY2tfc2l6ZSI6NDA5NiwiZGlnZXN0Ijoic2hhMjU2IiwiZmlsZXMiOlt7InBhdGgiOiJMSUNFTlNFIiwicm9vdF9oYXNoIjoiUGIwc2tBVUxaUzFqWldTQnctV0hIRkltRlhVcExiZDlUcVkwR2ZHSHBWcyJ9LHsicGF0aCI6ImtleXMuanNvbiIsInJvb3RfaGFzaCI6IjV3THVRS29HUW81aXd3eHk1ZmZGT1UxN1hjajdkVFJWbGR4OWNuY1hHUUkifSx7InBhdGgiOiJtYW5pZmVzdC5qc29uIiwicm9vdF9oYXNoIjoiWnlLb1lNaFZ6NVNsVDlIXzNUZ0J4TWxKOWJaOWhnR3RNQUpra3hCWDhycyJ9XSwiZm9ybWF0IjoidHJlZWhhc2giLCJoYXNoX2Jsb2NrX3NpemUiOjQwOTZ9XSwiaXRlbV9pZCI6ImtpYWJoYWJqZGJramRwamJwaWdmb2RiZGptYmdsY29vIiwiaXRlbV92ZXJzaW9uIjoiMjAyNS41LjE1LjEiLCJwcm90b2NvbF92ZXJzaW9uIjoxfQ","signatures":[{"header":{"kid":"publisher"},"protected":"eyJhbGciOiJSUzI1NiJ9","signature":"m6wMQqXNEKw_3hSXaOa4IcPAsygDHnGDX7W71n87JsRUTJo8bjHaDJMgKVtlBHRHsY0M1ji95bvTgrG_o3Pi_GsJxZWTX_0GNzJhmnX7xqBZoEYJ78QZbB2RfpIN2siM88yz_QVR6n-kogfEGqQwg4qcD1Rev_lMFvGznQZ0MTN91m6xWkGueL9b3wGF8ish27aTUXUAZoFdhyveAJwwZx7TZ2SN_6m2Dh4Q7N5ObRXCj9KCOBpJafWEHMbaMxDoTbtZvVNWJh1TFdxJ_YnnXuSo08O0Ej5QKGeHXdMprOrELHq2eRHKhj-fgjCs9m94HwDgzzXMozH-WM81eZ_r5-dImeBwM-UISUc_OkkEvLT7MbbEQ8Pd5J0UU2uOplXp1nV9-0m6aed42CFHg4ImyrQY5QM7YewaQV-9IIzKwuFDDmTDxalq59CI4EVwNbS0vZZuShq_Nlrxa4AghW2zrK8-urLG2whCDibvQkNEGr0W5rKG0I2Eyevrdglk-6dZbWjsqPTA6MXM31nVG0P3Yg-jKtG8GFrIZt04Rzjacx4Kj6WZqeN1wU1HTNNx-iimLaZ7iqj8X3G_1-MifGB7CNYWrpF2CegDG8L-KCL-3dIs-Eztyp23dnTi_DBK4-8iIAwl9vIMmHT_bZlw3KaRyoawpjRufOthBWh2LbRyDVA"},{"header":{"kid":"webstore"},"protected":"eyJhbGciOiJSUzI1NiJ9","signature":"HqKxKOCUP0euVwbDphrmanZqx5aBhNifi3-JaQGkQtx7SBOHyWNY3JeUK0ubDTcHzG3eOOXIaJziMhylX8V6Cw95UvuFgsZmWEXXQvJp8QkHf6XnJzGp0PYTLvXEyQX8YP8Msu5gXp-FlgcRzlRmngCDNzYPsSYHRDMfBnYCfhGb8xPeVCGzpEbFYG3NIiLS9BCyZn_BpWwU1QhN7l3zqwVsrQxHdWmBJWR2w77cLd2sbFyAFfKA79naGoA2tRY22jiXGRRqYFGOgxWtl2AAPuj-PuhoJXFinDRkpmaueR9mn9RQ-HghJKoAcRNTcSvhaxEh3zgWEQdKNLQgmF70PA"}]}}]

View File

@ -0,0 +1 @@
1.6B1561D18D6D7D238C1FA4FB8AEF54E1F1E6B574D958BC0A41CA955F90AFD7DC

View File

@ -0,0 +1,5 @@
{
"manifest_version": 2,
"name": "trustToken",
"version": "2025.5.15.1"
}