Version en service lors de la fermeture du chalet
This commit is contained in:
parent
cff11a8401
commit
997f9d29cb
@ -13,13 +13,17 @@ int mBatterySOC;
|
||||
|
||||
float mVoltageMeanSum;
|
||||
int mVoltageMeanCount;
|
||||
int mCurrentMeanSum;
|
||||
int mCurrentMeanCount;
|
||||
bool mCurrentModuleOK;
|
||||
|
||||
void InitBatteryMonitor()
|
||||
{
|
||||
mBatteryVoltage = 0;
|
||||
mBatteryCurrent = 0;
|
||||
mBatterySOC = 0;
|
||||
mBatterySOC = 0;
|
||||
mVoltageMeanCount = 0;
|
||||
mCurrentMeanCount = 0;
|
||||
mCurrentModuleOK = true;
|
||||
|
||||
TimerStart(BATTERY_MONITOR_TIMER,100);
|
||||
@ -43,9 +47,10 @@ void BatteryMonitorTick()
|
||||
static int NetworkSendCounter; //Every second (10 counts) we want to send the battery data.
|
||||
if(IsTimerExpired(BATTERY_MONITOR_TIMER))
|
||||
{
|
||||
int adc;
|
||||
float conv, raw;
|
||||
unsigned int adc;
|
||||
double conv, raw;
|
||||
|
||||
AD1CHSbits.CH0SA = 1; //AN1
|
||||
AD1CON1bits.SAMP = 0;
|
||||
while(AD1CON1bits.DONE == 0);
|
||||
adc = ADC1BUF0;
|
||||
@ -83,14 +88,43 @@ void BatteryMonitorTick()
|
||||
mCurrentModuleOK = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AD1CHSbits.CH0SA = 2; //AN2
|
||||
AD1CON1bits.SAMP = 0;
|
||||
while(AD1CON1bits.DONE == 0);
|
||||
adc = ADC1BUF0;
|
||||
AD1CON1bits.SAMP = 1;
|
||||
// adc &= 0xFFFE;
|
||||
|
||||
//40mV/A
|
||||
|
||||
conv = (double)adc * 1.0;
|
||||
conv /= 1023;
|
||||
conv *= 3.3; //Volts
|
||||
conv /= 0.04; //Amps (40mV/A)
|
||||
|
||||
raw = conv;
|
||||
|
||||
//avoid rollovers in case the LORA network gets disconnected.
|
||||
//This could go for a long time but 5000 samples is too much anyways.
|
||||
if(mCurrentMeanCount >= 500)
|
||||
{
|
||||
mCurrentMeanCount = 0;
|
||||
mCurrentMeanSum = adc;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentMeanCount++;
|
||||
mCurrentMeanSum += adc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mBatteryCurrent = adc;
|
||||
}
|
||||
|
||||
// if(NetworkSendCounter++ == 10)
|
||||
// {
|
||||
// NetworkSendCounter = 0;
|
||||
// SendNetworkBatteryData();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float GetBatteryVoltage()
|
||||
@ -98,6 +132,7 @@ float GetBatteryVoltage()
|
||||
mBatteryVoltage = (mVoltageMeanSum/mVoltageMeanCount);
|
||||
mVoltageMeanSum = 0.0;
|
||||
mVoltageMeanCount = 0;
|
||||
|
||||
|
||||
return mBatteryVoltage;
|
||||
|
||||
@ -105,7 +140,11 @@ float GetBatteryVoltage()
|
||||
|
||||
int GetSolarPanelCurrent()
|
||||
{
|
||||
return mBatteryCurrent;
|
||||
//mBatteryCurrent = (mCurrentMeanSum/mCurrentMeanCount);
|
||||
mVoltageMeanCount = 0;
|
||||
mCurrentMeanSum = 0.0;
|
||||
|
||||
return mBatteryCurrent;
|
||||
}
|
||||
|
||||
int GetBatterySOC()
|
||||
|
||||
@ -84,7 +84,9 @@ int InitBoard()
|
||||
|
||||
AD1PCFG = 0xFFFF; //Sart with I/O pins configured as digital I/O
|
||||
AD1PCFGbits.PCFG1 = 0;
|
||||
AD1PCFGbits.PCFG2 = 0;
|
||||
TRISBbits.TRISB1 = PIN_INPUT;
|
||||
TRISBbits.TRISB2 = PIN_INPUT;
|
||||
|
||||
AD1CON1 = 0;
|
||||
AD1CON2 = 0;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "SPI_Flash.h"
|
||||
#include "FlashMapping.h"
|
||||
#include "LoraWatchdog.h"
|
||||
#include "versionbuild.h"
|
||||
//#include "WiFiCtrl.h"
|
||||
//
|
||||
|
||||
@ -26,6 +27,7 @@
|
||||
//};
|
||||
unsigned char mLoraPreamble[3]={0x00,LORA_MASTER_ADDRESS,LORA_CHANNEL};
|
||||
|
||||
static const char mFirmwareVersion[15] = VERSIONNUMBER;
|
||||
|
||||
void ExecuteMasterCommand(int Command, unsigned char *Data)
|
||||
{
|
||||
@ -221,6 +223,11 @@ void ExecuteMasterCommand(int Command, unsigned char *Data)
|
||||
SendLoraNetworkCommand(CHALET_SET_STORED_WIFI_SETTINGS_RESPONSE,&response,1);
|
||||
break;
|
||||
}
|
||||
case CHALET_GET_FIRMWARE_VERSION_REQUEST:
|
||||
{
|
||||
SendLoraNetworkCommand(CHALET_GET_FIRMWARE_VERSION_RESPONSE,(unsigned char*)mFirmwareVersion,15);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,6 +296,8 @@ enum CHALET_CMDS
|
||||
CHALET_GET_STORED_WIFI_SETTINGS_RESPONSE,
|
||||
CHALET_SET_STORED_WIFI_SETTINGS_REQUEST,
|
||||
CHALET_SET_STORED_WIFI_SETTINGS_RESPONSE,
|
||||
CHALET_GET_FIRMWARE_VERSION_REQUEST,
|
||||
CHALET_GET_FIRMWARE_VERSION_RESPONSE,
|
||||
|
||||
MAX_CHALET_CMD
|
||||
};
|
||||
|
||||
@ -61,7 +61,7 @@ struct sockaddr_in addr_in;
|
||||
tstrM2MIPConfig mModuleIPConfig;
|
||||
|
||||
bool mWiFiInitOK = false;
|
||||
char mWiFiState = WIFI_UNKNOWN_STATE;
|
||||
char mWiFiState = WIFI_MODULE_OFF_STATE; //JFM wifi module is always OFF at boot...
|
||||
|
||||
|
||||
/**
|
||||
@ -324,6 +324,11 @@ static void wifi_cb(uint8 u8MsgType, void *pvMsg)
|
||||
case M2M_WIFI_REQ_DHCP_CONF:
|
||||
{
|
||||
uint8 *pu8IPAddress = (uint8 *)pvMsg;
|
||||
// unsigned char ip1,ip2,ip3,ip4;
|
||||
// ip1 = pu8IPAddress[0];
|
||||
// ip2 = pu8IPAddress[1];
|
||||
// ip3 = pu8IPAddress[2];
|
||||
// ip4 = pu8IPAddress[3];
|
||||
/* Turn LED0 on to declare that IP address received. */
|
||||
printf("Wi-Fi IP is %u.%u.%u.%u\r\n", pu8IPAddress[0], pu8IPAddress[1], pu8IPAddress[2], pu8IPAddress[3]);
|
||||
gbConnectedWifi = true;
|
||||
@ -584,7 +589,7 @@ void TickWiFi()
|
||||
OpenTerminalServer();
|
||||
//OpenNetworkServer();
|
||||
// OpenBootloaderServer();
|
||||
BootloaderActivateBootloader();
|
||||
// BootloaderActivateBootloader();
|
||||
#ifdef USE_SYSLOG
|
||||
OpenSyslogServer();
|
||||
#endif
|
||||
|
||||
@ -101,11 +101,13 @@ int IsBootloaderClientConnected();
|
||||
|
||||
//Acces Point settings
|
||||
#define HOME_AP_SEC_TYPE M2M_WIFI_SEC_WPA_PSK
|
||||
#define HOME_AP_NAME "ImprVEmard"
|
||||
#define HOME_AP_PWD "12345fffff"
|
||||
//#define HOME_AP_NAME "ImprVEmard"
|
||||
//#define HOME_AP_PWD "12345fffff"
|
||||
|
||||
//#define HOME_AP_NAME "ChaletVilleEmard"
|
||||
//#define HOME_AP_NAME "LeChalet"
|
||||
//#define HOME_AP_PWD "Evinrude30"
|
||||
//#define HOME_AP_NAME "ElRouteurDuChalet"
|
||||
#define HOME_AP_NAME "LeChalet"
|
||||
#define HOME_AP_PWD "Evinrude30"
|
||||
|
||||
#define TERMINAL_SERVER_PORT 85
|
||||
#define NETWORK_SERVER_PORT 86
|
||||
|
||||
@ -137,7 +137,7 @@ int main(void)
|
||||
|
||||
#ifndef NO_WIFI
|
||||
InitTerminal();
|
||||
InitWiFi();
|
||||
// InitWiFi();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#define VERSIONNUMBER "ENG00.01"
|
||||
#define BUILDNUMBER "1"
|
||||
#define VERSIONNUMBER "CHALET_V01.00.1" //shall be 15 chars...
|
||||
//#define VERSIONNUMBER "-__--TEST--__" //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 @@
|
||||
#
|
||||
#Tue Oct 12 11:25:56 EDT 2021
|
||||
#Wed Oct 20 12:56:19 EDT 2021
|
||||
default.languagetoolchain.version=2.41
|
||||
ChaletDuino_775F512H_.languagetoolchain.version=1.33
|
||||
default.Pack.dfplocation=C\:\\Users\\JF\\.mchp_packs\\Microchip\\PIC32MX_DFP\\1.2.228
|
||||
|
||||
@ -17,10 +17,10 @@
|
||||
</editor-bookmarks>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/main.c</file>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/LoraWatchdog.c</file>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/ProtocolDefs.h</file>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/LoraNetworkInterface.c</file>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/LoraWatchdog.h</file>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/WiFiCtrl.h</file>
|
||||
<file>file:/D:/Main/PicDev/Projets/ChaletLora/ChaletLora.X/Source/versionbuild.h</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user