Skip to content

Commit

Permalink
Implement multicast notifications for BTTFN-clients
Browse files Browse the repository at this point in the history
  • Loading branch information
realA10001986 authored Oct 26, 2024
1 parent b658b7e commit 142fa95
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 254 deletions.
2 changes: 2 additions & 0 deletions timecircuits-A10001986/tc_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,9 @@ static bool mp_renameFilesInDir(bool isSetup)
#ifdef HAVE_GETNEXTFILENAME
bool isDir;
#endif
#if defined(TC_DBG) || defined(TC_DBG_MP)
const char *funcName = "MusicPlayer/Renamer: ";
#endif

headLineShown = false;
blinker = true;
Expand Down
16 changes: 10 additions & 6 deletions timecircuits-A10001986/tc_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

// These must not contain any characters other than
// '0'-'9', 'A'-'Z', '(', ')', '.', '_', '-' or space
#define TC_VERSION "V3.1.99" // 13 chars max
#define TC_VERSION "V3.1.999" // 13 chars max
#ifndef IS_ACAR_DISPLAY
#define TC_VERSION_EXTRA "OCT232024" // 13 chars max
#define TC_VERSION_EXTRA "OCT262024" // 13 chars max
#else // A-Car
#define TC_VERSION_EXTRA "10232024" // 12 chars max
#define TC_VERSION_EXTRA "10262024" // 12 chars max
#endif

//#define TC_DBG // debug output on Serial
Expand Down Expand Up @@ -82,7 +82,7 @@
// A secondary rotary encoder is used for audio volume.
#define TC_HAVE_RE

// Uncomment for Remote support
// Uncomment for Remote control support
// "Remote" is a modified Futaba remote control with CS/A10001986 control board
// and the A10001986 "remote" firmware.
#define TC_HAVE_REMOTE
Expand Down Expand Up @@ -124,13 +124,17 @@
// The defined pin is set HIGH on a time travel, and LOW upon re-entry from
// a time travel. See tc_time.c for a timing diagram.
// Uncomment to include support for ETTO, see below for pin number
// This is also needed if MQTT or BTTFN is used to trigger external props.
// This is also needed if MQTT or BTTFN is used to trigger other props.
#define EXTERNAL_TIMETRAVEL_OUT

// Uncomment for HomeAssistant MQTT protocol support
#define TC_HAVEMQTT

// Uncomment for bttfn discover (multicast)
// Uncomment for bttfn discover (multicast) and notification broadcast.
// This is REQUIRED for operating a Futaba remote control, and very
// useful for other props' quicker speed updates. Supported by the
// following firmwares:
// Flux >= 1.60, SID >= 1.40, DG >= 1.10, VSR >= 1.10, Remote >= 0.90
#define TC_BTTFN_MC

// Uncomment to include Exhibition mode
Expand Down
46 changes: 45 additions & 1 deletion timecircuits-A10001986/tc_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,11 +2048,29 @@ static void doShowNetInfo()
/*
* Show BTTFN network clients ##################################
*/

static bool bttfnValChar(char *s, int i)
{
char a = s[i];

if(a == '-') return true;
if(a < '0') return false;
if(a > '9' && a < 'A') return false;
if(a <= 'Z') return true;
if(a >= 'a' && a <= 'z') {
s[i] &= ~0x20;
return true;
}
return false;
}

static void displayClient(int numCli, int number)
{
uint8_t *ip;
char *id;
uint8_t type;
char idbuf[12];
const char *tpArr[6] = { "[FLUX]", "[SID]", "[GAUGES]", "[VSR]", "[AUX]", "[REMOTE]" };

if(!numCli) {
dt_showTextDirect("NO CLIENTS");
Expand All @@ -2064,7 +2082,33 @@ static void displayClient(int numCli, int number)
if(number >= numCli) number = numCli - 1;

if(bttfnGetClientInfo(number, &id, &ip, &type)) {
dt_showTextDirect(id);

bool badName = false;
if(!*id) {
badName = true;
} else {
for(int j = 0; j < 12; j++) {
if(!id[j]) break;
if(!bttfnValChar(id, j)) {
badName = true;
break;
}
}
}

if(badName) {
if(type >= 1 && type <= 6) {
strcpy(idbuf, tpArr[type-1]);
} else {
strcpy(idbuf, "[UNKNOWN]");
}
} else {
strncpy(idbuf, id, 12);
idbuf[12] = 0;
}

dt_showTextDirect(idbuf);

presentTime.showHalfIPDirect(ip[0], ip[1], CDT_CLEAR);
departedTime.showHalfIPDirect(ip[2], ip[3], CDT_CLEAR);
pt_on();
Expand Down
Loading

0 comments on commit 142fa95

Please sign in to comment.