天道酬勤,学无止境

cbperipheral

外设的中心写入特性(iOS Core Bluetooth)(Central writing characteristic to Peripheral (iOS Core Bluetooth))

问题 Okay, so I've looked through a thousand tutorials and other Stack Overflow threads (so please don't list as duplicate without answering the question) and I cannot work out how to use this functionality. I have followed this tutorial: http://code.tutsplus.com/tutorials/ios-7-sdk-core-bluetooth-practical-lesson--mobile-20741 I have a system where a central can connect to a peripheral and read a characteristic from it. I am now trying to get my central to rewrite the data within the characteristic but am finding the write line that I have called just being ignored. I have declared my

2021-06-12 23:22:16    分类:技术分享    ios   objective-c   bluetooth   cbcentralmanager   cbperipheral

CoreBluetooth 设备名称更改(CoreBluetooth device name change)

问题 我目前正在创建一个简单的 iOS 蓝牙应用程序。 我目前有一个能够修改名称的设备。 我发现当我连接到 CBPeripheral 设备时,它似乎正在缓存旧设备名称。 通过我的应用程序连接到设备。 通过我的应用程序断开与设备的连接。 更改设备名称。 通过我的应用程序(使用现有的 CBPeripheral 对象)重新发现/重新连接到设备。 按照上述步骤,我希望我的 iOS 应用程序能够发现新的设备名称。 但是,我发现它倾向于保留旧名称。 通过两次与 CBPeripheral 设备断开连接,我发现我可以检索新名称。 所以我的问题是,有没有办法更新或清除 CBPeripheral 现有的已发现特征(或每次重新发现新特征)以获得最新的设备名称? 这是一个类似的问题:CoreBluetooth: Refreshing local name of an already found Peripheral 回答1 我遇到了类似的问题,而且这不仅仅是设备名称的问题,而是某些特性在特定模式下发生了变化(例如设备上的固件升级)。 从苹果得到以下答案: “答案是配件需要支持 GATT Service Changed 特性——请阅读规范,特别是 Vol 3, Part G, 2.5.2 和 Vol 3, Part G, 7.1。” 名称问题已通过将设备名称作为广告数据中的属性进行广告来解决。 (然而

2021-06-12 13:58:42    分类:技术分享    ios   bluetooth   core-bluetooth   cbperipheral

我想触发 iOS7 请求用户许可使用蓝牙和 Twitter 帐户(I want to trigger iOS7 to ask users permission to use Bluetooth and Twitter account)

问题 这与大多数人的要求有些落后。 我想故意触发对话框,要求用户允许: 连接到蓝牙设备,即使在离线状态下。 访问那里基于 iOS 的 Twitter 帐户。 我已经有一个类似的对话框用于定位工作正常。 我这样做是因为我想让请求许可的过程更温和一些,就像 Heyday,通过显示一个欢迎屏幕来解释为什么应用程序需要这个服务,然后当用户点击“确定”时,启动请求并触发对话框。 我已经尝试了一些东西。 对于 Twitter,我尝试了以下方法: - (void)triggerTwitterApprovalWithCompletion:(void (^)(BOOL, NSError *))completion { self.accountStore = [[ACAccountStore alloc] init]; //setup as a property. ACAccountType *twitterAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; [self.accountStore requestAccessToAccountsWithType:twitterAccountType options:nil completion:^

2021-06-11 22:06:58    分类:技术分享    ios   ios7   bluetooth   core-bluetooth   cbperipheral

How long is a CBPeripheral's stored UUID valid for reconnection? [duplicate]

This question already has an answer here: CoreBluetooth: What is the lifetime of unique UUIDs (1 answer) Closed 6 years ago. I've been playing with Corebluetooth and I've learnt that besides going through the tedious process of scanning for a peripheral every time I want to connect, I can also store the peripheral's UUID and use it with retrievePeripheralsWithIdentifiers and connectPeripheral for further reconnections. Turns out that it only works for a certain amount of time, apparently the peripheral has its UUID updated, therefore the stored one can be considered expired. I haven't been

2021-06-11 19:42:34    分类:问答    ios   uuid   core-bluetooth   cbperipheral

Peripheral transmit queue issue

I’m working on a simple wrapper around CoreBluetooth to send any data to any device. During developing I encountered a lot of bugs in framework, they were very annoying and to make my wrapper stable I had to shorten some of functionality for reliability. For now I’m working on sending data from peripheral. Ok, so I have following case: Client asks for value of dynamic characteristic I get a callback on server-side - peripheral:didReceiveReadRequest:. Note : I need to respond to this CBATTRequest in this method - I can’t store it elsewhere and respond to it asynchronously. (Im just putting some

2021-06-11 06:53:31    分类:问答    ios   core-bluetooth   peripherals   cbcentralmanager   cbperipheral

更快地重新连接 CBPeripheral(Reconnect a CBPeripheral faster)

问题 我正在开发一个应用程序,该应用程序可以多次连接和断开与不同蓝牙低功耗外围设备的连接。 经过在互联网上的大量研究,我没有找到一种方法来存储已经发现的服务和特征,以便我可以更快地重新连接。 目前,每次重新连接后我都会发现所需的服务和特征,这花费了我 1.5 到 2 秒的时间。 有人有存储/缓存 CBService 或 CBCharacteristic 的经验或解决方案,或者有人知道更快重新连接的方法吗? 谢谢你的帮助 回答1 我试过在内存中缓存外设、服务和特征对象,但手动缓存不起作用。 一旦与外围设备断开连接,服务和特征对象将不再有效使用。 事实上,即使是 CBPeripheral 也可以从你身下改变——CoreBluetooth 有一个内部行为,设备 UDID 每隔几分钟就会改变一次(如果 CBPeripheral 是另一个 iOS 设备)。 但是,如果您正在为 iOS 6 进行开发,则有一种方法可以加快速度。 如果您在 WWDC 2012 上观看高级蓝牙演讲,您会看到关于缓存服务和特性的幻灯片。 本质上,操作系统可以为您缓存它们,但仅限于配对设备。 要配对,您需要响应身份验证不足错误的写入请求。 例如,对于 iOS 外围设备,您可以编写如下内容: - (void)peripheralManager:(CBPeripheralManager *

2021-06-09 17:55:25    分类:技术分享    ios   objective-c   core-bluetooth   bluetooth-lowenergy   cbperipheral

How To Store a CBPeripheral For Use in Other Views

I setup a few BLE connections in my view controller, SViewController, and I need to store the peripherals for use in other view controllers. I've tried creating an NSUserDefault object and storing the peripherals in there, but I got the error "Attempt to insert non-property value", and it never inserted. I then tried wrapping it up in an NSData object and storing it in NSUserDefaults, but got the error "-[CBConcretePeripheral encodeWithCoder:]: unrecognized selector sent" and the app crashed. So that definitely did not work. I've also tried making the three CBPeripheral variables global, but I

2021-06-05 01:17:37    分类:问答    ios   objective-c   core-bluetooth   bluetooth-lowenergy   cbperipheral

CoreBluetooth Central --> Peripheral

I'm quite new to bluetooth communication. My first project intends to transfer data from an iOS device to a BLEshield (small chip). To test my central code, I decided to setup an iPhone as peripheral (the role the chip will have, once I got it) and an iPad as Central. I can connect the devices and also send data from the peripheral to the central. It's quite easy though: - (void)startService { _readChar = [[CBMutableCharacteristic alloc] initWithType:[CBUUID ...] properties:CBCharacteristicPropertyNotify value:nil permissions:CBAttributePermissionsReadable]; _writeChar = [

2021-06-03 08:33:48    分类:问答    ios   bluetooth-lowenergy   core-bluetooth   cbperipheral   cbcentralmanager

Central writing characteristic to Peripheral (iOS Core Bluetooth)

Okay, so I've looked through a thousand tutorials and other Stack Overflow threads (so please don't list as duplicate without answering the question) and I cannot work out how to use this functionality. I have followed this tutorial: http://code.tutsplus.com/tutorials/ios-7-sdk-core-bluetooth-practical-lesson--mobile-20741 I have a system where a central can connect to a peripheral and read a characteristic from it. I am now trying to get my central to rewrite the data within the characteristic but am finding the write line that I have called just being ignored. I have declared my

2021-06-01 04:18:50    分类:问答    ios   objective-c   bluetooth   cbcentralmanager   cbperipheral

Reconnect a CBPeripheral faster

I'm developing an app which connects and disconnects several times to different bluetooth low energy peripherals. After a lot of research on the internet, I didn't have found a way to store already discovered services and characteristics, so that I can reconnect faster. At the moment I'm discovering the required services and characteristics after each reconnection, which costs me between 1.5 and 2 seconds. Does someone have experience or a solution to store/cache a CBService or a CBCharacteristic or does someone know a way to reconnect faster? Thanks for any help

2021-05-25 10:09:09    分类:问答    ios   objective-c   core-bluetooth   bluetooth-lowenergy   cbperipheral