Rewrite BT proto to batch messages

Lots of changes. Old BT proto is no longer compatible. New one
batches messages per device and sends all on a single connection.
The queue (now a single buffer) is now a static global and the thread
that services it doesn't die (but gloms onto whatever Service instance
is most recent.) Code to pack and unpack the protocol can probably be
reused for wifi-direct or any other pass-through transport.
This commit is contained in:
Eric House 2019-02-15 08:11:23 -08:00
parent e13d90409c
commit 5cb2be33d2
4 changed files with 724 additions and 552 deletions

View file

@ -430,7 +430,7 @@ public class CommsTransport implements TransportProcs,
gameID, buf );
break;
case COMMS_CONN_BT:
nSent = BTService.enqueueFor( context, buf, addr, gameID );
nSent = BTService.sendPacket( context, buf, addr, gameID );
break;
case COMMS_CONN_P2P:
nSent = WiDirService

View file

@ -64,7 +64,7 @@ public class MultiMsgSink implements TransportProcs {
public int sendViaBluetooth( byte[] buf, int gameID, CommsAddrRec addr )
{
return BTService.enqueueFor( m_context, buf, addr, gameID );
return BTService.sendPacket( m_context, buf, addr, gameID );
}
public int sendViaSMS( byte[] buf, int gameID, CommsAddrRec addr )

View file

@ -609,7 +609,9 @@ public class NetLaunchInfo implements Serializable {
public boolean isValid()
{
// DbgUtils.logf( "NetLaunchInfo(%s).isValid() => %b", toString(), m_valid );
calcValid(); // this isn't always called. Likely should
// remove it as it's a stupid optimization
// Log.d( TAG, "NetLaunchInfo(%s).isValid() => %b", this, m_valid );
return m_valid;
}