mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-28 21:10:59 +00:00
Merge branch 'master' into dev-1.6.0
This commit is contained in:
@@ -62,6 +62,7 @@ MQTTClient mqtt(512);
|
||||
AmsMqttHandler* mqttHandler = NULL;
|
||||
|
||||
Stream *hanSerial;
|
||||
SoftwareSerial *swSerial = NULL;
|
||||
|
||||
GpioConfig gpioConfig;
|
||||
MeterConfig meterConfig;
|
||||
@@ -136,8 +137,11 @@ void setup() {
|
||||
|
||||
bool shared = false;
|
||||
config.getMeterConfig(meterConfig);
|
||||
Serial.flush();
|
||||
Serial.end();
|
||||
if(gpioConfig.hanPin == 3) {
|
||||
shared = true;
|
||||
<<<<<<< HEAD
|
||||
#if defined(ESP8266)
|
||||
SerialConfig serialConfig;
|
||||
#elif defined(ESP32)
|
||||
@@ -166,6 +170,9 @@ void setup() {
|
||||
|
||||
if(!shared) {
|
||||
Serial.begin(115200);
|
||||
=======
|
||||
setupHanPort(gpioConfig.hanPin, meterConfig.type);
|
||||
>>>>>>> master
|
||||
}
|
||||
|
||||
DebugConfig debug;
|
||||
@@ -477,9 +484,11 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
|
||||
if(Debug.isActive(RemoteDebug::INFO)) Debug.printf("(setupHanPort) Setting up HAN on pin %d with baud %d and parity %d\n", pin, baud, parityOrdinal);
|
||||
|
||||
HardwareSerial *hwSerial = NULL;
|
||||
if(pin == 3) {
|
||||
if(pin == 3 || pin == 113) {
|
||||
hwSerial = &Serial;
|
||||
}
|
||||
|
||||
|
||||
#if defined(ESP32)
|
||||
if(pin == 9) {
|
||||
hwSerial = &Serial1;
|
||||
@@ -496,6 +505,7 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
|
||||
|
||||
if(hwSerial != NULL) {
|
||||
debugD("Hardware serial");
|
||||
<<<<<<< HEAD
|
||||
Serial.flush();
|
||||
#if defined(ESP8266)
|
||||
SerialConfig serialConfig;
|
||||
@@ -511,21 +521,52 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
|
||||
break;
|
||||
case 10:
|
||||
serialConfig = SERIAL_7E1;
|
||||
=======
|
||||
hwSerial->flush();
|
||||
hwSerial->end();
|
||||
|
||||
switch(newMeterType) {
|
||||
case METER_TYPE_KAMSTRUP:
|
||||
case METER_TYPE_OMNIPOWER:
|
||||
hwSerial->begin(2400, SERIAL_8N1);
|
||||
>>>>>>> master
|
||||
break;
|
||||
default:
|
||||
serialConfig = SERIAL_8E1;
|
||||
break;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
#if defined(ESP32)
|
||||
hwSerial->begin(baud, serialConfig, -1, -1, invert);
|
||||
#else
|
||||
hwSerial->begin(baud, serialConfig, SERIAL_FULL, 1, invert);
|
||||
#endif
|
||||
=======
|
||||
#if defined(ESP8266)
|
||||
if(pin == 3) {
|
||||
debugI("Switching UART0 to pin 1 & 3");
|
||||
Serial.pins(1,3);
|
||||
} else if(pin == 113) {
|
||||
debugI("Switching UART0 to pin 15 & 13");
|
||||
Serial.pins(15,13);
|
||||
}
|
||||
#endif
|
||||
|
||||
>>>>>>> master
|
||||
hanSerial = hwSerial;
|
||||
} else {
|
||||
debugD("Software serial");
|
||||
Serial.flush();
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
if(swSerial != NULL) {
|
||||
swSerial->end();
|
||||
delete swSerial;
|
||||
}
|
||||
swSerial = new SoftwareSerial(pin);
|
||||
>>>>>>> master
|
||||
|
||||
SoftwareSerialConfig serialConfig;
|
||||
switch(parityOrdinal) {
|
||||
@@ -547,6 +588,7 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
|
||||
swSerial->begin(baud, serialConfig);
|
||||
hanSerial = swSerial;
|
||||
|
||||
Serial.end();
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ void AmsWebServer::temperaturePost() {
|
||||
delay(1);
|
||||
}
|
||||
|
||||
if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
//if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
if(config->save()) {
|
||||
printD("Successfully saved temperature sensors");
|
||||
server.sendHeader("Location", String("/temperature"), true);
|
||||
@@ -1198,7 +1198,7 @@ void AmsWebServer::handleSave() {
|
||||
|
||||
printI("Saving configuration now...");
|
||||
|
||||
if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
//if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
|
||||
if (config->save()) {
|
||||
printI("Successfully saved.");
|
||||
if(config->isWifiChanged()) {
|
||||
@@ -1344,6 +1344,11 @@ String AmsWebServer::getSerialSelectOptions(int selected) {
|
||||
#elif defined(ESP8266)
|
||||
int numGpio = 9;
|
||||
int gpios[] = {4,5,9,10,12,13,14,15,16};
|
||||
if(selected == 113) {
|
||||
gpioOptions += "<option value=\"113\" selected>UART2 (GPIO13)</option>";
|
||||
} else {
|
||||
gpioOptions += "<option value=\"113\">UART2 (GPIO13)</option>";
|
||||
}
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < numGpio; i++) {
|
||||
|
||||
Reference in New Issue
Block a user