|
@@ -91,6 +91,7 @@ struct timeb endChargingTime[AC_QUANTITY];
|
|
|
sqlite3 *localDb;
|
|
|
|
|
|
struct SysConfigData SysConfigOrg;
|
|
|
+ParsingRatedCur modelnameInfo={0};
|
|
|
|
|
|
struct PreviousData
|
|
|
{
|
|
@@ -432,6 +433,31 @@ int getEth0MacAddress()
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+int isUap0up(void)
|
|
|
+{
|
|
|
+ int result = FAIL;
|
|
|
+
|
|
|
+ FILE *fp;
|
|
|
+ char cmd[256];
|
|
|
+ char buf[512];
|
|
|
+
|
|
|
+ strcpy(cmd, "ifconfig uap0");;
|
|
|
+ fp = popen(cmd, "r");
|
|
|
+ if(fp != NULL)
|
|
|
+ {
|
|
|
+ while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
+ {
|
|
|
+ if(strstr(buf, "uap0") > 0)
|
|
|
+ {
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pclose(fp);
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
//======================================================
|
|
|
// OCPP routine
|
|
|
//======================================================
|
|
@@ -1979,6 +2005,8 @@ int LoadSysConfigAndInfo(struct SysConfigData *ptr)
|
|
|
}
|
|
|
|
|
|
DEBUG_INFO("Load SysConfigData OK\n");
|
|
|
+
|
|
|
+ RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
|
|
|
|
|
|
return PASS;
|
|
|
}
|
|
@@ -2052,6 +2080,11 @@ void InitEthernet()
|
|
|
char tmpbuf[256];
|
|
|
unsigned int natInterface = 0;
|
|
|
|
|
|
+ // Detele bridge interface
|
|
|
+ system("/sbin/ifconfig uap0 down");
|
|
|
+ system("/sbin/ifconfig br0 down");
|
|
|
+ system("/usr/sbin/brctl delbr br0");
|
|
|
+
|
|
|
//Init Eth0 for internet
|
|
|
memset(tmpbuf,0,256);
|
|
|
sprintf(tmpbuf,"/sbin/ifconfig eth0 %s netmask %s up &",
|
|
@@ -2273,8 +2306,15 @@ void InitEthernet()
|
|
|
|
|
|
// Check is need to reset WIFI/4G module power
|
|
|
if((!ShmSysConfigAndInfo->SysInfo.OcppConnStatus) &&
|
|
|
- ((system("pidof -s Module_Wifi > /dev/null") != 0) || (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 0) || ((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) || ((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))) &&
|
|
|
- ((system("pidof -s Module_4g > /dev/null") != 0) || (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) || ((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
|
|
|
+
|
|
|
+ ((system("pidof -s Module_Wifi > /dev/null") != 0) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 0) ||
|
|
|
+ ((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == ON)) ||
|
|
|
+ ((ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApDisconnectViaWiFi == ON))) &&
|
|
|
+
|
|
|
+ ((system("pidof -s Module_4g > /dev/null") != 0) ||
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 0) ||
|
|
|
+ ((ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == 1) && (ShmStatusCodeData->InfoCode.InfoEvents.bits.ApnDisconnectVia4Gi == ON))))
|
|
|
{
|
|
|
if(DiffTimebWithNow(startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]) > TIMEOUT_SPEC_RESET_4G_WIFI_POWER)
|
|
|
{
|
|
@@ -2304,6 +2344,33 @@ void InitEthernet()
|
|
|
ftime(&startTime[0][TMR_IDX_RESET_4G_WIFI_POWER]);
|
|
|
}
|
|
|
|
|
|
+ // Bridge ethernet to uap0 to get dynamic ip address
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
|
|
|
+ (isUap0up() == PASS) &&
|
|
|
+ (access("/sys/class/net/br0/address", F_OK) == -1))
|
|
|
+ {
|
|
|
+ sleep(10);
|
|
|
+ system("/usr/sbin/brctl addbr br0");
|
|
|
+ system("/usr/sbin/brctl addif br0 eth0");
|
|
|
+ system("/usr/sbin/brctl addif br0 uap0");
|
|
|
+ system("/sbin/ifconfig br0 192.168.10.200 up");
|
|
|
+ system("/bin/sed -i '/interface/d' /etc/udhcpd.conf");
|
|
|
+ system("/bin/echo 'interface br0' >> /etc/udhcpd.conf");
|
|
|
+ system("kill udhcpd");
|
|
|
+ system("/usr/sbin/udhcpd /etc/udhcpd.conf");
|
|
|
+
|
|
|
+ DEBUG_INFO("Bridge uap0 & eth0 for local power sharing by ethernet.\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Change uap0 to low priority
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing &&
|
|
|
+ (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
|
|
|
+ (isUap0up() == PASS))
|
|
|
+ {
|
|
|
+ system("/sbin/ifmetric uap0 1");
|
|
|
+ }
|
|
|
+
|
|
|
sleep(5);
|
|
|
}
|
|
|
}
|
|
@@ -3479,6 +3546,13 @@ void checkTask()
|
|
|
DEBUG_INFO("Module_ProduceUtils not running, restart it.\n");
|
|
|
system ("/root/Module_ProduceUtils &");
|
|
|
}
|
|
|
+
|
|
|
+ if((system("pidof -s Module_PowerSharing > /dev/null") != 0) &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Module_PowerSharing not running, restart it.\n");
|
|
|
+ system ("/root/Module_PowerSharing &");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void checkConnectionTimeout()
|
|
@@ -3818,6 +3892,20 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Charging session target current check if OCPP disconnect and power sharing server connected
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index]>ShmCharger->gun_info[gun_index].primaryMcuState.rating_current?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmSysConfigAndInfo->SysInfo.localSharingInfo.AvailableShargingCurrent[gun_index];
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmCharger->gun_info[gun_index].targetCurrent != 0)
|
|
|
+ DEBUG_WARN("Disconnect from power sharing server, target current set to 0.\n");
|
|
|
+
|
|
|
+ ShmCharger->gun_info[gun_index].targetCurrent = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
switch(system_mode)
|
|
|
{
|
|
|
case SYS_MODE_IDLE:
|
|
@@ -4253,6 +4341,23 @@ int main(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //==============================================
|
|
|
+ // Check Local Power Sharing Communication
|
|
|
+ //==============================================
|
|
|
+ if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing > 0)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.localSharingInfo.isConnectedSharingServer)
|
|
|
+ {
|
|
|
+ if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == ON)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = OFF;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError == OFF)
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LocalPowerSharingCommunicationError = ON;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//==============================================
|
|
|
// Connector loop
|
|
|
//==============================================
|