{"action":"created","comment":{"url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/comments/72916299","id":72916299,"diff_hunk":"@@ -0,0 +1,161 @@\n+/*\n+  Copyright (c) 2016 Intel Corporation. All rights reserved.\n+\n+  This library is free software; you can redistribute it and/or\n+  modify it under the terms of the GNU Lesser General Public\n+  License as published by the Free Software Foundation; either\n+  version 2.1 of the License, or (at your option) any later version.\n+\n+  This library is distributed in the hope that it will be useful,\n+  but WITHOUT ANY WARRANTY; without even the implied warranty of\n+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+  Lesser General Public License for more details.\n+\n+  You should have received a copy of the GNU Lesser General Public\n+  License along with this library; if not, write to the Free Software\n+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-\n+  1301 USA\n+*/\n+\n+// This example can work with CallbackLED to show the profile read/write operation in central\n+#include <CurieBLE.h>\n+\n+struct bt_le_conn_param conn_param = {0x18, 0x28, 0, 400};\n+\n+const int ledPin = 13; // set ledPin to use on-board LED\n+BLECentral bleCentral; // create central instance\n+BLEPeripheralHelper *blePeripheral1 = NULL;\n+\n+BLEService ledService(\"19B10000-E8F2-537E-4F6C-D104768A1214\"); // create service\n+// create switch characteristic and allow remote device to read and write\n+BLECharCharacteristic switchChar(\"19B10001-E8F2-537E-4F6C-D104768A1214\", BLERead | BLEWrite);\n+\n+\n+void bleCentralConnectHandler(BLEHelper& peripheral)\n+{\n+    // peripheral connected event handler\n+    blePeripheral1 = (BLEPeripheralHelper *)(&peripheral);\n+    Serial.print(\"Connected event, peripheral: \");\n+    Serial.println(peripheral.address());\n+    // Start discovery the profiles in peripheral device\n+    blePeripheral1->discover();\n+}\n+\n+void bleCentralDisconnectHandler(BLEHelper& peripheral)\n+{\n+    // peripheral disconnected event handler\n+    blePeripheral1 = NULL;\n+    Serial.print(\"Disconnected event, peripheral: \");\n+    Serial.println(peripheral.address());\n+    bleCentral.startScan();\n+}\n+\n+void switchCharacteristicWritten(BLEHelper& peripheral, BLECharacteristic& characteristic)\n+{\n+    // Read response/Notification wrote new value to characteristic, update LED\n+    Serial.print(\"Characteristic event, written: \");\n+\n+    if (switchChar.value()) \n+    {\n+        Serial.println(\"LED on\");\n+        digitalWrite(ledPin, HIGH);\n+    }\n+    else\n+    {\n+        Serial.println(\"LED off\");\n+        digitalWrite(ledPin, LOW);\n+    }\n+}\n+\n+bool adv_found(uint8_t type, \n+               const uint8_t *data, \n+               uint8_t data_len,\n+               void *user_data)\n+{\n+    bt_addr_le_t *addr = (bt_addr_le_t *)user_data;\n+    int i;\n+\n+    Serial.print(\"[AD]:\");\n+    Serial.print(type);\n+    Serial.print(\" data_len \");\n+    Serial.println(data_len);\n+\n+    switch (type)\n+    {\n+        case BT_DATA_UUID128_SOME:\n+        case BT_DATA_UUID128_ALL:\n+        {\n+            if (data_len % MAX_UUID_SIZE != 0) \n+            {\n+                Serial.println(\"AD malformed\");\n+                return true;\n+            }\n+            struct bt_uuid * serviceuuid = ledService.uuid();\n+            for (i = 0; i < data_len; i += MAX_UUID_SIZE)\n+            {\n+                if (memcmp (((struct bt_uuid_128*)serviceuuid)->val, &data[i], MAX_UUID_SIZE) != 0) \n+                {\n+                    continue;\n+                }\n+                \n+                // Accept the advertisement\n+                if (!bleCentral.stopScan()) \n+                {\n+                    Serial.println(\"Stop LE scan failed\");\n+                    continue;\n+                }\n+                Serial.println(\"Connecting\");\n+                // Connect to peripheral\n+                bleCentral.connect(addr, &conn_param);\n+                return false;\n+            }\n+        }\n+    }\n+\n+    return true;\n+}\n+\n+void setup() {\n+    Serial1.begin(115200);\n+\t\n+    Serial.begin(9600);\n+    pinMode(ledPin, OUTPUT); // use the LED on pin 13 as an output\n+\n+    // add service and characteristic\n+    bleCentral.addAttribute(ledService);\n+    bleCentral.addAttribute(switchChar);\n+\n+    // assign event handlers for connected, disconnected to central\n+    bleCentral.setEventHandler(BLEConnected, bleCentralConnectHandler);\n+    bleCentral.setEventHandler(BLEDisconnected, bleCentralDisconnectHandler);\n+\n+    // advertise the service\n+    bleCentral.setAdvertiseHandler(adv_found);\n+\n+    // assign event handlers for characteristic\n+    switchChar.setEventHandler(BLEWritten, switchCharacteristicWritten);\n+\n+    bleCentral.begin();\n+    Serial.println((\"Bluetooth device active, waiting for connections...\"));\n+}\n+\n+void loop()\n+{\n+    static unsigned char counter = 0;","path":"libraries/CurieBLE/examples/LEDCentral/LEDCentral.ino","position":144,"original_position":144,"commit_id":"f8dd602b005de944ea24b6fe58ec7e1d8c57e2c0","original_commit_id":"f8dd602b005de944ea24b6fe58ec7e1d8c57e2c0","user":{"login":"sgbihu","id":19296360,"avatar_url":"https://avatars.githubusercontent.com/u/19296360?v=3","gravatar_id":"","url":"https://api.github.com/users/sgbihu","html_url":"https://github.com/sgbihu","followers_url":"https://api.github.com/users/sgbihu/followers","following_url":"https://api.github.com/users/sgbihu/following{/other_user}","gists_url":"https://api.github.com/users/sgbihu/gists{/gist_id}","starred_url":"https://api.github.com/users/sgbihu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgbihu/subscriptions","organizations_url":"https://api.github.com/users/sgbihu/orgs","repos_url":"https://api.github.com/users/sgbihu/repos","events_url":"https://api.github.com/users/sgbihu/events{/privacy}","received_events_url":"https://api.github.com/users/sgbihu/received_events","type":"User","site_admin":false},"body":"Change counter as unsigned int. For the counter can't be negative number.","created_at":"2016-08-01T01:42:20Z","updated_at":"2016-08-01T01:42:20Z","html_url":"https://github.com/01org/corelibs-arduino101/pull/255#discussion_r72916299","pull_request_url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255","_links":{"self":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/comments/72916299"},"html":{"href":"https://github.com/01org/corelibs-arduino101/pull/255#discussion_r72916299"},"pull_request":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255"}}},"pull_request":{"url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255","id":79375265,"html_url":"https://github.com/01org/corelibs-arduino101/pull/255","diff_url":"https://github.com/01org/corelibs-arduino101/pull/255.diff","patch_url":"https://github.com/01org/corelibs-arduino101/pull/255.patch","issue_url":"https://api.github.com/repos/01org/corelibs-arduino101/issues/255","number":255,"state":"open","locked":false,"title":"BLE central Role implementation and peripheral refactor","user":{"login":"sgbihu","id":19296360,"avatar_url":"https://avatars.githubusercontent.com/u/19296360?v=3","gravatar_id":"","url":"https://api.github.com/users/sgbihu","html_url":"https://github.com/sgbihu","followers_url":"https://api.github.com/users/sgbihu/followers","following_url":"https://api.github.com/users/sgbihu/following{/other_user}","gists_url":"https://api.github.com/users/sgbihu/gists{/gist_id}","starred_url":"https://api.github.com/users/sgbihu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgbihu/subscriptions","organizations_url":"https://api.github.com/users/sgbihu/orgs","repos_url":"https://api.github.com/users/sgbihu/repos","events_url":"https://api.github.com/users/sgbihu/events{/privacy}","received_events_url":"https://api.github.com/users/sgbihu/received_events","type":"User","site_admin":false},"body":"@calvinatintel @SidLeung @eriknyquist \r\n\r\n\r\nI'm sorry for I make the old pull request lost when try to reset my local branch. The logs are lost too.","created_at":"2016-07-29T15:10:28Z","updated_at":"2016-08-01T01:42:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28dc0c87fa7d004e15079314624ad65a56488157","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255/commits","review_comments_url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255/comments","review_comment_url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/comments{/number}","comments_url":"https://api.github.com/repos/01org/corelibs-arduino101/issues/255/comments","statuses_url":"https://api.github.com/repos/01org/corelibs-arduino101/statuses/f8dd602b005de944ea24b6fe58ec7e1d8c57e2c0","head":{"label":"sgbihu:master","ref":"master","sha":"f8dd602b005de944ea24b6fe58ec7e1d8c57e2c0","user":{"login":"sgbihu","id":19296360,"avatar_url":"https://avatars.githubusercontent.com/u/19296360?v=3","gravatar_id":"","url":"https://api.github.com/users/sgbihu","html_url":"https://github.com/sgbihu","followers_url":"https://api.github.com/users/sgbihu/followers","following_url":"https://api.github.com/users/sgbihu/following{/other_user}","gists_url":"https://api.github.com/users/sgbihu/gists{/gist_id}","starred_url":"https://api.github.com/users/sgbihu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgbihu/subscriptions","organizations_url":"https://api.github.com/users/sgbihu/orgs","repos_url":"https://api.github.com/users/sgbihu/repos","events_url":"https://api.github.com/users/sgbihu/events{/privacy}","received_events_url":"https://api.github.com/users/sgbihu/received_events","type":"User","site_admin":false},"repo":{"id":59728984,"name":"corelibs-arduino101","full_name":"sgbihu/corelibs-arduino101","owner":{"login":"sgbihu","id":19296360,"avatar_url":"https://avatars.githubusercontent.com/u/19296360?v=3","gravatar_id":"","url":"https://api.github.com/users/sgbihu","html_url":"https://github.com/sgbihu","followers_url":"https://api.github.com/users/sgbihu/followers","following_url":"https://api.github.com/users/sgbihu/following{/other_user}","gists_url":"https://api.github.com/users/sgbihu/gists{/gist_id}","starred_url":"https://api.github.com/users/sgbihu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgbihu/subscriptions","organizations_url":"https://api.github.com/users/sgbihu/orgs","repos_url":"https://api.github.com/users/sgbihu/repos","events_url":"https://api.github.com/users/sgbihu/events{/privacy}","received_events_url":"https://api.github.com/users/sgbihu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sgbihu/corelibs-arduino101","description":"","fork":true,"url":"https://api.github.com/repos/sgbihu/corelibs-arduino101","forks_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/forks","keys_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/teams","hooks_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/hooks","issue_events_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/issues/events{/number}","events_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/events","assignees_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/assignees{/user}","branches_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/branches{/branch}","tags_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/tags","blobs_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/statuses/{sha}","languages_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/languages","stargazers_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/stargazers","contributors_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/contributors","subscribers_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/subscribers","subscription_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/subscription","commits_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/contents/{+path}","compare_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/merges","archive_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/downloads","issues_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/issues{/number}","pulls_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/pulls{/number}","milestones_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/milestones{/number}","notifications_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/labels{/name}","releases_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/releases{/id}","deployments_url":"https://api.github.com/repos/sgbihu/corelibs-arduino101/deployments","created_at":"2016-05-26T07:21:09Z","updated_at":"2016-07-27T08:29:49Z","pushed_at":"2016-07-29T15:04:53Z","git_url":"git://github.com/sgbihu/corelibs-arduino101.git","ssh_url":"git@github.com:sgbihu/corelibs-arduino101.git","clone_url":"https://github.com/sgbihu/corelibs-arduino101.git","svn_url":"https://github.com/sgbihu/corelibs-arduino101","homepage":null,"size":3009,"stargazers_count":1,"watchers_count":1,"language":"C","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":1,"default_branch":"master"}},"base":{"label":"01org:master","ref":"master","sha":"b317284ec9312288dea4e2b5db5696821fa6237f","user":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"repo":{"id":34078903,"name":"corelibs-arduino101","full_name":"01org/corelibs-arduino101","owner":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/01org/corelibs-arduino101","description":"","fork":false,"url":"https://api.github.com/repos/01org/corelibs-arduino101","forks_url":"https://api.github.com/repos/01org/corelibs-arduino101/forks","keys_url":"https://api.github.com/repos/01org/corelibs-arduino101/keys{/key_id}","collaborators_url":"https://api.github.com/repos/01org/corelibs-arduino101/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/01org/corelibs-arduino101/teams","hooks_url":"https://api.github.com/repos/01org/corelibs-arduino101/hooks","issue_events_url":"https://api.github.com/repos/01org/corelibs-arduino101/issues/events{/number}","events_url":"https://api.github.com/repos/01org/corelibs-arduino101/events","assignees_url":"https://api.github.com/repos/01org/corelibs-arduino101/assignees{/user}","branches_url":"https://api.github.com/repos/01org/corelibs-arduino101/branches{/branch}","tags_url":"https://api.github.com/repos/01org/corelibs-arduino101/tags","blobs_url":"https://api.github.com/repos/01org/corelibs-arduino101/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/01org/corelibs-arduino101/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/01org/corelibs-arduino101/git/refs{/sha}","trees_url":"https://api.github.com/repos/01org/corelibs-arduino101/git/trees{/sha}","statuses_url":"https://api.github.com/repos/01org/corelibs-arduino101/statuses/{sha}","languages_url":"https://api.github.com/repos/01org/corelibs-arduino101/languages","stargazers_url":"https://api.github.com/repos/01org/corelibs-arduino101/stargazers","contributors_url":"https://api.github.com/repos/01org/corelibs-arduino101/contributors","subscribers_url":"https://api.github.com/repos/01org/corelibs-arduino101/subscribers","subscription_url":"https://api.github.com/repos/01org/corelibs-arduino101/subscription","commits_url":"https://api.github.com/repos/01org/corelibs-arduino101/commits{/sha}","git_commits_url":"https://api.github.com/repos/01org/corelibs-arduino101/git/commits{/sha}","comments_url":"https://api.github.com/repos/01org/corelibs-arduino101/comments{/number}","issue_comment_url":"https://api.github.com/repos/01org/corelibs-arduino101/issues/comments{/number}","contents_url":"https://api.github.com/repos/01org/corelibs-arduino101/contents/{+path}","compare_url":"https://api.github.com/repos/01org/corelibs-arduino101/compare/{base}...{head}","merges_url":"https://api.github.com/repos/01org/corelibs-arduino101/merges","archive_url":"https://api.github.com/repos/01org/corelibs-arduino101/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/01org/corelibs-arduino101/downloads","issues_url":"https://api.github.com/repos/01org/corelibs-arduino101/issues{/number}","pulls_url":"https://api.github.com/repos/01org/corelibs-arduino101/pulls{/number}","milestones_url":"https://api.github.com/repos/01org/corelibs-arduino101/milestones{/number}","notifications_url":"https://api.github.com/repos/01org/corelibs-arduino101/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/01org/corelibs-arduino101/labels{/name}","releases_url":"https://api.github.com/repos/01org/corelibs-arduino101/releases{/id}","deployments_url":"https://api.github.com/repos/01org/corelibs-arduino101/deployments","created_at":"2015-04-16T20:29:04Z","updated_at":"2016-08-01T00:21:54Z","pushed_at":"2016-07-29T15:10:28Z","git_url":"git://github.com/01org/corelibs-arduino101.git","ssh_url":"git@github.com:01org/corelibs-arduino101.git","clone_url":"https://github.com/01org/corelibs-arduino101.git","svn_url":"https://github.com/01org/corelibs-arduino101","homepage":null,"size":3279,"stargazers_count":157,"watchers_count":157,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":77,"mirror_url":null,"open_issues_count":19,"forks":77,"open_issues":19,"watchers":157,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255"},"html":{"href":"https://github.com/01org/corelibs-arduino101/pull/255"},"issue":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/issues/255"},"comments":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/issues/255/comments"},"review_comments":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255/comments"},"review_comment":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/pulls/255/commits"},"statuses":{"href":"https://api.github.com/repos/01org/corelibs-arduino101/statuses/f8dd602b005de944ea24b6fe58ec7e1d8c57e2c0"}}}}
{"actor":{"display_login":"sgbihu"}}