{"action":"created","comment":{"url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/comments/64437566","id":64437566,"diff_hunk":"@@ -1,36 +1,89 @@\n+/*\n+Copyright (c) 2013-2016 Ubidots.\n+\n+Permission is hereby granted, free of charge, to any person obtaining\n+a copy of this software and associated documentation files (the\n+\"Software\"), to deal in the Software without restriction, including\n+without limitation the rights to use, copy, modify, merge, publish,\n+distribute, sublicense, and/or sell copies of the Software, and to\n+permit persons to whom the Software is furnished to do so, subject to\n+the following conditions:\n+\n+The above copyright notice and this permission notice shall be\n+included in all copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n+\n+Made by Mateo Velez - Metavix for Ubidots Inc\n+\n+*/\n+\n #ifndef __Ubidots_FONA_H_\n #define __Ubidots_FONA_H_\n #define DEBUG_UBIDOTS\n \n #include <SoftwareSerial.h>\n-#include <Adafruit_FONA.h>\n #include <stdlib.h>\n #include \"Arduino.h\"\n \n+#define DEFAULT_BUFFER_SIZE      64\n #define FONA_RX 2\n #define FONA_TX 3\n #define FONA_RST 4\n #define FONA_KEY 7\n #define FONA_PS 8\n+#define SERVER \"translate.ubidots.com\"\n+#define PORT \"9010\"\n+#define USER_AGENT \"FONA\"\n+#define VERSION \"/1.1\"\n+#define MAX_VALUES 5\n+\n+\n+typedef struct Value {\n+    char  *idName;\n+    char  *contextOne;\n+    float idValue;\n+} Value;\n+\n \n class Ubidots{\n private:\n     SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);\n-    Adafruit_FONA fona = Adafruit_FONA(FONA_RST);\n+    bool SendMessageAndwaitForOK(char* message, uint16_t timeout=4000);\n+    bool waitForMessage(const char *msg, uint32_t ts_max);\n+    bool isTimedOut(uint32_t ts) { return (long)(millis() - ts) >= 0; }\n+    int readLine(uint32_t ts_max);\n     char* _token;\n-    char* apn;\n+    char* _dsName;\n+    char* _dsTag;\n+    char* _server;\n+    char buffer[DEFAULT_BUFFER_SIZE];\n+    uint8_t currentValue;\n+    Value * val;\n+\n     \n public:\n-    \n-    Ubidots(char* token);\n+    Ubidots(char* token, char* server = SERVER);\n+    void begin();\n+    void setDataSourceName(char *dsName);\n+    void setDataSourceTag(char *dsTag);\n+    void add(char *variable_id, float value, char *ctext1 = NULL);\n+    bool sendAll();\n+    float getValueWithDatasource(char* dsTag, char* idName);\n+    bool setApn(char* apn, char* user = \"\", char* pwd = \"\");\n+    void turnOffFona();\n+    void turnOnFona();\n+    void flushSerial();\n+    // Deprecated functions\n     void gprsNetwork(const __FlashStringHelper *apn, const __FlashStringHelper *username, const __FlashStringHelper *password);\n     void saveValue(char* myid, float value);\n     float getValue(char* myid);\n-    void flushSerial();\n-    void gprsOnFona();","path":"Ubidots_FONA.h","position":93,"original_position":93,"commit_id":"2644b731d354a77bee3091354db079322f95db78","original_commit_id":"2644b731d354a77bee3091354db079322f95db78","user":{"login":"Metavix","id":8158682,"avatar_url":"https://avatars.githubusercontent.com/u/8158682?v=3","gravatar_id":"","url":"https://api.github.com/users/Metavix","html_url":"https://github.com/Metavix","followers_url":"https://api.github.com/users/Metavix/followers","following_url":"https://api.github.com/users/Metavix/following{/other_user}","gists_url":"https://api.github.com/users/Metavix/gists{/gist_id}","starred_url":"https://api.github.com/users/Metavix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metavix/subscriptions","organizations_url":"https://api.github.com/users/Metavix/orgs","repos_url":"https://api.github.com/users/Metavix/repos","events_url":"https://api.github.com/users/Metavix/events{/privacy}","received_events_url":"https://api.github.com/users/Metavix/received_events","type":"User","site_admin":false},"body":"ok i will do it","created_at":"2016-05-24T17:28:29Z","updated_at":"2016-05-24T17:28:29Z","html_url":"https://github.com/ubidots/Ubidots-FONA/pull/16#discussion_r64437566","pull_request_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/comments/64437566"},"html":{"href":"https://github.com/ubidots/Ubidots-FONA/pull/16#discussion_r64437566"},"pull_request":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16","id":70601263,"html_url":"https://github.com/ubidots/Ubidots-FONA/pull/16","diff_url":"https://github.com/ubidots/Ubidots-FONA/pull/16.diff","patch_url":"https://github.com/ubidots/Ubidots-FONA/pull/16.patch","issue_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/16","number":16,"state":"open","locked":false,"title":"Metavix/new library","user":{"login":"Metavix","id":8158682,"avatar_url":"https://avatars.githubusercontent.com/u/8158682?v=3","gravatar_id":"","url":"https://api.github.com/users/Metavix","html_url":"https://github.com/Metavix","followers_url":"https://api.github.com/users/Metavix/followers","following_url":"https://api.github.com/users/Metavix/following{/other_user}","gists_url":"https://api.github.com/users/Metavix/gists{/gist_id}","starred_url":"https://api.github.com/users/Metavix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metavix/subscriptions","organizations_url":"https://api.github.com/users/Metavix/orgs","repos_url":"https://api.github.com/users/Metavix/repos","events_url":"https://api.github.com/users/Metavix/events{/privacy}","received_events_url":"https://api.github.com/users/Metavix/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-18T21:20:03Z","updated_at":"2016-05-24T17:28:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"866bfa3f9fbbdf495aa6d276ea1ab9e99c984d70","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16/commits","review_comments_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16/comments","review_comment_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/16/comments","statuses_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/statuses/2644b731d354a77bee3091354db079322f95db78","head":{"label":"ubidots:metavix/new_library","ref":"metavix/new_library","sha":"2644b731d354a77bee3091354db079322f95db78","user":{"login":"ubidots","id":884496,"avatar_url":"https://avatars.githubusercontent.com/u/884496?v=3","gravatar_id":"","url":"https://api.github.com/users/ubidots","html_url":"https://github.com/ubidots","followers_url":"https://api.github.com/users/ubidots/followers","following_url":"https://api.github.com/users/ubidots/following{/other_user}","gists_url":"https://api.github.com/users/ubidots/gists{/gist_id}","starred_url":"https://api.github.com/users/ubidots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubidots/subscriptions","organizations_url":"https://api.github.com/users/ubidots/orgs","repos_url":"https://api.github.com/users/ubidots/repos","events_url":"https://api.github.com/users/ubidots/events{/privacy}","received_events_url":"https://api.github.com/users/ubidots/received_events","type":"Organization","site_admin":false},"repo":{"id":24337729,"name":"Ubidots-FONA","full_name":"ubidots/Ubidots-FONA","owner":{"login":"ubidots","id":884496,"avatar_url":"https://avatars.githubusercontent.com/u/884496?v=3","gravatar_id":"","url":"https://api.github.com/users/ubidots","html_url":"https://github.com/ubidots","followers_url":"https://api.github.com/users/ubidots/followers","following_url":"https://api.github.com/users/ubidots/following{/other_user}","gists_url":"https://api.github.com/users/ubidots/gists{/gist_id}","starred_url":"https://api.github.com/users/ubidots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubidots/subscriptions","organizations_url":"https://api.github.com/users/ubidots/orgs","repos_url":"https://api.github.com/users/ubidots/repos","events_url":"https://api.github.com/users/ubidots/events{/privacy}","received_events_url":"https://api.github.com/users/ubidots/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubidots/Ubidots-FONA","description":"Ubidots FONA Library","fork":false,"url":"https://api.github.com/repos/ubidots/Ubidots-FONA","forks_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/forks","keys_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/teams","hooks_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/hooks","issue_events_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/events{/number}","events_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/events","assignees_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/assignees{/user}","branches_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/branches{/branch}","tags_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/tags","blobs_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/statuses/{sha}","languages_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/languages","stargazers_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/stargazers","contributors_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/contributors","subscribers_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/subscribers","subscription_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/subscription","commits_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/contents/{+path}","compare_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/merges","archive_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/downloads","issues_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues{/number}","pulls_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls{/number}","milestones_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/milestones{/number}","notifications_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/labels{/name}","releases_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/releases{/id}","deployments_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/deployments","created_at":"2014-09-22T17:14:07Z","updated_at":"2016-01-22T22:29:05Z","pushed_at":"2016-05-23T20:55:46Z","git_url":"git://github.com/ubidots/Ubidots-FONA.git","ssh_url":"git@github.com:ubidots/Ubidots-FONA.git","clone_url":"https://github.com/ubidots/Ubidots-FONA.git","svn_url":"https://github.com/ubidots/Ubidots-FONA","homepage":"","size":204,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"ubidots:master","ref":"master","sha":"a1147200a0be25efbef1c392c5b1df913e58a0a2","user":{"login":"ubidots","id":884496,"avatar_url":"https://avatars.githubusercontent.com/u/884496?v=3","gravatar_id":"","url":"https://api.github.com/users/ubidots","html_url":"https://github.com/ubidots","followers_url":"https://api.github.com/users/ubidots/followers","following_url":"https://api.github.com/users/ubidots/following{/other_user}","gists_url":"https://api.github.com/users/ubidots/gists{/gist_id}","starred_url":"https://api.github.com/users/ubidots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubidots/subscriptions","organizations_url":"https://api.github.com/users/ubidots/orgs","repos_url":"https://api.github.com/users/ubidots/repos","events_url":"https://api.github.com/users/ubidots/events{/privacy}","received_events_url":"https://api.github.com/users/ubidots/received_events","type":"Organization","site_admin":false},"repo":{"id":24337729,"name":"Ubidots-FONA","full_name":"ubidots/Ubidots-FONA","owner":{"login":"ubidots","id":884496,"avatar_url":"https://avatars.githubusercontent.com/u/884496?v=3","gravatar_id":"","url":"https://api.github.com/users/ubidots","html_url":"https://github.com/ubidots","followers_url":"https://api.github.com/users/ubidots/followers","following_url":"https://api.github.com/users/ubidots/following{/other_user}","gists_url":"https://api.github.com/users/ubidots/gists{/gist_id}","starred_url":"https://api.github.com/users/ubidots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubidots/subscriptions","organizations_url":"https://api.github.com/users/ubidots/orgs","repos_url":"https://api.github.com/users/ubidots/repos","events_url":"https://api.github.com/users/ubidots/events{/privacy}","received_events_url":"https://api.github.com/users/ubidots/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubidots/Ubidots-FONA","description":"Ubidots FONA Library","fork":false,"url":"https://api.github.com/repos/ubidots/Ubidots-FONA","forks_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/forks","keys_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/teams","hooks_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/hooks","issue_events_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/events{/number}","events_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/events","assignees_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/assignees{/user}","branches_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/branches{/branch}","tags_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/tags","blobs_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/statuses/{sha}","languages_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/languages","stargazers_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/stargazers","contributors_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/contributors","subscribers_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/subscribers","subscription_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/subscription","commits_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/contents/{+path}","compare_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/merges","archive_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/downloads","issues_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues{/number}","pulls_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls{/number}","milestones_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/milestones{/number}","notifications_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/labels{/name}","releases_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/releases{/id}","deployments_url":"https://api.github.com/repos/ubidots/Ubidots-FONA/deployments","created_at":"2014-09-22T17:14:07Z","updated_at":"2016-01-22T22:29:05Z","pushed_at":"2016-05-23T20:55:46Z","git_url":"git://github.com/ubidots/Ubidots-FONA.git","ssh_url":"git@github.com:ubidots/Ubidots-FONA.git","clone_url":"https://github.com/ubidots/Ubidots-FONA.git","svn_url":"https://github.com/ubidots/Ubidots-FONA","homepage":"","size":204,"stargazers_count":0,"watchers_count":0,"language":"C++","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/ubidots/Ubidots-FONA/pulls/16"},"html":{"href":"https://github.com/ubidots/Ubidots-FONA/pull/16"},"issue":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/16"},"comments":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/ubidots/Ubidots-FONA/statuses/2644b731d354a77bee3091354db079322f95db78"}}}}
{"actor":{"display_login":"Metavix"}}