package at.jku.pervasive.ecg;

import java.util.List;

import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;

import junit.framework.Assert;

public class ECGMonitorMain {

  public static void main(String[] args) throws Exception {
    String address = "00A096203DCB"; // HeartMan C102

    HeartManDiscovery heartManDiscovery = new HeartManDiscovery();
    Assert.assertTrue(heartManDiscovery.isBluetoothEnabled());

    RemoteDevice device = heartManDiscovery.pingDevice(address);
    List<ServiceRecord> services = heartManDiscovery.searchServices(device);
    Assert.assertNotNull(services);
    Assert.assertTrue(services.size() > 0);
    ServiceRecord serviceRecord = services.get(0);

    ECGMonitor ecgMonitor = new ECGMonitor();
    ecgMonitor.setVisible(true);

    IHeartManListener l = ecgMonitor.getHeartManListener();

    heartManDiscovery.startListening(address, l, serviceRecord);
  }
}

@@ -40,19 +40,95 @@
 ava.
-util.List;%0A
+io.IOException;%0Aimport java.util.List;%0A%0Aimport javax.bluetooth.BluetoothStateException;
 %0Aimp
@@ -341,16 +341,72 @@
  address
+1 = %2200A096203DCB%22; // HeartMan C102%0A    String address2
  = %2200A0
@@ -573,78 +573,42 @@
     
-RemoteDevice device = heartManDiscovery.pingDevice(address);%0A    List%3C
+ServiceRecord serviceRecord1 = get
 Serv
@@ -620,20 +620,18 @@
 cord
-%3E services =
+(address1,
  hea
@@ -648,161 +648,90 @@
 very
-.searchServices(device);%0A    Assert.assertNotNull(services);%0A    Assert.assertTrue(services.size() %3E 0);%0A    ServiceRecord serviceRecord = services.get(0
+);%0A    ServiceRecord serviceRecord2 = getServiceRecord(address2, heartManDiscovery
 );%0A%0A
@@ -915,16 +915,17 @@
 (address
+1
 , l, ser
@@ -934,17 +934,554 @@
 ceRecord
-)
+1);%0A    heartManDiscovery.startListening(address2, l, serviceRecord2);%0A  %7D%0A%0A  private static ServiceRecord getServiceRecord(String address,%0A      HeartManDiscovery heartManDiscovery) throws IOException,%0A      BluetoothStateException %7B%0A    RemoteDevice device1 = heartManDiscovery.pingDevice(address);%0A    List%3CServiceRecord%3E services1 = heartManDiscovery.searchServices(device1);%0A    Assert.assertNotNull(services1);%0A    Assert.assertTrue(services1.size() %3E 0);%0A    ServiceRecord serviceRecord = services1.get(0);%0A    return serviceRecord
 ;%0A  %7D%0A%7D%0A

add listening for second device in ECGMonitorMain