From 898d9c339a3a3155c98e1abfaa4fe8675e9774fb Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 7 Feb 2012 18:05:06 -0800 Subject: [PATCH] add protocol-identifier byte. For now just assert it matches. --- .../XWords4/src/org/eehouse/android/xw4/BTService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java index 164005922..14c4950d4 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -60,6 +60,8 @@ public class BTService extends Service { public void eventOccurred( BTEvent event, Object ... args ); } + private static final int BT_PROTO = 0; + private static final int PING = 0; private static final int SCAN = 1; private static final int INVITE = 2; @@ -305,6 +307,8 @@ public class BTService extends Service { DbgUtils.logf( "run: accept() returned" ); inStream = new DataInputStream( socket.getInputStream() ); + byte proto = inStream.readByte(); + Assert.assertTrue( proto == BT_PROTO ); byte msg = inStream.readByte(); BTCmd cmd = BTCmd.values()[msg]; switch( cmd ) { @@ -721,6 +725,7 @@ public class BTService extends Service { try { socket.connect(); dos = new DataOutputStream( socket.getOutputStream() ); + dos.writeByte( BT_PROTO ); dos.writeByte( cmd.ordinal() ); DbgUtils.logf( "connect successful" ); } catch ( java.io.IOException ioe ) {