mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 08:47:56 +01:00
tweak logging around message parsing where crash seems to be
This commit is contained in:
parent
2a5fb95dac
commit
a60451d84c
2 changed files with 21 additions and 8 deletions
|
@ -536,17 +536,22 @@ dvc_makeMQTTNoSuchGames( XW_DUtilCtxt* dutil, XWEnv xwe,
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
isDevMsg( const MQTTDevID* myID, const XP_UCHAR* topic, XP_U32* gameID )
|
||||
isDevMsg( const MQTTDevID* myID, const XP_UCHAR* topic, XP_U32* gameIDP )
|
||||
{
|
||||
XP_UCHAR buf[64];
|
||||
formatMQTTDevTopic( myID, buf, VSIZE(buf) );
|
||||
size_t topicLen = XP_STRLEN(buf);
|
||||
XP_ASSERT( topicLen < VSIZE(buf)-1 );
|
||||
/* Does topic match xw4/device/<devid> at least */
|
||||
XP_Bool success = 0 == strncmp( buf, topic, topicLen );
|
||||
if ( success ) {
|
||||
/* Now get the gameID if it's there */
|
||||
const XP_UCHAR* gameIDPart = topic + topicLen;
|
||||
sscanf( gameIDPart, "/%X", gameID );
|
||||
int count =
|
||||
sscanf( gameIDPart, "/%X", gameIDP );
|
||||
XP_ASSERT( 1 == count || 0 == *gameIDP ); /* firing */
|
||||
}
|
||||
// XP_LOGFF( "(%s) => %s (gameID=%X)", topic, boolToStr(success), *gameID );
|
||||
XP_LOGFF( "(%s) => %s (gameID=%X)", topic, boolToStr(success), *gameIDP );
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -659,11 +664,10 @@ dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic,
|
|||
MQTTDevID myID;
|
||||
dvc_getMQTTDevID( dutil, xwe, &myID );
|
||||
|
||||
XP_LOGFF( "got myID" );
|
||||
// XP_LOGFF( "got myID" ); /* gets here */
|
||||
|
||||
XP_U32 gameID = 0;
|
||||
if ( isDevMsg( &myID, topic, &gameID ) ) {
|
||||
XP_LOGFF( "is msg; gameID: %X", gameID );
|
||||
XWStreamCtxt* stream = mkStream( dutil );
|
||||
stream_putBytes( stream, buf, len );
|
||||
|
||||
|
@ -722,7 +726,6 @@ dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic,
|
|||
}
|
||||
stream_destroy( stream );
|
||||
} else if ( isCtrlMsg( &myID, topic ) ) {
|
||||
XP_LOGFF( "is ctrl msg" );
|
||||
dutil_onCtrlReceived( dutil, xwe, buf, len );
|
||||
} else {
|
||||
XP_LOGFF( "OTHER" );
|
||||
|
|
|
@ -666,14 +666,24 @@ smsToBin( XP_U8* out, XP_U16* outlenp, const XP_UCHAR* sms, XP_U16 smslen )
|
|||
XP_UCHAR*
|
||||
formatMQTTDevID( const MQTTDevID* devid, XP_UCHAR* buf, XP_U16 bufLen )
|
||||
{
|
||||
XP_ASSERT( bufLen >= 17 );
|
||||
#ifdef DEBUG
|
||||
int len =
|
||||
#endif
|
||||
XP_SNPRINTF( buf, bufLen, MQTTDevID_FMT, *devid );
|
||||
XP_ASSERT( len < bufLen );
|
||||
// LOG_RETURNF( "%s", buf );
|
||||
return buf;
|
||||
}
|
||||
|
||||
XP_UCHAR*
|
||||
formatMQTTDevTopic( const MQTTDevID* devid, XP_UCHAR* buf, XP_U16 bufLen )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
int len =
|
||||
#endif
|
||||
XP_SNPRINTF( buf, bufLen, MQTTTopic_FMT, *devid );
|
||||
XP_ASSERT( len < bufLen );
|
||||
// LOG_RETURNF( "%s", buf );
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue