{"action":"created","issue":{"url":"https://api.github.com/repos/orbotix/sphero.js/issues/40","labels_url":"https://api.github.com/repos/orbotix/sphero.js/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/orbotix/sphero.js/issues/40/comments","events_url":"https://api.github.com/repos/orbotix/sphero.js/issues/40/events","html_url":"https://github.com/orbotix/sphero.js/issues/40","id":124268407,"number":40,"title":"Impossible to connect when 'connect ' is embedded into a function","user":{"login":"JBX028","id":88729,"avatar_url":"https://avatars.githubusercontent.com/u/88729?v=3","gravatar_id":"","url":"https://api.github.com/users/JBX028","html_url":"https://github.com/JBX028","followers_url":"https://api.github.com/users/JBX028/followers","following_url":"https://api.github.com/users/JBX028/following{/other_user}","gists_url":"https://api.github.com/users/JBX028/gists{/gist_id}","starred_url":"https://api.github.com/users/JBX028/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JBX028/subscriptions","organizations_url":"https://api.github.com/users/JBX028/orgs","repos_url":"https://api.github.com/users/JBX028/repos","events_url":"https://api.github.com/users/JBX028/events{/privacy}","received_events_url":"https://api.github.com/users/JBX028/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-29T21:09:01Z","updated_at":"2016-01-01T18:55:48Z","closed_at":null,"body":"Hi,\r\n\r\nI would like to expose most of the commands (color, roll, etc, ....) as web services in order to control my device across various channels (ifttt, cortana, node-red, etc...)\r\nTherefore, I have installed \"restify\" but bb8.connect is not fired when the command is embedded into a function. Below a simplified version of the source code to keep the most important elements:\r\n\r\n```javascript\r\nvar sphero = require(\"sphero\");\r\nvar bb8 = sphero(\"xxxx\");\r\n\r\nvar restify = require(\"restify\");\r\n\r\nvar server = restify.createServer({\r\n  name: \"bb8-rest-api\",\r\n  version: \"1.0.0\"\r\n});\r\n\r\nfunction bb8_SetColor(req, res, next) {\r\n  bb8.connect(function() {\r\n    console.log(\"connected\");\r\n    bb8.color(req.params.color);\r\n  }\r\n  res.send(200);\r\n  return next();\r\n});\r\n\r\nserver.get(\"/color/:color\", bb8_SetColor);\r\n\r\nserver.listen(\"8081\", function() {});\r\n```\r\n\r\nI have of course added several console.log and up to bb8.connect, the code is well executed and then nothing else happen after while the same code outside the function works fine.\r\n\r\nAny ideas why the command is not recognised?\r\n\r\nThanks for any help you will provide"},"comment":{"url":"https://api.github.com/repos/orbotix/sphero.js/issues/comments/168332104","html_url":"https://github.com/orbotix/sphero.js/issues/40#issuecomment-168332104","issue_url":"https://api.github.com/repos/orbotix/sphero.js/issues/40","id":168332104,"user":{"login":"dimorphic","id":3442665,"avatar_url":"https://avatars.githubusercontent.com/u/3442665?v=3","gravatar_id":"","url":"https://api.github.com/users/dimorphic","html_url":"https://github.com/dimorphic","followers_url":"https://api.github.com/users/dimorphic/followers","following_url":"https://api.github.com/users/dimorphic/following{/other_user}","gists_url":"https://api.github.com/users/dimorphic/gists{/gist_id}","starred_url":"https://api.github.com/users/dimorphic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimorphic/subscriptions","organizations_url":"https://api.github.com/users/dimorphic/orgs","repos_url":"https://api.github.com/users/dimorphic/repos","events_url":"https://api.github.com/users/dimorphic/events{/privacy}","received_events_url":"https://api.github.com/users/dimorphic/received_events","type":"User","site_admin":false},"created_at":"2016-01-01T18:55:48Z","updated_at":"2016-01-01T18:55:48Z","body":"Nevermind what i just said. I have the same problem.\r\nTrying to trigger a sphero.connect() in another function and fails silently. :<"}}