fix to compile with XWFEATURE_RELAY undefined

Didn't change the stream format. That will wait!
This commit is contained in:
Eric House 2021-03-19 18:51:34 -07:00
parent b1532f19a4
commit e3ba122ca0
3 changed files with 29 additions and 22 deletions

View file

@ -220,14 +220,15 @@ static void notifyQueueChanged( const CommsCtxt* comms, XWEnv xwe );
#if 0 < COMMS_VERSION #if 0 < COMMS_VERSION
static XP_U16 makeFlags( const CommsCtxt* comms ); static XP_U16 makeFlags( const CommsCtxt* comms );
#endif #endif
static XP_Bool sendNoConn( CommsCtxt* comms, XWEnv xwe,
const MsgQueueElem* elem, XWHostID destID );
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
static XP_Bool relayConnect( CommsCtxt* comms, XWEnv xwe ); static XP_Bool relayConnect( CommsCtxt* comms, XWEnv xwe );
static void relayDisconnect( CommsCtxt* comms, XWEnv xwe ); static void relayDisconnect( CommsCtxt* comms, XWEnv xwe );
static XP_Bool send_via_relay( CommsCtxt* comms, XWEnv xwe, XWRELAY_Cmd cmd, static XP_Bool send_via_relay( CommsCtxt* comms, XWEnv xwe, XWRELAY_Cmd cmd,
XWHostID destID, void* data, int dlen, XWHostID destID, void* data, int dlen,
const XP_UCHAR* msgNo ); const XP_UCHAR* msgNo );
static XP_Bool sendNoConn( CommsCtxt* comms, XWEnv xwe,
const MsgQueueElem* elem, XWHostID destID );
static XWHostID getDestID( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo ); static XWHostID getDestID( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo );
static void set_reset_timer( CommsCtxt* comms, XWEnv xwe ); static void set_reset_timer( CommsCtxt* comms, XWEnv xwe );
# ifdef XWFEATURE_DEVID # ifdef XWFEATURE_DEVID
@ -235,7 +236,11 @@ static void putDevID( const CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream );
# else # else
# define putDevID( comms, xwe, stream ) # define putDevID( comms, xwe, stream )
# endif # endif
# ifdef DEBUG # else
# define relayDisconnect( comms, xwe )
#endif
#ifdef DEBUG
static const char* relayCmdToStr( XWRELAY_Cmd cmd ); static const char* relayCmdToStr( XWRELAY_Cmd cmd );
static void printQueue( const CommsCtxt* comms ); static void printQueue( const CommsCtxt* comms );
static void logAddr( const CommsCtxt* comms, XWEnv xwe, static void logAddr( const CommsCtxt* comms, XWEnv xwe,
@ -243,11 +248,10 @@ static void logAddr( const CommsCtxt* comms, XWEnv xwe,
static void logAddrs( const CommsCtxt* comms, XWEnv xwe, static void logAddrs( const CommsCtxt* comms, XWEnv xwe,
const char* caller ); const char* caller );
# else #else
# define printQueue( comms ) #define printQueue( comms )
# define logAddr( comms, xwe, addr, caller) #define logAddr( comms, xwe, addr, caller)
# define logAddrs( comms, caller ) #define logAddrs( comms, caller )
# endif
#endif #endif
#if defined RELAY_HEARTBEAT || defined COMMS_HEARTBEAT #if defined RELAY_HEARTBEAT || defined COMMS_HEARTBEAT
static void setHeartbeatTimer( CommsCtxt* comms ); static void setHeartbeatTimer( CommsCtxt* comms );
@ -269,7 +273,6 @@ static void sendEmptyMsg( CommsCtxt* comms, XWEnv xwe, AddressRecord* rec );
/**************************************************************************** /****************************************************************************
* implementation * implementation
****************************************************************************/ ****************************************************************************/
#ifdef XWFEATURE_RELAY
#ifdef DEBUG #ifdef DEBUG
# define CNO_FMT(buf, cno) \ # define CNO_FMT(buf, cno) \
@ -280,6 +283,8 @@ static void sendEmptyMsg( CommsCtxt* comms, XWEnv xwe, AddressRecord* rec );
# define CNO_FMT(buf, cno) # define CNO_FMT(buf, cno)
#endif #endif
#ifdef XWFEATURE_RELAY
#ifdef DEBUG #ifdef DEBUG
const char* const char*
CommsRelayState2Str( CommsRelayState state ) CommsRelayState2Str( CommsRelayState state )
@ -492,10 +497,11 @@ reset_internal( CommsCtxt* comms, XWEnv xwe, XP_Bool isServer,
originally. So comment it out. */ originally. So comment it out. */
// XP_ASSERT( 0 == comms->nextChannelNo ); // XP_ASSERT( 0 == comms->nextChannelNo );
// comms->nextChannelNo = 0; // comms->nextChannelNo = 0;
#ifdef XWFEATURE_RELAY
if ( resetRelay ) { if ( resetRelay ) {
comms->channelSeed = 0; comms->channelSeed = 0;
} }
#endif
comms->connID = CONN_ID_NONE; comms->connID = CONN_ID_NONE;
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
if ( resetRelay ) { if ( resetRelay ) {
@ -1140,13 +1146,6 @@ comms_formatRelayID( const CommsCtxt* comms, XP_U16 indx,
return success; return success;
} }
static void
formatMsgNo( const CommsCtxt* comms, const MsgQueueElem* elem,
XP_UCHAR* buf, XP_U16 len )
{
XP_SNPRINTF( buf, len, "%d:%d", comms->rr.myHostID, elem->msgID );
}
/* Get *my* "relayID", a combo of connname and host id */ /* Get *my* "relayID", a combo of connname and host id */
XP_Bool XP_Bool
comms_getRelayID( const CommsCtxt* comms, XP_UCHAR* buf, XP_U16* lenp ) comms_getRelayID( const CommsCtxt* comms, XP_UCHAR* buf, XP_U16* lenp )
@ -1157,6 +1156,13 @@ comms_getRelayID( const CommsCtxt* comms, XP_UCHAR* buf, XP_U16* lenp )
} }
#endif #endif
static void
formatMsgNo( const CommsCtxt* comms, const MsgQueueElem* elem,
XP_UCHAR* buf, XP_U16 len )
{
XP_SNPRINTF( buf, len, "%d:%d", comms->rr.myHostID, elem->msgID );
}
void void
comms_getInitialAddr( CommsAddrRec* addr comms_getInitialAddr( CommsAddrRec* addr
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
@ -1182,7 +1188,7 @@ comms_getInitialAddr( CommsAddrRec* addr
Palm... */ Palm... */
addr->conType = COMMS_CONN_IR; addr->conType = COMMS_CONN_IR;
#else #else
addr->conType = COMMS_CONN_SMS; addr_setType( addr, COMMS_CONN_MQTT );
#endif #endif
} /* comms_getInitialAddr */ } /* comms_getInitialAddr */
@ -1633,13 +1639,15 @@ sendMsg( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* elem, const CommsConnType fi
return result; return result;
} /* sendMsg */ } /* sendMsg */
#ifdef XWFEATURE_RELAY
static void static void
send_ack( CommsCtxt* comms, XWEnv xwe ) send_relay_ack( CommsCtxt* comms, XWEnv xwe )
{ {
LOG_FUNC(); LOG_FUNC();
(void)send_via_relay( comms, xwe, XWRELAY_ACK, comms->rr.myHostID, (void)send_via_relay( comms, xwe, XWRELAY_ACK, comms->rr.myHostID,
NULL, 0, NULL ); NULL, 0, NULL );
} }
#endif
typedef XP_S16 (*MsgProc)( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* msg, typedef XP_S16 (*MsgProc)( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* msg,
CommsConnType filter, void* closure ); CommsConnType filter, void* closure );
@ -1883,7 +1891,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
case XWRELAY_CONNECT_RESP: case XWRELAY_CONNECT_RESP:
got_connect_cmd( comms, xwe, stream, XP_FALSE ); got_connect_cmd( comms, xwe, stream, XP_FALSE );
send_ack( comms, xwe ); send_relay_ack( comms, xwe );
break; break;
case XWRELAY_RECONNECT_RESP: case XWRELAY_RECONNECT_RESP:
got_connect_cmd( comms, xwe, stream, XP_TRUE ); got_connect_cmd( comms, xwe, stream, XP_TRUE );

View file

@ -120,6 +120,7 @@ typedef struct _TransportProcs {
XP_U32 flags; XP_U32 flags;
#endif #endif
TransportSend send; TransportSend send;
MsgCountChange countChanged;
#ifdef COMMS_HEARTBEAT #ifdef COMMS_HEARTBEAT
TransportReset reset; TransportReset reset;
#endif #endif
@ -131,7 +132,6 @@ typedef struct _TransportProcs {
# ifdef RELAY_VIA_HTTP # ifdef RELAY_VIA_HTTP
RelayRequestJoinProc requestJoin; RelayRequestJoinProc requestJoin;
# endif # endif
MsgCountChange countChanged;
#endif #endif
void* closure; void* closure;
} TransportProcs; } TransportProcs;

View file

@ -27,7 +27,6 @@ DEFINES += -DMAX_ROWS=32
DEFINES += -DCOMMON_LAYOUT DEFINES += -DCOMMON_LAYOUT
DEFINES += -DDROP_BITMAPS DEFINES += -DDROP_BITMAPS
DEFINES += -D__LITTLE_ENDIAN DEFINES += -D__LITTLE_ENDIAN
DEFINES += -DXWFEATURE_RELAY
# DEFINES += -DXWFEATURE_DEVID # DEFINES += -DXWFEATURE_DEVID
DEFINES += -D__WORDSIZE=32 DEFINES += -D__WORDSIZE=32
# DEFINES += -DCOMMS_CHECKSUM # DEFINES += -DCOMMS_CHECKSUM