Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ESPHamClock/ArduinoLib/WiFiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class WiFiClient {
void println (float f, int n);
void flush(void){};
IPAddress remoteIP(void);
void setTimeout(uint16_t ms) { read_pending_ms = ms; }

private:

Expand Down
3 changes: 2 additions & 1 deletion ESPHamClock/HamClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,9 @@ extern void doNCDXFBoxTouch (TouchType tt, const SCoord &s);
// special cleanCache ages
#define CACHE_FOREVER 0 // never remove matching files
#define CACHE_NONE 1 // remove all files older than 1 second
#define VOACAP_TIMEOUT_MS 15000 // timeout for VOACAP and band conditions endpoints

extern FILE *openCachedFile (const char *fn, const char *url, int max_age, int min_size);
extern FILE *openCachedFile (const char *fn, const char *url, int max_age, int min_size, int to_ms = 0);
extern bool cleanCache (const char *contains, int max_age);


Expand Down
4 changes: 3 additions & 1 deletion ESPHamClock/cachefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static bool fileAgeOk (const char *path, int max_age)
/* open the given local file or download fresh if too old or too small.
* if download fails retain fn as long as it's large enough, tolerating too old.
*/
FILE *openCachedFile (const char *fn, const char *url, int max_age, int min_size)
FILE *openCachedFile (const char *fn, const char *url, int max_age, int min_size, int to_ms)
{
// try local first
char fn_path[1000];
Expand All @@ -77,6 +77,8 @@ FILE *openCachedFile (const char *fn, const char *url, int max_age, int min_size

// download
WiFiClient cache_client;
if (to_ms > 0)
cache_client.setTimeout(to_ms);
Serial.println (url);
if (cache_client.connect(backend_host, backend_port)) {

Expand Down
1 change: 1 addition & 0 deletions ESPHamClock/mapmanage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ long max_age)
noteVOACAPAttempt(now);

WiFiClient client;
client.setTimeout(VOACAP_TIMEOUT_MS);
if (client.connect(backend_host, backend_port)) {
mapMsg (0, "%s", msg);
char url[2*QBUFLEN];
Expand Down
2 changes: 1 addition & 1 deletion ESPHamClock/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ static bool retrieveBandConditions (char *config)
snprintf (cache_fn, sizeof(cache_fn), "bc-%010u.txt", stringHash(query)); // N.B. see cleanCache() above

// open cache or get fresh
FILE *fp = openCachedFile (cache_fn, query, 12*3600L, 100);
FILE *fp = openCachedFile (cache_fn, query, 12*3600L, 100, VOACAP_TIMEOUT_MS);
if (fp) {

char buf[100];
Expand Down