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 4f4deec7ba
commit b5659f0e5c
4 changed files with 724 additions and 552 deletions

View file

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

View file

@ -64,7 +64,7 @@ public class MultiMsgSink implements TransportProcs {
public int sendViaBluetooth( byte[] buf, int gameID, CommsAddrRec addr ) 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 ) public int sendViaSMS( byte[] buf, int gameID, CommsAddrRec addr )

View file

@ -609,7 +609,9 @@ public class NetLaunchInfo implements Serializable {
public boolean isValid() 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; return m_valid;
} }