Post

Replies

Boosts

Views

Activity

Search for HC-05 Bluetooth device via Bluetooth
Good afternoon guys, I want to create an app that's detects common bluetooth based credit card skimmers predominantly found in gas pumps. The app scans for available bluetooth connections looking for a device with title HC-05. If found, the app will attempt to connect using the default password of 1234. Once connected, the letter 'P' will be sent. If a response of 'M' then there is a very high likelihood there is a skimmer in the bluetooth range of your phone (5 to 15 feet). I can show you the code I already have: class ScanViewController: UIViewController, CBPeripheralDelegate, CBCentralManagerDelegate {          // Properties Back-End         private var centralManager: CBCentralManager!         private var peripherals: [CBPeripheral] = []         private var peripheral: CBPeripheral!         override func viewDidLoad() {         super.viewDidLoad()         view.backgroundColor = .systemGroupedBackground                  centralManager = CBCentralManager(delegate: self, queue: nil)            }     //MARK: - Back-End          // If we're powered on, start scanning            func centralManagerDidUpdateState(_ central: CBCentralManager) {                print("Central state update")                if central.state != .poweredOn {                    print("Central is not powered on")                } else {                    print("Central scanning for", ParticlePeripheral.skimmerDeviceUUID);                    centralManager.scanForPeripherals(withServices: [ParticlePeripheral.skimmerDeviceUUID],                                                      options: [CBCentralManagerScanOptionAllowDuplicatesKey : true])                }            }          // Handles the result of the scan            func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {                // We've found it so stop scan                self.centralManager.stopScan()             print("Stopped to scan")                // Copy the peripheral instance                self.peripheral = peripheral                self.peripheral.delegate = self                // Connect!                self.centralManager.connect(self.peripheral, options: nil)                         }          // The handler if we do connect succesfully             func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {                 if peripheral == self.peripheral {                     print("Connected to Skimmer Scammer")                     peripheral.discoverServices([ParticlePeripheral.skimmerDeviceUUID])                 }             }          // Handles discovery event             func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {                 if let services = peripheral.services {                     for service in services {                         if service.uuid == ParticlePeripheral.skimmerDeviceUUID {                             print("Skimmer Scanner service found")                             //Now kick off discovery of characteristics                             peripheral.discoverCharacteristics([...], for: service)                             return                         }                     }                 }             } class ParticlePeripheral: NSObject {         // I think thats the uuid for HC-05         public static let skimmerDeviceUUID     = CBUUID.init(string: "00001101-0000-1000-8000-00805F9B34FB")     } I googled around for hours but I wasn't able to find a solution and I have never worked with Bluetooth connections before, that makes it really difficult but I tried. My questions: is the code I already have valid? How to can I connect via pin code? "1234" I would be so helpful if someone here has some advices for me, thanks in advance!
1
0
3.0k
Feb ’22
UICollectionView Layout Error: nil layout parameter
Hey guys, when I run my project the error: 'UICollectionView must be initialized with a non-nil layout parameter', appears. I don't know why because I already used the same code in another project and it worked. This is my code:  var myCollectionView : UICollectionView? func setUpContactsCollectionView() {         let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()         layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)         layout.itemSize = CGSize(width: 100, height: 100)         layout.scrollDirection = .horizontal                myCollectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)         myCollectionView?.showsHorizontalScrollIndicator = false                  myCollectionView?.register(InserateCollectionCell.self, forCellWithReuseIdentifier: "InserateCollectionCell")         myCollectionView?.backgroundColor = UIColor.white                  myCollectionView?.dataSource = self         myCollectionView?.delegate = self   myCollectionView?.translatesAutoresizingMaskIntoConstraints = false         myCollectionView?.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true         myCollectionView?.topAnchor.constraint(equalTo: topAnchor, constant: 50).isActive = true         myCollectionView?.widthAnchor.constraint(equalTo: widthAnchor).isActive = true         myCollectionView?.heightAnchor.constraint(equalTo: heightAnchor).isActive = true     } Thanks in advance!
12
0
3k
Jan ’22
Search for HC-05 Bluetooth device via Bluetooth
Good afternoon guys, I want to create an app that's detects common bluetooth based credit card skimmers predominantly found in gas pumps. The app scans for available bluetooth connections looking for a device with title HC-05. If found, the app will attempt to connect using the default password of 1234. Once connected, the letter 'P' will be sent. If a response of 'M' then there is a very high likelihood there is a skimmer in the bluetooth range of your phone (5 to 15 feet). I can show you the code I already have: class ScanViewController: UIViewController, CBPeripheralDelegate, CBCentralManagerDelegate {          // Properties Back-End         private var centralManager: CBCentralManager!         private var peripherals: [CBPeripheral] = []         private var peripheral: CBPeripheral!         override func viewDidLoad() {         super.viewDidLoad()         view.backgroundColor = .systemGroupedBackground                  centralManager = CBCentralManager(delegate: self, queue: nil)            }     //MARK: - Back-End          // If we're powered on, start scanning            func centralManagerDidUpdateState(_ central: CBCentralManager) {                print("Central state update")                if central.state != .poweredOn {                    print("Central is not powered on")                } else {                    print("Central scanning for", ParticlePeripheral.skimmerDeviceUUID);                    centralManager.scanForPeripherals(withServices: [ParticlePeripheral.skimmerDeviceUUID],                                                      options: [CBCentralManagerScanOptionAllowDuplicatesKey : true])                }            }          // Handles the result of the scan            func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {                // We've found it so stop scan                self.centralManager.stopScan()             print("Stopped to scan")                // Copy the peripheral instance                self.peripheral = peripheral                self.peripheral.delegate = self                // Connect!                self.centralManager.connect(self.peripheral, options: nil)                         }          // The handler if we do connect succesfully             func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {                 if peripheral == self.peripheral {                     print("Connected to Skimmer Scammer")                     peripheral.discoverServices([ParticlePeripheral.skimmerDeviceUUID])                 }             }          // Handles discovery event             func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {                 if let services = peripheral.services {                     for service in services {                         if service.uuid == ParticlePeripheral.skimmerDeviceUUID {                             print("Skimmer Scanner service found")                             //Now kick off discovery of characteristics                             peripheral.discoverCharacteristics([...], for: service)                             return                         }                     }                 }             } class ParticlePeripheral: NSObject {         // I think thats the uuid for HC-05         public static let skimmerDeviceUUID     = CBUUID.init(string: "00001101-0000-1000-8000-00805F9B34FB")     } I googled around for hours but I wasn't able to find a solution and I have never worked with Bluetooth connections before, that makes it really difficult but I tried. My questions: is the code I already have valid? How to can I connect via pin code? "1234" I would be so helpful if someone here has some advices for me, thanks in advance!
Replies
1
Boosts
0
Views
3.0k
Activity
Feb ’22
UICollectionView Layout Error: nil layout parameter
Hey guys, when I run my project the error: 'UICollectionView must be initialized with a non-nil layout parameter', appears. I don't know why because I already used the same code in another project and it worked. This is my code:  var myCollectionView : UICollectionView? func setUpContactsCollectionView() {         let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()         layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)         layout.itemSize = CGSize(width: 100, height: 100)         layout.scrollDirection = .horizontal                myCollectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)         myCollectionView?.showsHorizontalScrollIndicator = false                  myCollectionView?.register(InserateCollectionCell.self, forCellWithReuseIdentifier: "InserateCollectionCell")         myCollectionView?.backgroundColor = UIColor.white                  myCollectionView?.dataSource = self         myCollectionView?.delegate = self   myCollectionView?.translatesAutoresizingMaskIntoConstraints = false         myCollectionView?.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true         myCollectionView?.topAnchor.constraint(equalTo: topAnchor, constant: 50).isActive = true         myCollectionView?.widthAnchor.constraint(equalTo: widthAnchor).isActive = true         myCollectionView?.heightAnchor.constraint(equalTo: heightAnchor).isActive = true     } Thanks in advance!
Replies
12
Boosts
0
Views
3k
Activity
Jan ’22