发现后,iOS外围设备服务仍然为空 [英] iOS peripheral service still empty after discovering

查看:258
本文介绍了发现后,iOS外围设备服务仍然为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用蓝牙
我有这样的东西:

I am trying to use Bluetooth I have something like this :

func centralManager(central: CBCentralManager, didConnectPeripheral peripheral: CBPeripheral) {
    Connected = true
    TableView.reloadData()
    Activityview.stopAnimating()
    TabBar.topItem!.rightBarButtonItem = UIBarButtonItem(title: "Suivant", style: UIBarButtonItemStyle.Done, target: nil, action: #selector(Connexion.next))
    CM.stopScan()
    Scanning = false
    Refresh_Button.setTitle("Deconnecté", forState: UIControlState.Normal)
    let AlertMessage = UIAlertController(title: "Connecté", message: "Le module est bien connecté", preferredStyle: .Alert)
    let ActionAlert = UIAlertAction(title: "Ok", style: .Default) { (action) in }
    AlertMessage.addAction(ActionAlert)
    self.presentViewController(AlertMessage, animated: true, completion: nil)
    peripheral.delegate = self
    let servicetoFind = CBUUID(string: "19B10000-E8F2-537E-4F6C-D104768A1214")
    peripheral.discoverServices([servicetoFind])
}

我的服务功能:

func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) {
    print("found service")
    print(peripheral)
    print(peripheral.services)
    print(error)
    for service in peripheral.services! {
        print("Searching for charac...")
        peripheral.discoverCharacteristics(nil, forService: service)
    }
}

找到我的服务,并且进入控制台:

my Service is found and I got in console :

found service
<CBPeripheral: 0x13ce1c430, identifier = F39F9D5D-98FE-A350-17BD-21C1185E2089, name = GENUINO 101-1E2D, state = connected>
Optional([])
nil

为什么我为外围设备提供的服务发现之后仍然空着,但没有出错?

Why my services for my peripheral is still empty after discovering but got no error ?

有什么想法吗?

谢谢!

推荐答案

好吧,我重启了iPhone,现在一切都很好...谢谢大家!

Well, I restarted my iPhone and all work very good now... Thanks guys !

这篇关于发现后,iOS外围设备服务仍然为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆