I am new to Corebluetooth. I want to prevent duplicate peripherals when scanning. Can anyone help me?
And one more question, how to connect peripheral with in range ?
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber)
{
if (peripheral.name != nil) && (peripheral.name == "EXP") ||
(peripheral.name == "EXP")
{
let key = peripheral.identifier.uuidString
let data = advertisementData.description
if let previous = datas[key]
{
if (previous != data)
{
print("Different \(String(describing: peripheral.name)): \ . (data)")
}
} else
{
print("\(String(describing: peripheral.name)): \(data)");
datas[key] = data
}
peripherals.append(peripheral)
lblDeviceCount.isHidden = false
lblDeviceCount.text = "\(peripherals.count) Devices Found"
tblPeriPheral.reloadData()
}
}