J'essaie de créer une application iOS qui va lire à partir d'un périphérique OBDII Bluetooth 4 (LE). J'ai acheté un VGA icar3 bluetooth (4.0) elm327 OBDII. Je le branche dans ma voiture et trouve le périphérique IOS-VLink qui annonce certains services. Je peux ensuite obtenir les caractéristiques de ces services. Ce sont les services que je trouve:Comment utiliser BLE OBDII Peripheral
<CBService: 0x1780729c0, isPrimary = YES, UUID = Battery>
<CBService: 0x178072a80, isPrimary = YES, UUID = 1803>
<CBService: 0x178072ac0, isPrimary = YES, UUID = 1802>
<CBService: 0x178072b00, isPrimary = YES, UUID = 1811>
<CBService: 0x178072b40, isPrimary = YES, UUID = 1804>
<CBService: 0x178072b80, isPrimary = YES, UUID = 18F0>
<CBService: 0x178072bc0, isPrimary = YES, UUID = Device Information>
<CBService: 0x178072c00, isPrimary = YES, UUID = E7810A71-73AE-499D-8C15-FAA9AEF0C3F2>
Mais je ne sais pas quels sont ou comment les utiliser les 1803, 1802, 1811, 1804 et services 18F0. Voici mon programme simple pour savoir ce qui est annoncé.
class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate {
var centralManager = CBCentralManager()
var peripherals = [CBPeripheral]()
@IBOutlet weak var outputTextView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
centralManager.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
print("connected to \(peripheral.name ?? "unnamed")")
peripheral.delegate = self
peripheral.discoverServices(nil)
}
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if central.state == .poweredOn {
central.scanForPeripherals(withServices: nil, options: nil)
}
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
if peripheral.name == "IOS-Vlink" {
peripherals.append(peripheral)
print(peripheral.name ?? "peripheral has no name")
print(peripheral.description)
central.connect(peripheral, options: nil)
central.stopScan()
}
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
guard let services = peripheral.services else {
return
}
for service in services {
print(service.description)
peripheral.discoverCharacteristics(nil, for: service)
}
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
guard let chars = service.characteristics else {
return
}
for char in chars {
print(char.description)
}
}
}
Je trouve cela sur le E7810A ... UUID http://www.globals.market/offer/bcm20710%2520dual%2520mode%2520bluetooth%2520module%2520to%2520support%2520the%2520android%2520ios%2520apple% 2520master% 2520slave% 2520software% 2520can% 2520be% 2520customized% 2520at% 2520version-tb44737964123.html et ce https://www.bluetooth.com/specifications/gatt/services sur les autres uuids. Je ne sais toujours pas comment les utiliser. –