{"action":"created","issue":{"url":"https://api.github.com/repos/pebble/pebblejs/issues/134","labels_url":"https://api.github.com/repos/pebble/pebblejs/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/pebble/pebblejs/issues/134/comments","events_url":"https://api.github.com/repos/pebble/pebblejs/issues/134/events","html_url":"https://github.com/pebble/pebblejs/pull/134","id":130033641,"number":134,"title":"incomplete attempt to add the ability to send appmessage from a companion app","user":{"login":"jscottnz","id":6979887,"avatar_url":"https://avatars.githubusercontent.com/u/6979887?v=3","gravatar_id":"","url":"https://api.github.com/users/jscottnz","html_url":"https://github.com/jscottnz","followers_url":"https://api.github.com/users/jscottnz/followers","following_url":"https://api.github.com/users/jscottnz/following{/other_user}","gists_url":"https://api.github.com/users/jscottnz/gists{/gist_id}","starred_url":"https://api.github.com/users/jscottnz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jscottnz/subscriptions","organizations_url":"https://api.github.com/users/jscottnz/orgs","repos_url":"https://api.github.com/users/jscottnz/repos","events_url":"https://api.github.com/users/jscottnz/events{/privacy}","received_events_url":"https://api.github.com/users/jscottnz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-30T20:39:19Z","updated_at":"2016-01-31T03:05:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pebble/pebblejs/pulls/134","html_url":"https://github.com/pebble/pebblejs/pull/134","diff_url":"https://github.com/pebble/pebblejs/pull/134.diff","patch_url":"https://github.com/pebble/pebblejs/pull/134.patch"},"body":"So my idea was to create a cordova app that could communicate with a pebblejs app. Javascript phone App -> Javascript pebble App !!!\r\n\r\nUsing https://github.com/jbeuckm/cordova-plugin-pebble I was hoping that it would be possible to send a message to the pebble from the companion app.\r\n\r\nI tried straight out of the box and realized that I would need to get the pebble app to listen for a particular message.\r\n\r\nSo, here is a start...\r\nI'm a complete noob to PebbleC (and C) and based my code off: pebble/pebblejs@f06b0c1\r\n\r\nI'd like some advise as to if this is even possible, and if I'm going in the right direction!\r\n\r\nI think I've set up the C part to receive the message, but then I think I need to push it down to the javascript part.\r\nI'm also concerned about large messages... does this all play well together - I suspect not.\r\n\r\nAnyway, I'm happy to work on this but right now I'm going to need some advice."},"comment":{"url":"https://api.github.com/repos/pebble/pebblejs/issues/comments/177367629","html_url":"https://github.com/pebble/pebblejs/pull/134#issuecomment-177367629","issue_url":"https://api.github.com/repos/pebble/pebblejs/issues/134","id":177367629,"user":{"login":"Meiguro","id":4428900,"avatar_url":"https://avatars.githubusercontent.com/u/4428900?v=3","gravatar_id":"","url":"https://api.github.com/users/Meiguro","html_url":"https://github.com/Meiguro","followers_url":"https://api.github.com/users/Meiguro/followers","following_url":"https://api.github.com/users/Meiguro/following{/other_user}","gists_url":"https://api.github.com/users/Meiguro/gists{/gist_id}","starred_url":"https://api.github.com/users/Meiguro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Meiguro/subscriptions","organizations_url":"https://api.github.com/users/Meiguro/orgs","repos_url":"https://api.github.com/users/Meiguro/repos","events_url":"https://api.github.com/users/Meiguro/events{/privacy}","received_events_url":"https://api.github.com/users/Meiguro/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T03:05:47Z","updated_at":"2016-01-31T03:05:47Z","body":"Okay, I understand what setup you're trying to get working now.\r\n\r\n> I think when the cordova app connected, the pebble app on the phone lost the connection...\r\nand because of that the javascript part of the watch app couldn't execute\r\n\r\nAh, yes, this seems to be the limitation of only a Companion App or the Pebble Phone JavaScript being able to communicate at any one time.\r\n\r\nTo work around this limitation, you can run your entire pebble.js project in the Cordova JavaScript side. Building upon my earlier post, it would look something like this:\r\n\r\n> Cordova Companion App <=> pebble.js JavaScript app <=> cordova-plugin-pebble <=> C Watch App\r\n\r\nIn terms of how you would do this, you would have your Cordova app with the plugin loaded first, then you would load your pebble.js app. Your entire pebble.js JavaScript source, when built by `pebble build` is in `build/src/pebble-js-app.js` (funny name, I know). You can run that script after cordova-plugin-pebble is loaded, but not without a few changes.\r\n\r\nYou will have to run `build/src/pebble-js-app.js` in a context where `window.plugins.Pebble` is bound to `Pebble`. In JS terms, this means:\r\n```\r\n({function() {\r\n  var Pebble = window.plugins.Pebble;\r\n  ... // your pebble.js app code\r\n})();\r\n```\r\nOr more simply `window.Pebble = window.plugins.Pebble` if you don't mind leaking a global.\r\n\r\nThere will still be other problems, and this will be the bulk of the work; it seems the API is different from that of PebbleKit JavaScript. You will need to change the functions in cordova-plugin-pebble to mirror that of PebbleKit JavaScript, the critical ones being the App Message functions."}}