完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,大家好,
我从Alan Hawse的Xcode的教程如何使用BLE让iOS应用程序(链接:http://www.cypress.com/training/ ... ooth-low-energy-ble 我下载Xcode 8版本代码从GitHub页面: bleapp / Xcode / bleremote大师·cypresssemiconductorco / bleapp·GitHub 当我用Xcode 8,此程序的工作,但当我将它转换为Xcode 9,BLE设备(机器人)将不会显示在扫描设备的屏幕。它只会出现空白。我试着在iOS设备扫描BLE设备使用报表打印,但打印语句不会显示在输出,这意味着iOS智能手机没有发现任何PSoC器件时,它扫描。 我可能已经缩小了问题的原因,一些所谓的“notificationcenter”,具有这些全局变量: 结构RcNovices { 静让founddevice =“COM。柏树。bleremote。founddevice” 静让connectioncomplete =“COM。柏树。bleremote。connectioncomplete” 静让disconnecteddevice =“COM。柏树。bleremote。disconnecteddevice” 静让updatedspeed =“COM。柏树。bleremote。updatedspeed” 静让updatedtach =“COM。柏树。bleremote。updatedtach” } 顺便问一下,你们知道这些全局变量的意思吗?我不知道它为什么叫“COM。柏树。bleremote。founddevice”时,那不是我的包标识符,如果我改变它一样我的包标识符(COM应用程序。bleremote),它并没有什么不同。 为notificationcenter代码,这看起来是这样的当我打电话给一个全局变量(在Xcode 9): notificationcenter默认addObserver(forName:通知。名字(原始数值:rcnotifications。founddevice),对象:零,队列:operationqueue。主){ _在 Auto.TabLVIEW .RealDeDATA() 打印(“设备发现”) } 这是代码行我前面提到的,我把打印的声明,没有出现在输出窗口。 这就是同样的代码看起来像在Xcode 8我自动固定之前的一切: NSNotificationCenter。defaultcenter()。addobserverforname(rcnotifications.founddevice,对象:零,队列:NSOperationQueue。mainqueue()){ _在 Auto.TabLVIEW .RealDeDATA() 打印(“设备发现”) } 你们知道什么地方出了错,从变化到Xcode 9? 谢谢, 安德鲁·柯林斯 以上来自于百度翻译 以下为原文 Hi All, I have followed the Xcode BLE tutorials from Alan Hawse for how to make an iOS App using BLE (link: http://www.cypress.com/training/ ... ooth-low-energy-ble I downloaded the Xcode 8 version code from this github page: bleapp/Xcode/BleRemote at master · cypresssemiconductorco/bleapp · GitHub When I used Xcode 8, this program worked, but when I converted it to Xcode 9, the BLE device (Robot) would not show up in the scan for devices screen. It would just show up blank. I tried using print statements in the place where the iOS device scans for BLE devices, but the print statement doesn't show up in the output, meaning that the iOS smartphone is not finding any PSoC devices when it scans. I may have narrowed down the cause of the problem to something called the "NotificationCenter", which has these globals: struct RCNotifications { static let FoundDevice = "com.cypress.bleremote.founddevice" static let ConnectionComplete = "com.cypress.bleremote.connectioncomplete" static let DisconnectedDevice = "com.cypress.bleremote.disconnecteddevice" static let UpdatedSpeed = "com.cypress.bleremote.updatedspeed" static let UpdatedTach = "com.cypress.bleremote.updatedtach" } By the way, do any of you know what these globals mean? For I do not know why it is calling "com.cypress.bleremote.founddevice" when that is not my bundle identifier, and if I change it to be the same as my bundle identifier (com.app.bleremote), it doesn't really make a difference. For the NotificationCenter code, this is how it looks like when I call one of these globals (in Xcode 9): NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: RCNotifications.FoundDevice), object: nil, queue: OperationQueue.main) { _ in self.tableView.reloadData() print("Device Found") } This is the line of code I mentioned earlier where I put a print statement that didn't appear in the output window. And this is how that same code looked like in Xcode 8 before I auto-fixed everything: NSNotificationCenter.defaultCenter().addObserverForName(RCNotifications.FoundDevice, object: nil, queue: NSOperationQueue.mainQueue()) { _ in self.tableView.reloadData() print("Device Found") } Do any of you know what went wrong from the changes to Xcode 9? Thanks, Andrew Collins |
|
相关推荐
2个回答
|
|
全局只是代表不同的广播事件似乎不是这里的问题因为字符串只是回调期间用于进行比较。你可以使用你的包的名称或默认,不要紧。
这个问题可能是蓝牙广告过程。我目前只有XCODE 8。将尝试在Xcode 9重现错误,调试发现问题的原因。你可以试着将打印报表的代码从哪里开始搜索设备吗? 当做, 德黑拉杰 以上来自于百度翻译 以下为原文 The globals just represent the different broadcast events and doesn't seem to be the problem here because the strings are just used for comparison during callback. You can use either your bundle name or the default, it doesn't matter. The issue might have something to do with Bluetooth advertisement process. I currently have only XCode 8. Will try to reproduce the error in XCode 9 and will debug to find the cause of the issue. Can you try putting print statements in the code where it starts searching for devices too? Regards, Dheeraj |
|
|
|
twtetrwerw 发表于 2018-8-17 03:55 嗨,Dheeraj, 谢谢你的建议!我在这个代码中放了一个打印语句(来自XCODE 8): 当你看到一个广告包时 功能centralmanager(中央:cbcentralmanager,diddiscoverperipheral周:cbperipheral,advertisementdata:[字符串:任何物体],RSSI:NSNumber) { 如果搜索设备(外围设备)=nIL { 打印(“发现新的周边广告汽车服务”) 让新车= rccar(连接:bleconnection(外围:外围)) 汽车追加(新车) NSNotificationCenter。defaultcenter()。postnotificationname(rcnotifications.founddevice,对象:无) } } /“当你看到一个广告包功能centralmanager(中央:cbcentralmanager,diddiscoverperipheral周:cbperipheral,advertisementdata:[字符串:任何物体],RSSI:NSNumber){如果searchdevices(周)= = nil { print(“发现了一个新的periphal广告motorservice”)让新汽车= RcCar(连接:bleconnection(外围:外围))汽车(新车)。追加NSNotificationCenter。defaultcenter()。postnotificationname(rcnotifications.founddevice,对象:无)} } 当我将它转换为Xcode 9,原来的汽车修理变成私有函数,所以这就是问题的原因。 现在一切都进展顺利。感谢你的帮助! 用感恩的心, 安德鲁·柯林斯 以上来自于百度翻译 以下为原文 Hi Dheeraj, Thanks for your advice! I put a print statement in this code (from Xcode 8): // called when you see an advertising packet func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) { if searchDevices(peripheral) == nil { print("Found a new Periphal advertising motorservice") let newCar = RcCar(connection: BleConnection(peripheral: peripheral)) cars.append(newCar) NSNotificationCenter.defaultCenter().postNotificationName(RCNotifications.FoundDevice, object: nil) } }
When I converted it to Xcode 9, it turns out that the auto-fix turned it into a private function, so that was the cause of the problem. Now everything is running so smoothly. Thanks so much for your help! With gratitude, Andrew Collins |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2106 浏览 1 评论
1853 浏览 1 评论
3671 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1786 浏览 6 评论
1536 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
570浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
423浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
437浏览 2评论
384浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
915浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 07:28 , Processed in 0.884591 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号