{"action":"opened","number":9,"pull_request":{"url":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/9","id":66654611,"html_url":"https://github.com/Polidea/RxBluetoothKit/pull/9","diff_url":"https://github.com/Polidea/RxBluetoothKit/pull/9.diff","patch_url":"https://github.com/Polidea/RxBluetoothKit/pull/9.patch","issue_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/9","number":9,"state":"open","locked":false,"title":"Feature/convenience peripheral functions","user":{"login":"Kacper20","id":6010341,"avatar_url":"https://avatars.githubusercontent.com/u/6010341?v=3","gravatar_id":"","url":"https://api.github.com/users/Kacper20","html_url":"https://github.com/Kacper20","followers_url":"https://api.github.com/users/Kacper20/followers","following_url":"https://api.github.com/users/Kacper20/following{/other_user}","gists_url":"https://api.github.com/users/Kacper20/gists{/gist_id}","starred_url":"https://api.github.com/users/Kacper20/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kacper20/subscriptions","organizations_url":"https://api.github.com/users/Kacper20/orgs","repos_url":"https://api.github.com/users/Kacper20/repos","events_url":"https://api.github.com/users/Kacper20/events{/privacy}","received_events_url":"https://api.github.com/users/Kacper20/received_events","type":"User","site_admin":false},"body":"I've written convenience functions to `Peripheral` as an extension.\r\nMotivation is to provide to user simpler interface and not force him to use every time `discover` methods.\r\nWith this, user can create for example enums for every device he wants to use like that:\r\n```enum XXXCharacteristic: String, CharacteristicIdentifier {\r\n    case ManufacturerName = \"2A29\"\r\n    case GenericCommunication = \"XXXX\"\r\n\r\n    var UUID: CBUUID {\r\n        return CBUUID(string: self.rawValue)\r\n    }\r\n    var service: ServiceIdentifier {\r\n        switch self {\r\n        case .ManufacturerName:\r\n            return XXXService.DeviceInformation\r\n        case .GenericCommunication:\r\n            return XXXService.GenericCommunication\r\n        }\r\n    }\r\n}\r\nenum XXXService: String, ServiceIdentifier {\r\n    case DeviceInformation = \"180A\"\r\n    case GenericCommunication = \"XXX\"\r\n\r\n    var UUID: CBUUID {\r\n        return CBUUID(string: self.rawValue)\r\n    }\r\n}```\r\nLater, thanks to that, simple action like making connection and reading value shortens from:\r\n```\r\nperipheral.connect()\r\n    .flatMap { Observable.from($0.discoverServices([serviceId])) }\r\n    .flatMap { Observable.from($0.discoverCharacteristics([characteristicId])}\r\n    .flatMap { $0.readValue }\r\n    .subscribeNext {\r\n        let data = $0.value\r\n    }\r\n```\r\nto:\r\n```\r\nperipheral.connect()\r\n    .flatMap { $0.readValueFromCharacteristicWithId(XXXCharacteristic.ManufacturerName)\r\n    .subscribeNext {\r\n        let data = $0.value\r\n    }\r\n```\r\nAlso, if characteristic / descriptor / service is available in cache - we use it.","created_at":"2016-04-15T14:48:05Z","updated_at":"2016-04-15T14:48:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":{"login":"literator","id":242131,"avatar_url":"https://avatars.githubusercontent.com/u/242131?v=3","gravatar_id":"","url":"https://api.github.com/users/literator","html_url":"https://github.com/literator","followers_url":"https://api.github.com/users/literator/followers","following_url":"https://api.github.com/users/literator/following{/other_user}","gists_url":"https://api.github.com/users/literator/gists{/gist_id}","starred_url":"https://api.github.com/users/literator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/literator/subscriptions","organizations_url":"https://api.github.com/users/literator/orgs","repos_url":"https://api.github.com/users/literator/repos","events_url":"https://api.github.com/users/literator/events{/privacy}","received_events_url":"https://api.github.com/users/literator/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/9/comments","statuses_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/statuses/664426a04eac3159940113e071782250724c798f","head":{"label":"Polidea:feature/convenience_peripheral_functions","ref":"feature/convenience_peripheral_functions","sha":"664426a04eac3159940113e071782250724c798f","user":{"login":"Polidea","id":1611150,"avatar_url":"https://avatars.githubusercontent.com/u/1611150?v=3","gravatar_id":"","url":"https://api.github.com/users/Polidea","html_url":"https://github.com/Polidea","followers_url":"https://api.github.com/users/Polidea/followers","following_url":"https://api.github.com/users/Polidea/following{/other_user}","gists_url":"https://api.github.com/users/Polidea/gists{/gist_id}","starred_url":"https://api.github.com/users/Polidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polidea/subscriptions","organizations_url":"https://api.github.com/users/Polidea/orgs","repos_url":"https://api.github.com/users/Polidea/repos","events_url":"https://api.github.com/users/Polidea/events{/privacy}","received_events_url":"https://api.github.com/users/Polidea/received_events","type":"Organization","site_admin":false},"repo":{"id":55787235,"name":"RxBluetoothKit","full_name":"Polidea/RxBluetoothKit","owner":{"login":"Polidea","id":1611150,"avatar_url":"https://avatars.githubusercontent.com/u/1611150?v=3","gravatar_id":"","url":"https://api.github.com/users/Polidea","html_url":"https://github.com/Polidea","followers_url":"https://api.github.com/users/Polidea/followers","following_url":"https://api.github.com/users/Polidea/following{/other_user}","gists_url":"https://api.github.com/users/Polidea/gists{/gist_id}","starred_url":"https://api.github.com/users/Polidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polidea/subscriptions","organizations_url":"https://api.github.com/users/Polidea/orgs","repos_url":"https://api.github.com/users/Polidea/repos","events_url":"https://api.github.com/users/Polidea/events{/privacy}","received_events_url":"https://api.github.com/users/Polidea/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polidea/RxBluetoothKit","description":"iOS Bluetooth library for RxSwift","fork":false,"url":"https://api.github.com/repos/Polidea/RxBluetoothKit","forks_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/forks","keys_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/teams","hooks_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/hooks","issue_events_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/events{/number}","events_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/events","assignees_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/assignees{/user}","branches_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/branches{/branch}","tags_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/tags","blobs_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/statuses/{sha}","languages_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/languages","stargazers_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/stargazers","contributors_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/contributors","subscribers_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/subscribers","subscription_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/subscription","commits_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/contents/{+path}","compare_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/merges","archive_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/downloads","issues_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues{/number}","pulls_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls{/number}","milestones_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/milestones{/number}","notifications_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/labels{/name}","releases_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/releases{/id}","deployments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/deployments","created_at":"2016-04-08T14:57:55Z","updated_at":"2016-04-15T14:00:03Z","pushed_at":"2016-04-15T14:39:35Z","git_url":"git://github.com/Polidea/RxBluetoothKit.git","ssh_url":"git@github.com:Polidea/RxBluetoothKit.git","clone_url":"https://github.com/Polidea/RxBluetoothKit.git","svn_url":"https://github.com/Polidea/RxBluetoothKit","homepage":"","size":675,"stargazers_count":16,"watchers_count":16,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":16,"default_branch":"master"}},"base":{"label":"Polidea:master","ref":"master","sha":"3cd85e52e81395092168058df61ca60a7adaf381","user":{"login":"Polidea","id":1611150,"avatar_url":"https://avatars.githubusercontent.com/u/1611150?v=3","gravatar_id":"","url":"https://api.github.com/users/Polidea","html_url":"https://github.com/Polidea","followers_url":"https://api.github.com/users/Polidea/followers","following_url":"https://api.github.com/users/Polidea/following{/other_user}","gists_url":"https://api.github.com/users/Polidea/gists{/gist_id}","starred_url":"https://api.github.com/users/Polidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polidea/subscriptions","organizations_url":"https://api.github.com/users/Polidea/orgs","repos_url":"https://api.github.com/users/Polidea/repos","events_url":"https://api.github.com/users/Polidea/events{/privacy}","received_events_url":"https://api.github.com/users/Polidea/received_events","type":"Organization","site_admin":false},"repo":{"id":55787235,"name":"RxBluetoothKit","full_name":"Polidea/RxBluetoothKit","owner":{"login":"Polidea","id":1611150,"avatar_url":"https://avatars.githubusercontent.com/u/1611150?v=3","gravatar_id":"","url":"https://api.github.com/users/Polidea","html_url":"https://github.com/Polidea","followers_url":"https://api.github.com/users/Polidea/followers","following_url":"https://api.github.com/users/Polidea/following{/other_user}","gists_url":"https://api.github.com/users/Polidea/gists{/gist_id}","starred_url":"https://api.github.com/users/Polidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polidea/subscriptions","organizations_url":"https://api.github.com/users/Polidea/orgs","repos_url":"https://api.github.com/users/Polidea/repos","events_url":"https://api.github.com/users/Polidea/events{/privacy}","received_events_url":"https://api.github.com/users/Polidea/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polidea/RxBluetoothKit","description":"iOS Bluetooth library for RxSwift","fork":false,"url":"https://api.github.com/repos/Polidea/RxBluetoothKit","forks_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/forks","keys_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/teams","hooks_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/hooks","issue_events_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/events{/number}","events_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/events","assignees_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/assignees{/user}","branches_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/branches{/branch}","tags_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/tags","blobs_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/statuses/{sha}","languages_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/languages","stargazers_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/stargazers","contributors_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/contributors","subscribers_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/subscribers","subscription_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/subscription","commits_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/contents/{+path}","compare_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/merges","archive_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/downloads","issues_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues{/number}","pulls_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls{/number}","milestones_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/milestones{/number}","notifications_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/labels{/name}","releases_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/releases{/id}","deployments_url":"https://api.github.com/repos/Polidea/RxBluetoothKit/deployments","created_at":"2016-04-08T14:57:55Z","updated_at":"2016-04-15T14:00:03Z","pushed_at":"2016-04-15T14:39:35Z","git_url":"git://github.com/Polidea/RxBluetoothKit.git","ssh_url":"git@github.com:Polidea/RxBluetoothKit.git","clone_url":"https://github.com/Polidea/RxBluetoothKit.git","svn_url":"https://github.com/Polidea/RxBluetoothKit","homepage":"","size":675,"stargazers_count":16,"watchers_count":16,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/9"},"html":{"href":"https://github.com/Polidea/RxBluetoothKit/pull/9"},"issue":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/9"},"comments":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Polidea/RxBluetoothKit/statuses/664426a04eac3159940113e071782250724c798f"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":7,"additions":1118,"deletions":274,"changed_files":42}}