GitHub PullRequestReviewCommentEvent at 2014-11-05 05:15:52
Repository: node-bluetooth-serial-port
Actor: langholz
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/comments/19855729","id":19855729,"diff_hunk":"@@ -294,9 +294,94 @@ Handle<Value> DeviceINQ::ListPairedDevices(const Arguments& args) {\n     }\n     Local<Function> cb = Local<Function>::Cast(args[0]);\n \n-    Local<Array> resultArray = Array::New(0);\n-\n-    // TODO: build an array of objects representing a paired device:\n+   // Construct windows socket bluetooth variables\n+   DWORD flags = LUP_CONTAINERS | LUP_RETURN_NAME | LUP_RETURN_ADDR;\n+   DWORD querySetSize = sizeof(WSAQUERYSET);\n+   WSAQUERYSET *querySet = (WSAQUERYSET *)malloc(querySetSize);\n+   if (querySet == nullptr) {\n+\t   return scope.Close(ThrowException(Exception::Error(String::New(\"Out of memory: Unable to allocate memory resource for inquiry\"))));\n+   }\n+\n+   ZeroMemory(querySet, querySetSize);\n+   querySet->dwSize = querySetSize;\n+   querySet->dwNameSpace = NS_BTH;\n+\n+   std::vector<std::vector<Local<String>>> devices;\n+   std::vector<int> channels;\n+\n+   // Initiate client device inquiry\n+   HANDLE lookupServiceHandle;\n+   int lookupServiceError = WSALookupServiceBegin(querySet, flags, &lookupServiceHandle);\n+   if (lookupServiceError != SOCKET_ERROR) {\n+\t   // Iterate over each found bluetooth service\n+\t   bool inquiryComplete = false;\n+\t   while (!inquiryComplete) {\n+\t\t   // For each bluetooth service retrieve its corresponding details\n+\t\t   lookupServiceError = WSALookupServiceNext(lookupServiceHandle, flags, &querySetSize, querySet);\n+\t\t   if (lookupServiceError != SOCKET_ERROR) {\n+\t\t\t   char address[40] = { 0 };\n+\t\t\t   DWORD addressLength = _countof(address);\n+\t\t\t   SOCKADDR_BTH *bluetoothSocketAddress = (SOCKADDR_BTH *)querySet->lpcsaBuffer->RemoteAddr.lpSockaddr;\n+\t\t\t   BTH_ADDR bluetoothAddress = bluetoothSocketAddress->btAddr;\n+\n+\t\t\t   // Emit the corresponding event if we were able to retrieve the address\n+\t\t\t   int addressToStringError = WSAAddressToString(querySet->lpcsaBuffer->RemoteAddr.lpSockaddr,\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t sizeof(SOCKADDR_BTH),\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t nullptr,\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t address,\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t &addressLength);\n+\t\t\t   if (addressToStringError != SOCKET_ERROR) {\n+\t\t\t\t   // Strip any leading and trailing parentheses is encountered\n+\t\t\t\t   char strippedAddress[19] = { 0 };\n+\t\t\t\t   auto addressString = sscanf_s(address, \"(\" \"%18[^)]\" \")\", strippedAddress) == 1\n+\t\t\t\t\t\t\t\t\t\t? String::New(strippedAddress)\n+\t\t\t\t\t\t\t\t\t\t: String::New(address);\n+\t\t\t\t   std::vector<Local<String>> device;\n+\t\t\t\t   device.push_back(addressString);\n+\t\t\t\t   device.push_back(String::New(querySet->lpszServiceInstanceName));","path":"src/windows/DeviceINQ.cc","position":51,"original_position":51,"commit_id":"3f7f2d93ebe4e82a20207b746d97aa432439b783","original_commit_id":"3f7f2d93ebe4e82a20207b746d97aa432439b783","user":{"login":"langholz","id":365487,"avatar_url":"https://avatars.githubusercontent.com/u/365487?v=2","gravatar_id":"","url":"https://api.github.com/users/langholz","html_url":"https://github.com/langholz","followers_url":"https://api.github.com/users/langholz/followers","following_url":"https://api.github.com/users/langholz/following{/other_user}","gists_url":"https://api.github.com/users/langholz/gists{/gist_id}","starred_url":"https://api.github.com/users/langholz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langholz/subscriptions","organizations_url":"https://api.github.com/users/langholz/orgs","repos_url":"https://api.github.com/users/langholz/repos","events_url":"https://api.github.com/users/langholz/events{/privacy}","received_events_url":"https://api.github.com/users/langholz/received_events","type":"User","site_admin":false},"body":"Under certain circumstances its possible that the device might not have a name available. Consider adding a check for querySet->lpszServiceInstanceName && *(querySet->lpszServiceInstanceName). If not present we should probably default into using the addressString to conform to the [linux](https://github.com/eelcocramer/node-bluetooth-serial-port/blob/master/src/linux/DeviceINQ.cc#L219-L220) and [osx](https://github.com/eelcocramer/node-bluetooth-serial-port/blob/master/src/osx/BluetoothWorker.mm#L383) versions.","created_at":"2014-11-05T05:15:52Z","updated_at":"2014-11-05T05:15:52Z","html_url":"https://github.com/eelcocramer/node-bluetooth-serial-port/pull/43#discussion_r19855729","pull_request_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/comments/19855729"},"html":{"href":"https://github.com/eelcocramer/node-bluetooth-serial-port/pull/43#discussion_r19855729"},"pull_request":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43","id":23707797,"html_url":"https://github.com/eelcocramer/node-bluetooth-serial-port/pull/43","diff_url":"https://github.com/eelcocramer/node-bluetooth-serial-port/pull/43.diff","patch_url":"https://github.com/eelcocramer/node-bluetooth-serial-port/pull/43.patch","issue_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues/43","number":43,"state":"open","locked":false,"title":"Basic ListPairedDevices for Windows","user":{"login":"ELundby45","id":373868,"avatar_url":"https://avatars.githubusercontent.com/u/373868?v=2","gravatar_id":"","url":"https://api.github.com/users/ELundby45","html_url":"https://github.com/ELundby45","followers_url":"https://api.github.com/users/ELundby45/followers","following_url":"https://api.github.com/users/ELundby45/following{/other_user}","gists_url":"https://api.github.com/users/ELundby45/gists{/gist_id}","starred_url":"https://api.github.com/users/ELundby45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ELundby45/subscriptions","organizations_url":"https://api.github.com/users/ELundby45/orgs","repos_url":"https://api.github.com/users/ELundby45/repos","events_url":"https://api.github.com/users/ELundby45/events{/privacy}","received_events_url":"https://api.github.com/users/ELundby45/received_events","type":"User","site_admin":false},"body":"Adds ListPairedDevices for Windows, is virtually instantaneous and\r\ncompared to inquiry.  The code could be greatly improved. The SPP\r\nchannel is currently being hard coded to 1, ideally this would be\r\npopulated using SDP. There is code duplication with Inquiry().","created_at":"2014-10-31T21:41:58Z","updated_at":"2014-11-05T05:15:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d1f46038bd8a8ac7085ce442205a94d43bca5dac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43/commits","review_comments_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43/comments","review_comment_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/comments/{number}","comments_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues/43/comments","statuses_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/statuses/3f7f2d93ebe4e82a20207b746d97aa432439b783","head":{"label":"ELundby45:ListPairedDevices-Windows","ref":"ListPairedDevices-Windows","sha":"3f7f2d93ebe4e82a20207b746d97aa432439b783","user":{"login":"ELundby45","id":373868,"avatar_url":"https://avatars.githubusercontent.com/u/373868?v=2","gravatar_id":"","url":"https://api.github.com/users/ELundby45","html_url":"https://github.com/ELundby45","followers_url":"https://api.github.com/users/ELundby45/followers","following_url":"https://api.github.com/users/ELundby45/following{/other_user}","gists_url":"https://api.github.com/users/ELundby45/gists{/gist_id}","starred_url":"https://api.github.com/users/ELundby45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ELundby45/subscriptions","organizations_url":"https://api.github.com/users/ELundby45/orgs","repos_url":"https://api.github.com/users/ELundby45/repos","events_url":"https://api.github.com/users/ELundby45/events{/privacy}","received_events_url":"https://api.github.com/users/ELundby45/received_events","type":"User","site_admin":false},"repo":{"id":26033890,"name":"node-bluetooth-serial-port","full_name":"ELundby45/node-bluetooth-serial-port","owner":{"login":"ELundby45","id":373868,"avatar_url":"https://avatars.githubusercontent.com/u/373868?v=2","gravatar_id":"","url":"https://api.github.com/users/ELundby45","html_url":"https://github.com/ELundby45","followers_url":"https://api.github.com/users/ELundby45/followers","following_url":"https://api.github.com/users/ELundby45/following{/other_user}","gists_url":"https://api.github.com/users/ELundby45/gists{/gist_id}","starred_url":"https://api.github.com/users/ELundby45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ELundby45/subscriptions","organizations_url":"https://api.github.com/users/ELundby45/orgs","repos_url":"https://api.github.com/users/ELundby45/repos","events_url":"https://api.github.com/users/ELundby45/events{/privacy}","received_events_url":"https://api.github.com/users/ELundby45/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ELundby45/node-bluetooth-serial-port","description":"Serial I/O using node and bluetooth","fork":true,"url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port","forks_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/forks","keys_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/teams","hooks_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/hooks","issue_events_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/issues/events{/number}","events_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/events","assignees_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/assignees{/user}","branches_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/branches{/branch}","tags_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/tags","blobs_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/git/refs{/sha}","trees_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/statuses/{sha}","languages_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/languages","stargazers_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/stargazers","contributors_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/contributors","subscribers_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/subscribers","subscription_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/subscription","commits_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/commits{/sha}","git_commits_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/git/commits{/sha}","comments_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/comments{/number}","issue_comment_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/issues/comments/{number}","contents_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/contents/{+path}","compare_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/merges","archive_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/downloads","issues_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/issues{/number}","pulls_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/pulls{/number}","milestones_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/milestones{/number}","notifications_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/labels{/name}","releases_url":"https://api.github.com/repos/ELundby45/node-bluetooth-serial-port/releases{/id}","created_at":"2014-10-31T21:36:05Z","updated_at":"2014-10-08T01:41:39Z","pushed_at":"2014-10-31T21:41:28Z","git_url":"git://github.com/ELundby45/node-bluetooth-serial-port.git","ssh_url":"git@github.com:ELundby45/node-bluetooth-serial-port.git","clone_url":"https://github.com/ELundby45/node-bluetooth-serial-port.git","svn_url":"https://github.com/ELundby45/node-bluetooth-serial-port","homepage":null,"size":294,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eelcocramer:master","ref":"master","sha":"857ddb62d448756213c5ce5e08de5064594603cc","user":{"login":"eelcocramer","id":795579,"avatar_url":"https://avatars.githubusercontent.com/u/795579?v=2","gravatar_id":"","url":"https://api.github.com/users/eelcocramer","html_url":"https://github.com/eelcocramer","followers_url":"https://api.github.com/users/eelcocramer/followers","following_url":"https://api.github.com/users/eelcocramer/following{/other_user}","gists_url":"https://api.github.com/users/eelcocramer/gists{/gist_id}","starred_url":"https://api.github.com/users/eelcocramer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eelcocramer/subscriptions","organizations_url":"https://api.github.com/users/eelcocramer/orgs","repos_url":"https://api.github.com/users/eelcocramer/repos","events_url":"https://api.github.com/users/eelcocramer/events{/privacy}","received_events_url":"https://api.github.com/users/eelcocramer/received_events","type":"User","site_admin":false},"repo":{"id":6353054,"name":"node-bluetooth-serial-port","full_name":"eelcocramer/node-bluetooth-serial-port","owner":{"login":"eelcocramer","id":795579,"avatar_url":"https://avatars.githubusercontent.com/u/795579?v=2","gravatar_id":"","url":"https://api.github.com/users/eelcocramer","html_url":"https://github.com/eelcocramer","followers_url":"https://api.github.com/users/eelcocramer/followers","following_url":"https://api.github.com/users/eelcocramer/following{/other_user}","gists_url":"https://api.github.com/users/eelcocramer/gists{/gist_id}","starred_url":"https://api.github.com/users/eelcocramer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eelcocramer/subscriptions","organizations_url":"https://api.github.com/users/eelcocramer/orgs","repos_url":"https://api.github.com/users/eelcocramer/repos","events_url":"https://api.github.com/users/eelcocramer/events{/privacy}","received_events_url":"https://api.github.com/users/eelcocramer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eelcocramer/node-bluetooth-serial-port","description":"Serial I/O using node and bluetooth","fork":false,"url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port","forks_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/forks","keys_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/teams","hooks_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/hooks","issue_events_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues/events{/number}","events_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/events","assignees_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/assignees{/user}","branches_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/branches{/branch}","tags_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/tags","blobs_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/git/refs{/sha}","trees_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/statuses/{sha}","languages_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/languages","stargazers_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/stargazers","contributors_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/contributors","subscribers_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/subscribers","subscription_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/subscription","commits_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/commits{/sha}","git_commits_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/git/commits{/sha}","comments_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/comments{/number}","issue_comment_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues/comments/{number}","contents_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/contents/{+path}","compare_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/merges","archive_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/downloads","issues_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues{/number}","pulls_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls{/number}","milestones_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/milestones{/number}","notifications_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/labels{/name}","releases_url":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/releases{/id}","created_at":"2012-10-23T13:49:56Z","updated_at":"2014-11-03T06:01:26Z","pushed_at":"2014-08-18T17:22:34Z","git_url":"git://github.com/eelcocramer/node-bluetooth-serial-port.git","ssh_url":"git@github.com:eelcocramer/node-bluetooth-serial-port.git","clone_url":"https://github.com/eelcocramer/node-bluetooth-serial-port.git","svn_url":"https://github.com/eelcocramer/node-bluetooth-serial-port","homepage":null,"size":817,"stargazers_count":93,"watchers_count":93,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":8,"forks":25,"open_issues":8,"watchers":93,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43"},"html":{"href":"https://github.com/eelcocramer/node-bluetooth-serial-port/pull/43"},"issue":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues/43"},"comments":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/eelcocramer/node-bluetooth-serial-port/statuses/3f7f2d93ebe4e82a20207b746d97aa432439b783"}}}}