1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

Withrottle connect improvements

This commit is contained in:
Asbelos 2022-12-14 13:06:01 +00:00
parent 576e1fe11c
commit 789b72a170
4 changed files with 16 additions and 23 deletions

View File

@ -131,7 +131,8 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
else if (!heartrateSent) {
heartrateSent=true;
// allow heartbeat to slow down once all metadata sent
StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS);
StringFormatter::send(stream,F("*%d\nHMConnected\n"),HEARTBEAT_SECONDS);
}
}
@ -187,7 +188,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
}
break;
case 'N': // Heartbeat (2), only send if connection completed by 'HU' message
StringFormatter::send(stream, F("*%d\n"), heartrateSent ? HEARTBEAT_SECONDS : HEARTBEAT_SECONDS/2); // return timeout value
StringFormatter::send(stream, F("*%d\n"), heartrateSent ? HEARTBEAT_SECONDS : HEARTBEAT_PRELOAD); // return timeout value
break;
case 'M': // multithrottle
multithrottle(stream, cmd);
@ -500,8 +501,8 @@ void WiThrottle::sendIntro(Print* stream) {
StringFormatter::send(stream,F("HtDCC-EX v%S, %S, %S, %S\n"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA));
StringFormatter::send(stream,F("PTT]\\[Turnouts}|{Turnout]\\[THROW}|{2]\\[CLOSE}|{4\n"));
StringFormatter::send(stream,F("PPA%x\n"),TrackManager::getMainPower()==POWERMODE::ON);
// set heartbeat to 5 seconds because we need to sync the metadata (1 second is too short!)
StringFormatter::send(stream,F("*%d\n"), HEARTBEAT_SECONDS/2);
// set heartbeat to 2 seconds because we need to sync the metadata (1 second is too short!)
StringFormatter::send(stream,F("*%d\nHMConnecting..\n"), HEARTBEAT_PRELOAD);
}
void WiThrottle::sendTurnouts(Print* stream) {

View File

@ -45,7 +45,8 @@ class WiThrottle {
~WiThrottle();
static const int MAX_MY_LOCO=10; // maximum number of locos assigned to a single client
static const int HEARTBEAT_SECONDS=10; // heartbeat at 4secs to provide messaging transport
static const int HEARTBEAT_SECONDS=10; // heartbeat at 10 secs to provide messaging transport
static const int HEARTBEAT_PRELOAD=2; // request fast callback when connecting multiple messages
static const int ESTOP_SECONDS=20; // eStop if no incoming messages for more than 8secs
static WiThrottle* firstThrottle;
static int getInt(byte * cmd);

View File

@ -31,7 +31,6 @@ WifiInboundHandler * WifiInboundHandler::singleton;
void WifiInboundHandler::setup(Stream * ESStream) {
singleton=new WifiInboundHandler(ESStream);
// DIAG(F("WifiInbound Setup2 %P %P"), ESStream,singleton);
}
void WifiInboundHandler::loop() {
@ -45,7 +44,6 @@ WifiInboundHandler::WifiInboundHandler(Stream * ESStream) {
inboundRing=new RingStream(INBOUND_RING);
outboundRing=new RingStream(OUTBOUND_RING);
pendingCipsend=false;
// DIAG(F("WifiInbound setup1 %P"), wifiStream);
}
@ -53,20 +51,13 @@ WifiInboundHandler::WifiInboundHandler(Stream * ESStream) {
// +IPD,x,lll:data is stored in streamer[x]
// Other input returns
void WifiInboundHandler::loop1() {
static bool XX=true;
if (XX) DIAG(F("Wifi 1"));
// First handle all inbound traffic events because they will block the sending
if (loop2()!=INBOUND_IDLE) {
if (XX) DIAG(F("Wifi 2"));
return;
}
if (XX) DIAG(F("Wifi 3"));
if (loop2()!=INBOUND_IDLE) return;
WiThrottle::loop(outboundRing);
if (XX) DIAG(F("Wifi 4"));
XX=false;
// if nothing is already CIPSEND pending, we can CIPSEND one reply
// if nothing is already CIPSEND pending, we can CIPSEND one reply
if (clientPendingCIPSEND<0) {
clientPendingCIPSEND=outboundRing->read();
if (clientPendingCIPSEND>=0) {
@ -97,9 +88,6 @@ if (XX) DIAG(F("Wifi 3"));
}
}
// This is a Finite State Automation (FSA) handling the inbound bytes from an ES AT command processor
WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() {

View File

@ -4,7 +4,10 @@
#include "StringFormatter.h"
#define VERSION "4.2.7a"
#define VERSION "4.2.9"
// 4.2.9 Withrottle connecting improvements
// 4.2.8 Report board type when provided
// 4.2.7 Cleanup wifi disconnect issues and highmem
// 4.2.6 FIX: Remove RAM thief
// FIX: ADC port 8-15 fix
// 4.2.5 Make GETFLASHW code more universal