Réglé plein de bugs... prêt pour le chalet pour vrai...
This commit is contained in:
parent
647f38c4ca
commit
13655e40f4
@ -10,10 +10,12 @@ bool mCAStateReceived;
|
|||||||
char mMasterData[100];
|
char mMasterData[100];
|
||||||
int mMasterDataSize;
|
int mMasterDataSize;
|
||||||
char mInputString[100];
|
char mInputString[100];
|
||||||
|
bool mIsDataPending;
|
||||||
|
|
||||||
void InitATCmdInterpreter()
|
void InitATCmdInterpreter()
|
||||||
{
|
{
|
||||||
mCAStateReceived = false;
|
mCAStateReceived = false;
|
||||||
|
mIsDataPending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
||||||
@ -147,11 +149,11 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
|||||||
{
|
{
|
||||||
if(strncmp("+CARECV:",mInputString,strlen("+CARECV:")) == 0) //+CARECV: 4,test
|
if(strncmp("+CARECV:",mInputString,strlen("+CARECV:")) == 0) //+CARECV: 4,test
|
||||||
{
|
{
|
||||||
// printf("ATCmdInterpreter : Received +CARECV, storing data in buffer, waiting for OK\n\r");
|
// printf("ATCmdInterpreter : Received +CARECV, storing data in buffer, waiting for OK\n\r");
|
||||||
memset(mMasterData,0,100);
|
memset(mMasterData,0,100);
|
||||||
mMasterDataSize = 0;
|
mMasterDataSize = 0;
|
||||||
char *token;
|
char *token;
|
||||||
// sscanf("%d,%s",&mInputString[9],&DataSize,Data);
|
// sscanf("%d,%s",&mInputString[9],&DataSize,Data);
|
||||||
token = strtok(&mInputString[9],",");
|
token = strtok(&mInputString[9],",");
|
||||||
if(token != NULL)
|
if(token != NULL)
|
||||||
{
|
{
|
||||||
@ -169,9 +171,9 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
|||||||
}
|
}
|
||||||
if(strncmp(mInputString,"OK",2) == 0) //The command was executed
|
if(strncmp(mInputString,"OK",2) == 0) //The command was executed
|
||||||
{
|
{
|
||||||
// printf("ATCmdInterpreter : Received OK, calling LTEModuleDataReceived\n\r");
|
// printf("ATCmdInterpreter : Received OK, calling LTEModuleDataReceived\n\r");
|
||||||
LTEModuleDataReceived(mMasterData,mMasterDataSize);
|
LTEModuleDataReceived(mMasterData,mMasterDataSize);
|
||||||
// LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK);
|
// LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK);
|
||||||
}
|
}
|
||||||
else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed
|
else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed
|
||||||
{
|
{
|
||||||
@ -184,10 +186,25 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
|||||||
if(strncmp(mInputString,"OK",2) == 0) //The command was executed
|
if(strncmp(mInputString,"OK",2) == 0) //The command was executed
|
||||||
{
|
{
|
||||||
LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK);
|
LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK);
|
||||||
|
if(mIsDataPending == true)
|
||||||
|
{
|
||||||
|
mIsDataPending = false;
|
||||||
|
LTEModuleNewDataReady();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed
|
else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed
|
||||||
{
|
{
|
||||||
LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR);
|
LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR);
|
||||||
|
if(mIsDataPending == true)
|
||||||
|
{
|
||||||
|
mIsDataPending = false;
|
||||||
|
LTEModuleNewDataReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strncmp("+CADATAIND:",mInputString,strlen("+CADATAIND:")) == 0)
|
||||||
|
{
|
||||||
|
// We sometimes receive data while sending...
|
||||||
|
mIsDataPending = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -198,12 +215,12 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
|||||||
{
|
{
|
||||||
if(strncmp("+CADATAIND:",mInputString,strlen("+CADATAIND:")) == 0)
|
if(strncmp("+CADATAIND:",mInputString,strlen("+CADATAIND:")) == 0)
|
||||||
{
|
{
|
||||||
// printf("ATCmdInterpreter : Received +CADATAIND, calling NewDataReady\n\r");
|
// printf("ATCmdInterpreter : Received +CADATAIND, calling NewDataReady\n\r");
|
||||||
LTEModuleNewDataReady();
|
LTEModuleNewDataReady();
|
||||||
}
|
}
|
||||||
if(strncmp("+APP PDP:",mInputString,strlen("+APP PDP:")) == 0)
|
if(strncmp("+APP PDP:",mInputString,strlen("+APP PDP:")) == 0)
|
||||||
{
|
{
|
||||||
// LTEModuleNewDataReady();
|
// LTEModuleNewDataReady();
|
||||||
}
|
}
|
||||||
if(strncmp("+CASTATE:",mInputString,strlen("+CASTATE:")) == 0) //+CASTATE: 0,0
|
if(strncmp("+CASTATE:",mInputString,strlen("+CASTATE:")) == 0) //+CASTATE: 0,0
|
||||||
{
|
{
|
||||||
@ -216,6 +233,12 @@ int AnalyzeNewATString(char* Str, int StrLen, int CurCmd)
|
|||||||
LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED);
|
LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(strncmp("+CAURC:",mInputString,strlen("+CAURC:")) == 0)
|
||||||
|
{
|
||||||
|
// printf("ATCmdInterpreter : Received +CADATAIND, calling NewDataReady\n\r");
|
||||||
|
//LTEModuleReset();
|
||||||
|
LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,7 @@ void InitLTEModule()
|
|||||||
|
|
||||||
mMasterConnected = false;
|
mMasterConnected = false;
|
||||||
mAPNConnected = false;
|
mAPNConnected = false;
|
||||||
|
LTENetworkInterfaceInit();
|
||||||
}
|
}
|
||||||
int LTEModuleReset()
|
int LTEModuleReset()
|
||||||
{
|
{
|
||||||
@ -186,64 +187,72 @@ void LTEModuleNewData(unsigned char Data)
|
|||||||
LTESendMasterBufferToModule();
|
LTESendMasterBufferToModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Data == 0x0A) //Line feed... '\n'
|
if(Data == 0x0A) //Line feed... '\n' Ignore
|
||||||
{
|
{
|
||||||
|
if(mNbCmdCharsReceived < 2)
|
||||||
if(mNbCmdCharsReceived >= 2)
|
|
||||||
{
|
{
|
||||||
if(mATCmd[mNbCmdCharsReceived-2] == 0x0D) //do we have the escape sequence? \r\n ??
|
mNbCmdCharsReceived = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(Data == 0x0D) //escape sequence \r
|
||||||
|
{
|
||||||
|
|
||||||
|
//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 \r character is part of the payload, continue receiving...
|
||||||
|
return;
|
||||||
|
|
||||||
//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(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(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)
|
||||||
|
{
|
||||||
|
if(mNbCmdCharsReceived > 1)
|
||||||
|
{
|
||||||
|
AnalyzeNewATString(mATCmd,mNbCmdCharsReceived,mCurrentCmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mNbCmdCharsReceived = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#define VERSIONNUMBER "CHALET_V01.02.1" //shall be 15 chars...
|
#define VERSIONNUMBER "CHALET_V01.02.2" //shall be 15 chars...
|
||||||
//Force DHCP instead of static IP.
|
//Force DHCP instead of static IP.
|
||||||
|
|
||||||
//#define VERSIONNUMBER "CHALET_V01.00.1" //shall be 15 chars...
|
//#define VERSIONNUMBER "CHALET_V01.00.1" //shall be 15 chars...
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
#Thu Jul 10 17:51:07 EDT 2025
|
#Sun Jul 13 10:51:04 EDT 2025
|
||||||
ChaletDuinoV2_795F512H_.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc32\\v1.33\\bin
|
ChaletDuinoV2_795F512H_.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc32\\v1.33\\bin
|
||||||
default.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
|
proj.dir=D\:\\Main\\PicDev\\Projets\\ChaletLora\\ChaletLora.X
|
||||||
|
|||||||
@ -1,37 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="11">
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="11">
|
||||||
<file>
|
|
||||||
<url>Source/hd44780.c</url>
|
|
||||||
<bookmark id="7">
|
|
||||||
<name/>
|
|
||||||
<line>340</line>
|
|
||||||
<key/>
|
|
||||||
</bookmark>
|
|
||||||
</file>
|
|
||||||
<file>
|
|
||||||
<url>Source/SIM7080GInterface.c</url>
|
|
||||||
<bookmark id="11">
|
|
||||||
<name/>
|
|
||||||
<line>119</line>
|
|
||||||
<key/>
|
|
||||||
</bookmark>
|
|
||||||
<bookmark id="10">
|
|
||||||
<name/>
|
|
||||||
<line>378</line>
|
|
||||||
<key/>
|
|
||||||
</bookmark>
|
|
||||||
<bookmark id="8">
|
|
||||||
<name/>
|
|
||||||
<line>622</line>
|
|
||||||
<key/>
|
|
||||||
</bookmark>
|
|
||||||
<bookmark id="9">
|
|
||||||
<name/>
|
|
||||||
<line>739</line>
|
|
||||||
<key/>
|
|
||||||
</bookmark>
|
|
||||||
</file>
|
|
||||||
<file>
|
<file>
|
||||||
<url>Source/BootloaderInterface.c</url>
|
<url>Source/BootloaderInterface.c</url>
|
||||||
<bookmark id="5">
|
<bookmark id="5">
|
||||||
@ -45,6 +14,37 @@
|
|||||||
<key/>
|
<key/>
|
||||||
</bookmark>
|
</bookmark>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<url>Source/hd44780.c</url>
|
||||||
|
<bookmark id="7">
|
||||||
|
<name/>
|
||||||
|
<line>340</line>
|
||||||
|
<key/>
|
||||||
|
</bookmark>
|
||||||
|
</file>
|
||||||
|
<file>
|
||||||
|
<url>Source/SIM7080GInterface.c</url>
|
||||||
|
<bookmark id="11">
|
||||||
|
<name/>
|
||||||
|
<line>120</line>
|
||||||
|
<key/>
|
||||||
|
</bookmark>
|
||||||
|
<bookmark id="10">
|
||||||
|
<name/>
|
||||||
|
<line>387</line>
|
||||||
|
<key/>
|
||||||
|
</bookmark>
|
||||||
|
<bookmark id="8">
|
||||||
|
<name/>
|
||||||
|
<line>631</line>
|
||||||
|
<key/>
|
||||||
|
</bookmark>
|
||||||
|
<bookmark id="9">
|
||||||
|
<name/>
|
||||||
|
<line>748</line>
|
||||||
|
<key/>
|
||||||
|
</bookmark>
|
||||||
|
</file>
|
||||||
</editor-bookmarks>
|
</editor-bookmarks>
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group/>
|
<group/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user