{"action":"created","issue":{"url":"https://api.github.com/repos/hansemannn/titanium-bluetooth/issues/29","repository_url":"https://api.github.com/repos/hansemannn/titanium-bluetooth","labels_url":"https://api.github.com/repos/hansemannn/titanium-bluetooth/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/hansemannn/titanium-bluetooth/issues/29/comments","events_url":"https://api.github.com/repos/hansemannn/titanium-bluetooth/issues/29/events","html_url":"https://github.com/hansemannn/titanium-bluetooth/issues/29","id":259130814,"number":29,"title":"Subscribing to characteristics","user":{"login":"FizixRichard","id":6486268,"avatar_url":"https://avatars0.githubusercontent.com/u/6486268?v=4","gravatar_id":"","url":"https://api.github.com/users/FizixRichard","html_url":"https://github.com/FizixRichard","followers_url":"https://api.github.com/users/FizixRichard/followers","following_url":"https://api.github.com/users/FizixRichard/following{/other_user}","gists_url":"https://api.github.com/users/FizixRichard/gists{/gist_id}","starred_url":"https://api.github.com/users/FizixRichard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FizixRichard/subscriptions","organizations_url":"https://api.github.com/users/FizixRichard/orgs","repos_url":"https://api.github.com/users/FizixRichard/repos","events_url":"https://api.github.com/users/FizixRichard/events{/privacy}","received_events_url":"https://api.github.com/users/FizixRichard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":47,"created_at":"2017-09-20T11:31:05Z","updated_at":"2017-09-25T14:43:57Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI'm having trouble subscribing to characteristics and the documentation doesn't explain how. Following the XCode Core Bluetooth documentation isn't helping.\r\n\r\nI am trying to subscribe to a couple of services on a BT device, battery and immediate alert.\r\n\r\nI'm successfully scanning for devices, finding the device, getting its data, listing services and getting the characteristics. \r\n\r\nWhat I need to do from here is to subscribe to the characteristics I need and receive callbacks whenever the battery level changes or the alert level changes on the BT device. I've tried a number of approaches but none seem to be working.\r\n\r\nCode up to subscription below:\r\n\r\n\r\n// -----------------------------------------------------------------------------\r\n// Peripheral Connect Callback\r\n// -----------------------------------------------------------------------------\r\ncentralManager.addEventListener('didConnectPeripheral', function(e) \r\n{\r\n    Ti.API.info('Connected to Periperal...');\r\n    \r\n    connectedPeripheral = e.peripheral;\r\n    \r\n    \r\n    connectedPeripheral.addEventListener('didUpdateValueForCharacteristic', function(e) {\r\n        Ti.API.info('didUpdateValueForCharacteristic');\r\n        Ti.API.info(e);\r\n\t});\r\n\r\n\r\n    connectedPeripheral.addEventListener('didDiscoverServices', function(e) \r\n    {\r\n    \tTi.API.info('Service Discovery...');\r\n    \t\r\n    \tp = e.peripheral;\r\n\r\n\t\tTi.API.info('peripheral has', p.services.length, 'service(s)');\t\r\n\t\t\r\n\t\tp.services.forEach(function(service) \r\n\t\t{\r\n\t\t\tTi.API.info('service: ', service.uuid);\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t// Assign battery service\r\n\t\t\tif(service.uuid == gattBattery)\r\n\t\t\t{\r\n\t\t\t\tTi.API.info(\"BatteryService Found\");\r\n\t\t\t\tserviceBattery = service;\r\n\t\t\t\r\n\t\t\t\tp.addEventListener('didDiscoverCharacteristicsForService', function(e) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar characteristics = e.service.characteristics;\r\n\t\t\t\t\t\r\n\t\t\t\t\tcharacteristics.forEach(function(characteristic) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTi.API.info('Characteristic ID:', characteristic.uuid);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// Want to subscribe to this characteristic and receive value changes from peripheral\r\n\t\t\t\t\t\tif(characteristic.uuid == '2A19')\r\n\t\t\t\t\t\t{\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t});\t\r\n\t\t\t\t\r\n\t\t\t\tp.discoverCharacteristicsForService({\r\n\t\t\t\t\tcharacteristics : [],\r\n\t\t\t\t\tservice : service\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n    });\r\n    \r\n    \r\n    // Discover services\r\n    connectedPeripheral.discoverServices();\r\n});\r\n"},"comment":{"url":"https://api.github.com/repos/hansemannn/titanium-bluetooth/issues/comments/331903923","html_url":"https://github.com/hansemannn/titanium-bluetooth/issues/29#issuecomment-331903923","issue_url":"https://api.github.com/repos/hansemannn/titanium-bluetooth/issues/29","id":331903923,"user":{"login":"FizixRichard","id":6486268,"avatar_url":"https://avatars0.githubusercontent.com/u/6486268?v=4","gravatar_id":"","url":"https://api.github.com/users/FizixRichard","html_url":"https://github.com/FizixRichard","followers_url":"https://api.github.com/users/FizixRichard/followers","following_url":"https://api.github.com/users/FizixRichard/following{/other_user}","gists_url":"https://api.github.com/users/FizixRichard/gists{/gist_id}","starred_url":"https://api.github.com/users/FizixRichard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FizixRichard/subscriptions","organizations_url":"https://api.github.com/users/FizixRichard/orgs","repos_url":"https://api.github.com/users/FizixRichard/repos","events_url":"https://api.github.com/users/FizixRichard/events{/privacy}","received_events_url":"https://api.github.com/users/FizixRichard/received_events","type":"User","site_admin":false},"created_at":"2017-09-25T14:43:57Z","updated_at":"2017-09-25T14:43:57Z","author_association":"NONE","body":"It's ok, I'll figure it out. It should be a string (battery level) or int (alert level)"}}
{"actor":{"display_login":"FizixRichard"}}