title: multiple BLE devices which have same services and characteristics in ios
body: <p>I have multiple BLE devices which have same services and characteristics. I can scan and connect multiple devices. After connections, when I try to distinguish each one by sending command it doesn't work. It works perfectly with a single device. Is it something like socket connection ? Like A server spawns child threads and each client can maintain a connection through threads. </p>
  
  <p>Please provide some tips on how to scan each device when other device is reading the data from the device.</p>
  
  <pre><code>-(void) scanDevice {
  
    centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
  
    [centralManager scanForPeripheralsWithServices:nil options:0];
  
   [AppDelegate app].cbCentral = centralManager;
  
  }
  
  -(void) stopScan {
  
      [[AppDelegate app].cbCentral stopScan];
  }
  
  -(void)connectToDevice:(CBPeripheral *)peripheral{
  
  
    [[AppDelegate app] cbCentral].delegate = self;
    [[[AppDelegate app] cbCentral] connectPeripheral:peripheral options:nil];
  
  }
  
   -(void)calldiscoverServicesForPeripheral:(CBPeripheral *)peripheral{
  
    [peripheral setDelegate:self];
    [peripheral discoverServices:nil];
  
  }
  
  - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral     *)peripheral {
  
  NSLog(@"Connected PERIPHERAL %d",peripheral.state);
  
    [delegate getConnectedPeripheral:peripheral];
  
    NSLog(@"Connected peripheral %@",peripheral);
  }
  
  - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
  
     NSLog(@"Discovered servicea: %@", peripheral.services);
  
    for (CBService *service in peripheral.services) {
      NSLog(@"Discovered service: %@", [service.UUID data]);
      [peripheral discoverCharacteristics:nil forService:service];
    }
  }
  </code></pre>
  
  <p>I will explain in detail,</p>
  
  <p>I have table view, that contains BLE devices. For the first time it is empty, so i will search for the devices by calling a class "Scan Devices".</p>
  
  <p>This "Scan devices" class contains all the Corebluetooth methods like CBCentralManager allocation, CBperipheral delegate methods.</p>
  
  <p>After search, I will display the device in table view and connect to the BLE device. I am getting some data from "Scan Device" class.</p>
  
  <p>Now, I want to search more devices to connect and get the data. For this, I will call [[CBCentralManager alloc] initWithDelegate:self] in "ScanDevices" class. At this time, for previous device(connected and reading) is showing the warning "is not a valid peripheral" and new device is connecting and reading data from the device.</p>
  
  <p>But I want read the data from both devices at a time</p>
  
  <p>Please help me...
  Thanks</p>