Corrigé le problème de driver LTE. Prêt à apporter au chalet

This commit is contained in:
2025-07-10 18:09:53 -04:00
parent 06ab16b771
commit 647f38c4ca
15 changed files with 10046 additions and 15560 deletions
+4 -2
View File
@@ -77,7 +77,7 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
if(strncmp("+CAOPEN:",mInputString,strlen("+CAOPEN:")) == 0)
{
int result = atoi(&mInputString[11]);
if(StrLen == 12 && mInputString[11] == '0') //The connection on port 0 is established
if(StrLen >= 12 && mInputString[11] == '0') //The connection on port 0 is established
{
LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_CONNECTED);
}
@@ -147,6 +147,7 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
{
if(strncmp("+CARECV:",mInputString,strlen("+CARECV:")) == 0) //+CARECV: 4,test
{
// printf("ATCmdInterpreter : Received +CARECV, storing data in buffer, waiting for OK\n\r");
memset(mMasterData,0,100);
mMasterDataSize = 0;
char *token;
@@ -168,7 +169,7 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
}
if(strncmp(mInputString,"OK",2) == 0) //The command was executed
{
// printf("ATCmdInterpreter : Received OK, calling LTEModuleDataReceived\n\r");
LTEModuleDataReceived(mMasterData,mMasterDataSize);
// LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK);
}
@@ -197,6 +198,7 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
{
if(strncmp("+CADATAIND:",mInputString,strlen("+CADATAIND:")) == 0)
{
// printf("ATCmdInterpreter : Received +CADATAIND, calling NewDataReady\n\r");
LTEModuleNewDataReady();
}
if(strncmp("+APP PDP:",mInputString,strlen("+APP PDP:")) == 0)
+1 -1
View File
@@ -296,7 +296,7 @@ enum CHALET_CMDS
CHALET_DO_HARAKIRI_CONFIRMATION,
CHALET_REBOOT_CPU_REQUEST,
CHALET_REBOOT_CPU_RESPONSE,
CHALET_GET_STORED_WIFI_SETTINGS_REQUEST,
CHALET_GET_STORED_WIFI_SETTINGS_REQUEST,//14
CHALET_GET_STORED_WIFI_SETTINGS_RESPONSE,
CHALET_SET_STORED_WIFI_SETTINGS_REQUEST,
CHALET_SET_STORED_WIFI_SETTINGS_RESPONSE,
+182 -3
View File
@@ -165,6 +165,8 @@ void TickLTEModule()
void LTEModuleNewData(unsigned char Data)
{
// printf("%c - 0x%x\n",Data,Data);
if(mIsPassthroughEnabled == true)
{
SyslogNewByte(Data);
@@ -177,10 +179,131 @@ void LTEModuleNewData(unsigned char Data)
SyslogNewByte(Data);
}
if(Data == '\n') //ignore line feeds
mATCmd[mNbCmdCharsReceived++] = Data;
if(mLTEModuleOperationSMState == LTE_MODULE_OPERATION_SENDING_DATA_STATE && Data == '>')
{
LTESendMasterBufferToModule();
}
if(Data == 0x0A) //Line feed... '\n'
{
if(mNbCmdCharsReceived >= 2)
{
if(mATCmd[mNbCmdCharsReceived-2] == 0x0D) //do we have the escape sequence? \r\n ??
{
//check if it's part of a data payload
if(strncmp("+CARECV:",mATCmd,strlen("+CARECV:")) == 0)
{
// printf("3\n");
char DataSzString[2];
DataSzString[0] = mATCmd[9];
int LenghtSize = 1;
if(mATCmd[10] != ',')
{
// printf("4\n");
DataSzString[1] = mATCmd[10];
LenghtSize = 2;
}
else
{
// printf("5\n");
DataSzString[1] = '\0';
}
int DataSize = 0;
DataSize = atoi(&DataSzString[0]);
// printf("Received escape sequence, DataSize = %d\n", DataSize);
//
//
//Check if we received the whole payload.
if(mNbCmdCharsReceived-1 < (DataSize + LenghtSize + 10))
{
//The \n character is part of the payload, continue receiving...
return;
if(Data != '\r')
}
}
if(mLTEModuleSMState == LTE_MODULE_SM_WAIT_RDY_STATE)
{
if(mATCmd[0] == 'R' && mATCmd[1] == 'D' && mATCmd[2] == 'Y')
{
LTEModuleSM(LTE_MODULE_RX_RDY_EVENT);
}
}
else if(mLTEModuleSMState == LTE_MODULE_SM_RUN_STATE)
{
AnalyzeNewATString(mATCmd,mNbCmdCharsReceived,mCurrentCmd);
}
mNbCmdCharsReceived = 0;
}
}
}
/*
if(Data == 0x0D) //ignore line feeds '\n'
{
if(mLTEModuleOperationSMState == LTE_MODULE_OPERATION_WAIT_FOR_DATA_STATE)
{
printf("1 mNbCmdCharsReceived = %d\n",mNbCmdCharsReceived);
// //Verify if \n is part of the payload data..
if(mNbCmdCharsReceived > 11) //Check that we received the datasize from module
{
printf("2\n");
// //Extract datasize
if(strncmp("+CARECV:",mATCmd,strlen("+CARECV:")) == 0)
{
// printf("3\n");
char DataSzString[2];
DataSzString[0] = mATCmd[9];
int LenghtSize = 1;
if(mATCmd[10] != ',')
{
// printf("4\n");
DataSzString[1] = mATCmd[10];
LenghtSize = 2;
}
else
{
// printf("5\n");
DataSzString[1] = '\0';
}
int DataSize = 0;
DataSize = atoi(&DataSzString[0]);
printf("Received \\n, DataSize = %d\n", DataSize);
//
//
//Check if we received the whole payload.
if(mNbCmdCharsReceived >= (DataSize + LenghtSize + 10))
{
// printf("6\n");
//The whole payload is received... do not store the \n
// printf("Received \\n, all payload received, ignoring. NbCharReceived = %d\n",mNbCmdCharsReceived);
}
else
{
// printf("7\n");
//The \n character is part of the payload, store it and continue receiving...
mATCmd[mNbCmdCharsReceived] = Data;
// printf("Received \\n in payload, storing data. NbCharReceived = %d\n",mNbCmdCharsReceived);
mNbCmdCharsReceived++;
}
}
}
}
// printf("8\n");
return;
}
if(Data != 0x0A) // '\r'
{
if(mLTEModuleOperationSMState == LTE_MODULE_OPERATION_SENDING_DATA_STATE && Data == '>')
{
@@ -199,6 +322,60 @@ void LTEModuleNewData(unsigned char Data)
}
else
{
// if(mLTEModuleOperationSMState == LTE_MODULE_OPERATION_WAIT_FOR_DATA_STATE)
// {
// //Verify if we really are done or if \r is part of the payload data..
// if(mNbCmdCharsReceived > 11) //Check that we received the datasize from module
// {
// //Extract datasize
// if(strncmp("+CARECV:",mATCmd,strlen("+CARECV:")) == 0)
// {
// char DataSzString[2];
// DataSzString[0] = mATCmd[9];
// int LenghtSize = 1;
// if(mATCmd[10] != ',')
// {
// DataSzString[1] = mATCmd[10];
// LenghtSize = 2;
// }
// else
// {
// DataSzString[1] = '\0';
// }
//
// int DataSize = 0;
// DataSize = atoi(&DataSzString[0]);
// printf("DataSzString : 0x%x - 0x%x\n",DataSzString[0],DataSzString[1]);
// printf("Received \\r, DataSize = %d\n", DataSize);
// printf("%s\n",mATCmd);
// //Check if we received the whole payload.
// if(mNbCmdCharsReceived >= (DataSize + LenghtSize + 10))
// {
// //The \r character is not part of the payload, continue normally
// printf("Received \\r normally, all payload received, continuing. NbCharReceived = %d\n",mNbCmdCharsReceived);
// }
// else
// {
// //The \r character is part of the payload, store it and continue receiving...
// mATCmd[mNbCmdCharsReceived] = Data;
// printf("Received \\r in payload, storing data. NbCharReceived = %d\n",mNbCmdCharsReceived);
// mNbCmdCharsReceived++;
//
// return;
// }
// }
// else
// {
// //weird stuff happening...
//
// }
// }
// else
// {
// //Weird stuff happening...
//
// }
// }
if(mNbCmdCharsReceived != 0) //New Command received
{
@@ -212,13 +389,14 @@ void LTEModuleNewData(unsigned char Data)
else if(mLTEModuleSMState == LTE_MODULE_SM_RUN_STATE)
{
AnalyzeNewATString(mATCmd,mNbCmdCharsReceived,mCurrentCmd);
mNbCmdCharsReceived = mNbCmdCharsReceived;
}
mNbCmdCharsReceived = 0;
}
}
*/
}
void LTEEnterSerialPassthrough()
@@ -289,6 +467,7 @@ void SendDataToLteModule(char *Data, int Size)
SyslogNewByte(*ptr++);
}
}
// printf("PIC: %s",Data);
UartTransmitData(LTE_IF_UART_PORT,Data,Size);
}
+2 -1
View File
@@ -98,7 +98,8 @@ void InitUart(void)
setbuf(stdout,NULL); //to use printf without \r
fflush(stdout);
UartOpenComPort(NETWORK_UART_PORT,9600,UART_ONE_STOP_BIT,UART_NO_PARITY); //Open LoRa module port
//UartOpenComPort(NETWORK_UART_PORT,9600,UART_ONE_STOP_BIT,UART_NO_PARITY); //Open LoRa module port
UartOpenComPort(NETWORK_UART_PORT,115200,UART_ONE_STOP_BIT,UART_NO_PARITY); //Open printf port
UartOpenComPort(LTE_IF_UART_PORT,115200,UART_ONE_STOP_BIT,UART_NO_PARITY); //Open LTE module port
#ifdef USE_PRINTF
//UartOpenComPort(CONSOLE_UART_PORT,115200,UART_ONE_STOP_BIT,UART_NO_PARITY); //Open console port
+2
View File
@@ -399,6 +399,7 @@ int InitWiFi()
char IP1,IP2,IP3,IP4,GW1,GW2,GW3,GW4;
//Load WiFi parameters from flash if present
#ifndef FORCE_WIFI_SETTINGS
if(SPIFlashIsPresent() == 1)
{
char StoredIPConfig[11];
@@ -456,6 +457,7 @@ int InitWiFi()
}
}
else
#endif
{
IP1 = STATIC_IP_ADDRESS_1;
IP2 = STATIC_IP_ADDRESS_2;
+8 -8
View File
@@ -100,7 +100,7 @@ void SendBootloaderByte(uint8 data);
int IsBootloaderClientConnected();
//#define FORCE_WIFI_SETTINGS
//#define USE_STATIC_IP
@@ -168,12 +168,12 @@ int IsBootloaderClientConnected();
//#define HOME_AP_NAME "ImprVEmard"
//#define HOME_AP_PWD "12345fffff"
#define HOME_AP_NAME "ChaletVilleEmard"
//#define HOME_AP_NAME "ImprVilleEmard"
//#define HOME_AP_NAME "ChaletVilleEmard"
#define HOME_AP_NAME "ImprVilleEmard"
//#define HOME_AP_NAME "ElRouteurDuChalet"
//#define HOME_AP_NAME "LeChalet"
#define HOME_AP_PWD "Evinrude30"
//#define HOME_AP_PWD "12345fffff"
//#define HOME_AP_PWD "Evinrude30"
#define HOME_AP_PWD "12345fffff"
#define TERMINAL_SERVER_PORT 85
#define NETWORK_SERVER_PORT 86
@@ -185,12 +185,12 @@ int IsBootloaderClientConnected();
//Module Static IP settings
#define STATIC_IP_ADDRESS_1 192
#define STATIC_IP_ADDRESS_2 168
#define STATIC_IP_ADDRESS_3 30
#define STATIC_IP_ADDRESS_4 127
#define STATIC_IP_ADDRESS_3 50
#define STATIC_IP_ADDRESS_4 125
#define GATEWAY_ADDRESS_1 192
#define GATEWAY_ADDRESS_2 168
#define GATEWAY_ADDRESS_3 30
#define GATEWAY_ADDRESS_3 50
#define GATEWAY_ADDRESS_4 1
#define DEFAULT_DNS_ADD_1 8
+12 -5
View File
@@ -242,17 +242,24 @@ void InitializeBoard()
}
void _mon_putc(char c)
{
// U2TXREG = c;
// while (U2STAbits.TRMT==0);
UartTransmitData(NETWORK_UART_PORT,&c,1);
}
#ifdef USE_PRINTF
void _mon_putc(char c)
{
U2TXREG = c;
while (U2STAbits.TRMT==0);
}
#elif defined USE_SYSLOG
void _mon_putc(char c)
{
SyslogNewByte(c);
}
//#elif defined USE_SYSLOG
//void _mon_putc(char c)
//{
// SyslogNewByte(c);
//}
#endif
+1 -1
View File
@@ -1,4 +1,4 @@
#define VERSIONNUMBER "CHALET_V01.01.6" //shall be 15 chars...
#define VERSIONNUMBER "CHALET_V01.02.1" //shall be 15 chars...
//Force DHCP instead of static IP.
//#define VERSIONNUMBER "CHALET_V01.00.1" //shall be 15 chars...
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
#
#Sun Mar 09 13:04:22 EDT 2025
#Thu Jul 10 17:51:07 EDT 2025
ChaletDuinoV2_795F512H_.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc32\\v1.33\\bin
default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc32\\v1.33\\bin
proj.dir=D\:\\Main\\PicDev\\Projets\\ChaletLora\\ChaletLora.X
+16 -16
View File
@@ -1,19 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="11">
<file>
<url>Source/BootloaderInterface.c</url>
<bookmark id="5">
<name/>
<line>387</line>
<key/>
</bookmark>
<bookmark id="4">
<name/>
<line>437</line>
<key/>
</bookmark>
</file>
<file>
<url>Source/hd44780.c</url>
<bookmark id="7">
@@ -31,17 +18,30 @@
</bookmark>
<bookmark id="10">
<name/>
<line>201</line>
<line>378</line>
<key/>
</bookmark>
<bookmark id="8">
<name/>
<line>443</line>
<line>622</line>
<key/>
</bookmark>
<bookmark id="9">
<name/>
<line>560</line>
<line>739</line>
<key/>
</bookmark>
</file>
<file>
<url>Source/BootloaderInterface.c</url>
<bookmark id="5">
<name/>
<line>387</line>
<key/>
</bookmark>
<bookmark id="4">
<name/>
<line>437</line>
<key/>
</bookmark>
</file>