{"id":19847023,"url":"https://github.com/polidea/plxcorebluetooth-racextensions","last_synced_at":"2025-05-01T21:31:40.372Z","repository":{"id":62450090,"uuid":"51926371","full_name":"Polidea/PLXCoreBluetooth-RACExtensions","owner":"Polidea","description":"Reactive Cocoa Extensions to CoreBluetooth","archived":false,"fork":false,"pushed_at":"2017-04-28T06:57:42.000Z","size":3846,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-11-12T11:46:30.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Polidea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-17T13:57:32.000Z","updated_at":"2021-07-24T13:03:16.000Z","dependencies_parsed_at":"2022-11-01T22:31:51.148Z","dependency_job_id":null,"html_url":"https://github.com/Polidea/PLXCoreBluetooth-RACExtensions","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2FPLXCoreBluetooth-RACExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2FPLXCoreBluetooth-RACExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2FPLXCoreBluetooth-RACExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Polidea%2FPLXCoreBluetooth-RACExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Polidea","download_url":"https://codeload.github.com/Polidea/PLXCoreBluetooth-RACExtensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224278377,"owners_count":17285080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T13:13:15.112Z","updated_at":"2024-11-12T13:13:15.621Z","avatar_url":"https://github.com/Polidea.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PLXCoreBluetooth\n\n`PLXCoreBluetooth` is a thin abstraction layer over `CBCentralManager` and `CBPeripheral` that enables programming using Reactive Cocoa.\n\n## Usage\n\n### Sample App\n\nTake a look at example app, it illustrates all common usage cases pretty straightforward.\nTo run it, clone the repo, and run `pod install` from the Example directory first or run `pod try PLXCoreBluetooth`.\n\n### Example\n\nLet's try to scan for some peripherals, connect to them, discover characteristics for given services and read them. Easy.\n\n```objc\n\n@weakify(self)\n[[[[self.centralManager rac_scanForPeripheralsWithServices:@[mySpecialService]\n                                                     count:PLXCBCentralManagerScanInfiniteCount\n                                                   options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @NO}]\n        reduceEach:^id(CBPeripheral *peripheral, NSDictionary\u003cNSString *, id\u003e *advertisementData, NSNumber *RSSI) {\n            return peripheral;\n        }]\n        flattenMap:^RACSignal *(CBPeripheral *peripheral) {\n            @strongify(self)\n            return [[[self.centralManager\n                    rac_connectPeripheral:peripheral options:nil]\n                    flattenMap:^RACSignal *(CBPeripheral *_) {\n                        return [peripheral rac_discoverCharacteristics:nil forService:mySpecialService];\n                    }]\n                    flattenMap:^RACSignal *(NSArray\u003cCBCharacteristic *\u003e *characteristics) {\n                        return [[[characteristics.rac_sequence signal]\n                                flattenMap:^RACSignal *(CBCharacteristic *characteristic) {\n                                    return [peripheral rac_readValueForCharacteristic:characteristic];\n                                }]\n                                collect];\n                    }];\n        }]\n```\n\n### API\n\nThere are two sets of extensions, first for `CBCentralManager`, second for `CBPeripheral`.\n\n#### `CBCentralManager`\n\nThis is a property that determines whether all methods below should continue only if `CBCentralManager` is in powered on state. If it's set to YES each of them will be blocking and will wait for powered on state. Otherwise, default behavior is to finish immediately with error.\n\nBy default set to NO.\n\n```objc\n@property(nonatomic, assign) BOOL plx_shouldWaitUntilPoweredOn;\n```\n\n##### Scanning\n\nScan method returns signal with first `count` scanned peripherals info tuples (peripheral, advertisementData, RSSI) for given services.\nFor infinite scan count there should be passed `PLXCBCentralManagerScanInfiniteCount`.\n\nIf scan is limited and all peripherals are discovered `stopScan` will be called automatically.\n`stopScan` will be called as well when signal is disposed.\n\n```objc\n- (RACSignal *)rac_scanForPeripheralsWithServices:(nullable NSArray\u003cCBUUID *\u003e *)serviceUUIDs\n                                            count:(NSInteger)count\n                                          options:(nullable NSDictionary\u003cNSString *, id\u003e *)options;\n```\n\nStop scan method is just a wrapper for `stopScan` that returns `@YES` after calling it.\n\n```objc\n- (RACSignal *)rac_stopScan;\n```\n\n##### Connecting\n\nConnect method connects to the peripheral and returns it on success. On connection failure it returns error signal.\n\n```objc\n- (RACSignal *)rac_connectPeripheral:(CBPeripheral *)peripheral\n                             options:(nullable NSDictionary\u003cNSString *, id\u003e *)options;\n```\n\nDisconnect method disconnects from the peripheral and returns it on success. On disconnection failure it returns error signal.\n\n```objc\n- (RACSignal *)rac_disconnectPeripheralConnection:(CBPeripheral *)peripheral;\n```\n\n##### Misc\n\nThere's a signal that is updated whenever power on property changes.\n\n```objc\n- (RACSignal *)rac_isPoweredOn;\n```\n\n#### `CBPeripheral`\n\nThis is a property that determines whether all methods below should continue only if `CBPeripheral` is in connected state. If it's set to YES each of them will be blocking and will wait for connected state. Otherwise, default behavior is to finish immediately with error.\n\nBy default set to NO.\n\n```objc\n@property(nonatomic, assign) BOOL plx_shouldWaitUntilConnected;\n```\n\nThis property returns most recent name and subscribes for peripheral name changes.\n\n```objc\n@property(nonatomic, strong, readonly) RACSignal *rac_name;\n```\n\nThis method returns signal subscribed for peripheral name changes.\n\n```objc\n- (RACSignal *)rac_peripheralDidUpdateName;\n```\n\nThis method returns signal containing services peripheral that have been changed over time.\n\n```objc\n- (RACSignal *)rac_peripheralDidModifyServices;\n```\n\n##### Discovery\n\nReturns an array of discovered services.\n\n```objc\n- (RACSignal *)rac_discoverServices:(nullable NSArray\u003cCBUUID *\u003e *)serviceUUIDs;\n```\n\nReturns an array of discovered included services for given service.\n\n```objc\n- (RACSignal *)rac_discoverIncludedServices:(nullable NSArray\u003cCBUUID *\u003e *)includedServiceUUIDs\n                                 forService:(CBService *)service;\n```\n\nReturns an array of discovered characteristics for given service.\n\n```objc\n- (RACSignal *)rac_discoverCharacteristics:(nullable NSArray\u003cCBUUID *\u003e *)characteristicUUIDs\n                                forService:(CBService *)service;\n```\n\nReturns an array of discovered descriptors for given characteristic.\n\n```objc\n- (RACSignal *)rac_discoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic;\n```\n\n##### Reading\n\nThis method returns RSSI and completes, error signal otherwise.\n\n```objc\n- (RACSignal *)rac_readRSSI;\n```\n\nThose methods return read value and complete on successful read, error otherwise.\n\n```objc\n- (RACSignal *)rac_readValueForCharacteristic:(CBCharacteristic *)characteristic;\n\n- (RACSignal *)rac_readValueForDescriptor:(CBDescriptor *)descriptor;\n```\n\n##### Writing\n\nThose methods return boolean YES and complete on successful write, error otherwise.\n\n```objc\n- (RACSignal *)rac_writeValue:(NSData *)data\n            forCharacteristic:(CBCharacteristic *)characteristic\n                    writeType:(CBCharacteristicWriteType)writeType;\n\n- (RACSignal *)rac_writeValue:(NSData *)data\n                forDescriptor:(CBDescriptor *)descriptor;\n```\n\n##### Updating\n\nThis method returns boolean YES and completes if change succeeds, or error otherwise.\n\n```objc\n- (RACSignal *)rac_setNotifyValue:(BOOL)enabled\n       forChangesInCharacteristic:(CBCharacteristic *)characteristic;\n```\n\nThis method returns updated values (from `peripheral:didUpdateValueForCharacteristic:error:` callback), or error if update fails.\n\n```objc\n- (RACSignal *)rac_setNotifyValue:(BOOL)enabled\nandGetUpdatesForChangesInCharacteristic:(CBCharacteristic *)characteristic;\n```\n\nThis method returns stream of signals with value or error (taken from `peripheral:didUpdateValueForCharacteristic:error:` callback).\n\n```objc\n- (RACSignal *)rac_listenForUpdatesForCharacteristic:(nullable CBCharacteristic *)characteristic;\n```\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 7.2+\n\n## Installation\n\nPLXCoreBluetooth is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"PLXCoreBluetooth\"\n```\n\n## Authors\n\nMaciej Oczko, maciek.oczko@polidea.com\n\nMichal Mizera, michal.mizera@polidea.com\n\n## License\n\nPLXCoreBluetooth is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolidea%2Fplxcorebluetooth-racextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolidea%2Fplxcorebluetooth-racextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolidea%2Fplxcorebluetooth-racextensions/lists"}