Skip to content

Commit

Permalink
added logging for connection attempt from client to transport
Browse files Browse the repository at this point in the history
  • Loading branch information
gokris165 committed Feb 22, 2024
1 parent ec0a359 commit 03e71a7
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View view) {
try {
connectButton.setEnabled(true);

resultText.append("Starting connection...\n");
exchangeMessage(wifiDirectManager);
} catch (ExecutionException | InterruptedException e) {
e.printStackTrace();
Expand Down Expand Up @@ -190,7 +192,7 @@ public void exchangeMessage(WifiDirectManager wifiDirectManager) throws Executio
if (!group.isGroupOwner()){
// start request task
Log.d(TAG,"Connection Successful!");
resultText.append("Connection Successful!\n");
resultText.append("Connection Successful!\n\n");
// receive task
new GrpcReceiveTask(this).execute("192.168.49.1", "1778");

Expand All @@ -199,6 +201,8 @@ public void exchangeMessage(WifiDirectManager wifiDirectManager) throws Executio
// .execute(
// "192.168.49.1",
// "1778");
} else {
resultText.append("Connection Failed\n\n");
}
return group;
});
Expand All @@ -220,19 +224,26 @@ public void connectTransport(WifiDirectManager wifiDirectManager){
completedFuture.thenApply((b) -> {
Log.d(TAG, "Did DiscoverPeers succeed?: " + b);
if( b ){
resultText.append("Discovering Peers...\n");
ArrayList<WifiP2pDevice> devices = wifiDirectManager.getPeerList();
Log.d(TAG, "Logging Devices: \n");
if(devices.isEmpty()) {
resultText.append("Failed to find any Wi-Fi direct compatible devices\n\n");
Log.d(TAG,"No devices found yet");
} else {
resultText.append("Found Wi-Fi direct compatible devices\n");
}
for(WifiP2pDevice d: devices) {
// Log.d(TAG, d.toString());
if(d.deviceName.contains(SJSUHostDeviceName))
Log.d(TAG,"Trying to make connection with "+d.toString());
if(d.deviceName.contains(SJSUHostDeviceName)) {
Log.d(TAG, "Trying to make connection with " + d.toString());
resultText.append("Trying to make connection with " + d.toString());
}
wifiDirectManager.connect(wifiDirectManager.makeConfig(
d, false));
}
}
if( !b ) resultText.append("Failed to discover any peers...\n\n");
return b;
});
String message = "I tried to find some peers!: ";
Expand Down

0 comments on commit 03e71a7

Please sign in to comment.