{"action":"created","comment":{"url":"https://api.github.com/repos/ellsclytn/Ringo/pulls/comments/79529823","id":79529823,"diff_hunk":"@@ -1,24 +1,112 @@\n-const short LED_COUNT = 2;\n-const short LEDS[LED_COUNT] = {2, 3};\n+#include <ESP8266WiFi.h>\n+#include <PubSubClient.h>\n+#include \"env.h\"\n \n-void setup() {\n-  for (short i = 0; i < LED_COUNT; i++) {\n-    pinMode(LEDS[i], OUTPUT);\n+WiFiClient espClient;\n+PubSubClient client(espClient);\n+\n+byte leds[] = {12, 13};\n+short blinkDelay = 500;\n+long ledSwitchTime = 0;\n+bool prOpen = false;\n+bool led1On = false;\n+\n+void setup_wifi() {\n+  Serial.println();\n+  Serial.print(\"Connecting to \");\n+  Serial.println(SSID);\n+\n+  WiFi.begin(SSID, WIFI_PASS);\n+\n+  while (WiFi.status() != WL_CONNECTED) {\n+    delay(500);\n+    Serial.print(\".\");\n   }\n+\n+  randomSeed(micros());\n+\n+  Serial.println();\n+  Serial.println(\"WiFi connected\");\n+  Serial.print(\"IP address: \");\n+  Serial.println(WiFi.localIP());\n }\n \n-void loop() {\n-  delay(random(0, 300) * 1000);\n-  blinkLoop(902.255638);\n+void callback(char* topic, byte* payload, unsigned int length) {\n+  Serial.print(\"Message arrived [\");\n+  Serial.print(topic);\n+  Serial.print(\"] \");\n+  for (int i = 0; i < length; i++) {\n+    Serial.print((char)payload[i]);\n+  }\n+  Serial.println();\n+\n+  if ((char)payload[0] == '1') {\n+    prOpen = true;\n+  }\n+}\n+\n+void reconnect() {\n+  while (!client.connected()) {\n+    Serial.print(\"Attempting MQTT connection...\");\n+    String clientId = \"ESP8266Client-\";","path":"src/ringo.ino","position":59,"original_position":59,"commit_id":"a3c8eca1c1238f1a76fa5bc97dbe1d122d3148b8","original_commit_id":"a3c8eca1c1238f1a76fa5bc97dbe1d122d3148b8","user":{"login":"aabrook","id":12283603,"avatar_url":"https://avatars.githubusercontent.com/u/12283603?v=3","gravatar_id":"","url":"https://api.github.com/users/aabrook","html_url":"https://github.com/aabrook","followers_url":"https://api.github.com/users/aabrook/followers","following_url":"https://api.github.com/users/aabrook/following{/other_user}","gists_url":"https://api.github.com/users/aabrook/gists{/gist_id}","starred_url":"https://api.github.com/users/aabrook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aabrook/subscriptions","organizations_url":"https://api.github.com/users/aabrook/orgs","repos_url":"https://api.github.com/users/aabrook/repos","events_url":"https://api.github.com/users/aabrook/events{/privacy}","received_events_url":"https://api.github.com/users/aabrook/received_events","type":"User","site_admin":false},"body":"You're not using ESP8266 right?","created_at":"2016-09-20T03:11:40Z","updated_at":"2016-09-20T03:11:40Z","html_url":"https://github.com/ellsclytn/Ringo/pull/1#discussion_r79529823","pull_request_url":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ellsclytn/Ringo/pulls/comments/79529823"},"html":{"href":"https://github.com/ellsclytn/Ringo/pull/1#discussion_r79529823"},"pull_request":{"href":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1","id":85903890,"html_url":"https://github.com/ellsclytn/Ringo/pull/1","diff_url":"https://github.com/ellsclytn/Ringo/pull/1.diff","patch_url":"https://github.com/ellsclytn/Ringo/pull/1.patch","issue_url":"https://api.github.com/repos/ellsclytn/Ringo/issues/1","number":1,"state":"open","locked":false,"title":"MQTT Subscription","user":{"login":"ellsclytn","id":8725013,"avatar_url":"https://avatars.githubusercontent.com/u/8725013?v=3","gravatar_id":"","url":"https://api.github.com/users/ellsclytn","html_url":"https://github.com/ellsclytn","followers_url":"https://api.github.com/users/ellsclytn/followers","following_url":"https://api.github.com/users/ellsclytn/following{/other_user}","gists_url":"https://api.github.com/users/ellsclytn/gists{/gist_id}","starred_url":"https://api.github.com/users/ellsclytn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellsclytn/subscriptions","organizations_url":"https://api.github.com/users/ellsclytn/orgs","repos_url":"https://api.github.com/users/ellsclytn/repos","events_url":"https://api.github.com/users/ellsclytn/events{/privacy}","received_events_url":"https://api.github.com/users/ellsclytn/received_events","type":"User","site_admin":false},"body":"- Use PubSubClient to subscribe to MQTT\r\n- Listen for a `pr` message with content `1` in order to blink lights\r\n- Allow light blinking to be dismissed with button press","created_at":"2016-09-20T03:06:04Z","updated_at":"2016-09-20T03:26:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1104951de3e1a0fbf676cef21a8829444b9e95ac","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ellsclytn/Ringo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ellsclytn/Ringo/issues/1/comments","statuses_url":"https://api.github.com/repos/ellsclytn/Ringo/statuses/a3c8eca1c1238f1a76fa5bc97dbe1d122d3148b8","head":{"label":"ellsclytn:dev","ref":"dev","sha":"a3c8eca1c1238f1a76fa5bc97dbe1d122d3148b8","user":{"login":"ellsclytn","id":8725013,"avatar_url":"https://avatars.githubusercontent.com/u/8725013?v=3","gravatar_id":"","url":"https://api.github.com/users/ellsclytn","html_url":"https://github.com/ellsclytn","followers_url":"https://api.github.com/users/ellsclytn/followers","following_url":"https://api.github.com/users/ellsclytn/following{/other_user}","gists_url":"https://api.github.com/users/ellsclytn/gists{/gist_id}","starred_url":"https://api.github.com/users/ellsclytn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellsclytn/subscriptions","organizations_url":"https://api.github.com/users/ellsclytn/orgs","repos_url":"https://api.github.com/users/ellsclytn/repos","events_url":"https://api.github.com/users/ellsclytn/events{/privacy}","received_events_url":"https://api.github.com/users/ellsclytn/received_events","type":"User","site_admin":false},"repo":{"id":56760113,"name":"Ringo","full_name":"ellsclytn/Ringo","owner":{"login":"ellsclytn","id":8725013,"avatar_url":"https://avatars.githubusercontent.com/u/8725013?v=3","gravatar_id":"","url":"https://api.github.com/users/ellsclytn","html_url":"https://github.com/ellsclytn","followers_url":"https://api.github.com/users/ellsclytn/followers","following_url":"https://api.github.com/users/ellsclytn/following{/other_user}","gists_url":"https://api.github.com/users/ellsclytn/gists{/gist_id}","starred_url":"https://api.github.com/users/ellsclytn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellsclytn/subscriptions","organizations_url":"https://api.github.com/users/ellsclytn/orgs","repos_url":"https://api.github.com/users/ellsclytn/repos","events_url":"https://api.github.com/users/ellsclytn/events{/privacy}","received_events_url":"https://api.github.com/users/ellsclytn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ellsclytn/Ringo","description":"Because it's important to make sure your octopus can blink his lights","fork":false,"url":"https://api.github.com/repos/ellsclytn/Ringo","forks_url":"https://api.github.com/repos/ellsclytn/Ringo/forks","keys_url":"https://api.github.com/repos/ellsclytn/Ringo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ellsclytn/Ringo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ellsclytn/Ringo/teams","hooks_url":"https://api.github.com/repos/ellsclytn/Ringo/hooks","issue_events_url":"https://api.github.com/repos/ellsclytn/Ringo/issues/events{/number}","events_url":"https://api.github.com/repos/ellsclytn/Ringo/events","assignees_url":"https://api.github.com/repos/ellsclytn/Ringo/assignees{/user}","branches_url":"https://api.github.com/repos/ellsclytn/Ringo/branches{/branch}","tags_url":"https://api.github.com/repos/ellsclytn/Ringo/tags","blobs_url":"https://api.github.com/repos/ellsclytn/Ringo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ellsclytn/Ringo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ellsclytn/Ringo/git/refs{/sha}","trees_url":"https://api.github.com/repos/ellsclytn/Ringo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ellsclytn/Ringo/statuses/{sha}","languages_url":"https://api.github.com/repos/ellsclytn/Ringo/languages","stargazers_url":"https://api.github.com/repos/ellsclytn/Ringo/stargazers","contributors_url":"https://api.github.com/repos/ellsclytn/Ringo/contributors","subscribers_url":"https://api.github.com/repos/ellsclytn/Ringo/subscribers","subscription_url":"https://api.github.com/repos/ellsclytn/Ringo/subscription","commits_url":"https://api.github.com/repos/ellsclytn/Ringo/commits{/sha}","git_commits_url":"https://api.github.com/repos/ellsclytn/Ringo/git/commits{/sha}","comments_url":"https://api.github.com/repos/ellsclytn/Ringo/comments{/number}","issue_comment_url":"https://api.github.com/repos/ellsclytn/Ringo/issues/comments{/number}","contents_url":"https://api.github.com/repos/ellsclytn/Ringo/contents/{+path}","compare_url":"https://api.github.com/repos/ellsclytn/Ringo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ellsclytn/Ringo/merges","archive_url":"https://api.github.com/repos/ellsclytn/Ringo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ellsclytn/Ringo/downloads","issues_url":"https://api.github.com/repos/ellsclytn/Ringo/issues{/number}","pulls_url":"https://api.github.com/repos/ellsclytn/Ringo/pulls{/number}","milestones_url":"https://api.github.com/repos/ellsclytn/Ringo/milestones{/number}","notifications_url":"https://api.github.com/repos/ellsclytn/Ringo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ellsclytn/Ringo/labels{/name}","releases_url":"https://api.github.com/repos/ellsclytn/Ringo/releases{/id}","deployments_url":"https://api.github.com/repos/ellsclytn/Ringo/deployments","created_at":"2016-04-21T09:18:56Z","updated_at":"2016-04-21T09:21:31Z","pushed_at":"2016-09-20T03:06:05Z","git_url":"git://github.com/ellsclytn/Ringo.git","ssh_url":"git@github.com:ellsclytn/Ringo.git","clone_url":"https://github.com/ellsclytn/Ringo.git","svn_url":"https://github.com/ellsclytn/Ringo","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":"Arduino","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ellsclytn:master","ref":"master","sha":"7887e9c360f2cf03a40583cd5ca6ef8437e6786d","user":{"login":"ellsclytn","id":8725013,"avatar_url":"https://avatars.githubusercontent.com/u/8725013?v=3","gravatar_id":"","url":"https://api.github.com/users/ellsclytn","html_url":"https://github.com/ellsclytn","followers_url":"https://api.github.com/users/ellsclytn/followers","following_url":"https://api.github.com/users/ellsclytn/following{/other_user}","gists_url":"https://api.github.com/users/ellsclytn/gists{/gist_id}","starred_url":"https://api.github.com/users/ellsclytn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellsclytn/subscriptions","organizations_url":"https://api.github.com/users/ellsclytn/orgs","repos_url":"https://api.github.com/users/ellsclytn/repos","events_url":"https://api.github.com/users/ellsclytn/events{/privacy}","received_events_url":"https://api.github.com/users/ellsclytn/received_events","type":"User","site_admin":false},"repo":{"id":56760113,"name":"Ringo","full_name":"ellsclytn/Ringo","owner":{"login":"ellsclytn","id":8725013,"avatar_url":"https://avatars.githubusercontent.com/u/8725013?v=3","gravatar_id":"","url":"https://api.github.com/users/ellsclytn","html_url":"https://github.com/ellsclytn","followers_url":"https://api.github.com/users/ellsclytn/followers","following_url":"https://api.github.com/users/ellsclytn/following{/other_user}","gists_url":"https://api.github.com/users/ellsclytn/gists{/gist_id}","starred_url":"https://api.github.com/users/ellsclytn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellsclytn/subscriptions","organizations_url":"https://api.github.com/users/ellsclytn/orgs","repos_url":"https://api.github.com/users/ellsclytn/repos","events_url":"https://api.github.com/users/ellsclytn/events{/privacy}","received_events_url":"https://api.github.com/users/ellsclytn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ellsclytn/Ringo","description":"Because it's important to make sure your octopus can blink his lights","fork":false,"url":"https://api.github.com/repos/ellsclytn/Ringo","forks_url":"https://api.github.com/repos/ellsclytn/Ringo/forks","keys_url":"https://api.github.com/repos/ellsclytn/Ringo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ellsclytn/Ringo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ellsclytn/Ringo/teams","hooks_url":"https://api.github.com/repos/ellsclytn/Ringo/hooks","issue_events_url":"https://api.github.com/repos/ellsclytn/Ringo/issues/events{/number}","events_url":"https://api.github.com/repos/ellsclytn/Ringo/events","assignees_url":"https://api.github.com/repos/ellsclytn/Ringo/assignees{/user}","branches_url":"https://api.github.com/repos/ellsclytn/Ringo/branches{/branch}","tags_url":"https://api.github.com/repos/ellsclytn/Ringo/tags","blobs_url":"https://api.github.com/repos/ellsclytn/Ringo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ellsclytn/Ringo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ellsclytn/Ringo/git/refs{/sha}","trees_url":"https://api.github.com/repos/ellsclytn/Ringo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ellsclytn/Ringo/statuses/{sha}","languages_url":"https://api.github.com/repos/ellsclytn/Ringo/languages","stargazers_url":"https://api.github.com/repos/ellsclytn/Ringo/stargazers","contributors_url":"https://api.github.com/repos/ellsclytn/Ringo/contributors","subscribers_url":"https://api.github.com/repos/ellsclytn/Ringo/subscribers","subscription_url":"https://api.github.com/repos/ellsclytn/Ringo/subscription","commits_url":"https://api.github.com/repos/ellsclytn/Ringo/commits{/sha}","git_commits_url":"https://api.github.com/repos/ellsclytn/Ringo/git/commits{/sha}","comments_url":"https://api.github.com/repos/ellsclytn/Ringo/comments{/number}","issue_comment_url":"https://api.github.com/repos/ellsclytn/Ringo/issues/comments{/number}","contents_url":"https://api.github.com/repos/ellsclytn/Ringo/contents/{+path}","compare_url":"https://api.github.com/repos/ellsclytn/Ringo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ellsclytn/Ringo/merges","archive_url":"https://api.github.com/repos/ellsclytn/Ringo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ellsclytn/Ringo/downloads","issues_url":"https://api.github.com/repos/ellsclytn/Ringo/issues{/number}","pulls_url":"https://api.github.com/repos/ellsclytn/Ringo/pulls{/number}","milestones_url":"https://api.github.com/repos/ellsclytn/Ringo/milestones{/number}","notifications_url":"https://api.github.com/repos/ellsclytn/Ringo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ellsclytn/Ringo/labels{/name}","releases_url":"https://api.github.com/repos/ellsclytn/Ringo/releases{/id}","deployments_url":"https://api.github.com/repos/ellsclytn/Ringo/deployments","created_at":"2016-04-21T09:18:56Z","updated_at":"2016-04-21T09:21:31Z","pushed_at":"2016-09-20T03:06:05Z","git_url":"git://github.com/ellsclytn/Ringo.git","ssh_url":"git@github.com:ellsclytn/Ringo.git","clone_url":"https://github.com/ellsclytn/Ringo.git","svn_url":"https://github.com/ellsclytn/Ringo","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":"Arduino","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1"},"html":{"href":"https://github.com/ellsclytn/Ringo/pull/1"},"issue":{"href":"https://api.github.com/repos/ellsclytn/Ringo/issues/1"},"comments":{"href":"https://api.github.com/repos/ellsclytn/Ringo/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ellsclytn/Ringo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ellsclytn/Ringo/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ellsclytn/Ringo/statuses/a3c8eca1c1238f1a76fa5bc97dbe1d122d3148b8"}}}}
{"actor":{"display_login":"aabrook"}}