| ... | ... |
@@ -1,8 +1,8 @@ |
| 1 | 1 |
argv = ['/home/louis/.pebble-sdk/SDKs/current/sdk-core/pebble/waf', 'configure'] |
| 2 |
-environ = {'LC_NUMERIC': 'fr_FR.UTF-8', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'SSH_CLIENT': '172.27.96.1 62789 22', 'LOGNAME': 'louis', 'USER': 'louis', 'PATH': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/arm-cs-tools/bin:/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/bin:/home/louis/.local/bin:/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'LC_PAPER': 'fr_FR.UTF-8', 'HOME': '/home/louis', 'LANG': 'en_US.UTF-8', 'TERM': 'xterm', 'SHELL': '/bin/bash', 'LC_MEASUREMENT': 'fr_FR.UTF-8', 'NOCLIMB': '1', 'XDG_RUNTIME_DIR': '/run/user/1000', 'LC_ADDRESS': 'fr_FR.UTF-8', 'SHLVL': '2', 'NO_GCE_CHECK': 'False', 'PEBBLE_TOOLCHAIN_PATH': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/arm-cs-tools/bin', 'XDG_SESSION_ID': '21', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', '_': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/.env/bin/python', 'LC_IDENTIFICATION': 'fr_FR.UTF-8', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'SSH_TTY': '/dev/pts/2', 'OLDPWD': '/home/louis', 'PYTHONHOME': '/home/louis/.pebble-sdk/SDKs/current/sdk-core/../.env', 'LC_TELEPHONE': 'fr_FR.UTF-8', 'NODE_PATH': '/home/louis/.pebble-sdk/SDKs/current/sdk-core/../node_modules', 'LC_MONETARY': 'fr_FR.UTF-8', 'PWD': '/home/louis/pebble-dev/repos/synocam_home_switch', 'LC_NAME': 'fr_FR.UTF-8', 'MAIL': '/var/mail/louis', 'LC_TIME': 'fr_FR.UTF-8', 'SSH_CONNECTION': '172.27.96.1 62789 172.27.97.47 22', 'PHONESIM_PATH': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/.env//bin/pypkjs', 'XDG_DATA_DIRS': '/usr/local/share:/usr/share:/var/lib/snapd/desktop'}
|
|
| 3 |
-files = ['/home/louis/pebble-dev/repos/synocam_home_switch/wscript'] |
|
| 2 |
+environ = {'LC_NUMERIC': 'fr_FR.UTF-8', 'QT4_IM_MODULE': 'xim', 'GJS_DEBUG_OUTPUT': 'stderr', 'PEBBLE_TOOLCHAIN_PATH': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/arm-cs-tools/bin', 'XDG_CURRENT_DESKTOP': 'ubuntu:GNOME', 'QT_IM_MODULE': 'xim', 'LOGNAME': 'louis', 'USER': 'louis', 'PATH': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/arm-cs-tools/bin:/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/bin:/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/bin:/sbin:/bin:/usr/bin:/usr/local/bin:/snap/bin', 'LC_PAPER': 'fr_FR.UTF-8', 'HOME': '/home/louis', 'XRDP_SESSION': '1', 'DISPLAY': ':10.0', 'SSH_AGENT_PID': '2174', 'LANG': 'en_US.UTF-8', 'TERM': 'xterm-256color', 'SHELL': '/bin/bash', 'UID': '1000', 'SESSION_MANAGER': 'local/ubuntu-IDS:@/tmp/.ICE-unix/2087,unix/ubuntu-IDS:/tmp/.ICE-unix/2087', 'LC_MEASUREMENT': 'fr_FR.UTF-8', 'QT_ACCESSIBILITY': '1', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'CLUTTER_IM_MODULE': 'xim', 'TEXTDOMAIN': 'im-config', 'XMODIFIERS': '@im=ibus', 'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1', 'NOCLIMB': '1', 'SHLVL': '2', 'XRDP_SOCKET_PATH': '/var/run/xrdp/sockdir', 'XDG_RUNTIME_DIR': '/run/user/1000', 'GTK_IM_MODULE': 'ibus', 'LC_ADDRESS': 'fr_FR.UTF-8', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'VTE_VERSION': '5202', 'IM_CONFIG_PHASE': '2', 'TEXTDOMAINDIR': '/usr/share/locale/', 'GNOME_SHELL_SESSION_MODE': 'ubuntu', 'NO_GCE_CHECK': 'False', 'PULSE_SCRIPT': '/etc/xrdp/pulse/default.pa', 'LESSOPEN': '| /bin/lesspipe %s', 'XDG_SESSION_ID': 'c3', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', '_': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/.env/bin/python', 'GNOME_TERMINAL_SERVICE': ':1.70', 'LC_IDENTIFICATION': 'fr_FR.UTF-8', 'LESSCLOSE': '/bin/lesspipe %s %s', 'GTK_MODULES': 'gail:atk-bridge', 'OLDPWD': '/home/louis/pebble-dev/repo_remote/synocam_home_switch/build', 'PYTHONHOME': '/home/louis/.pebble-sdk/SDKs/current/sdk-core/../.env', 'LC_TELEPHONE': 'fr_FR.UTF-8', 'NODE_PATH': '/home/louis/.pebble-sdk/SDKs/current/sdk-core/../node_modules', 'LC_MONETARY': 'fr_FR.UTF-8', 'XDG_DATA_DIRS': '/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop', 'PWD': '/home/louis/pebble-dev/repo_remote/synocam_home_switch', 'COLORTERM': 'truecolor', 'LC_NAME': 'fr_FR.UTF-8', 'XDG_MENU_PREFIX': 'gnome-', 'LC_TIME': 'fr_FR.UTF-8', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'PHONESIM_PATH': '/home/louis/pebble-dev/pebble-sdk-4.6-rc2-linux64/.env//bin/pypkjs', 'GJS_DEBUG_TOPICS': 'JS ERROR;JS LOG', 'GNOME_TERMINAL_SCREEN': '/org/gnome/Terminal/screen/e2f7f31b_8f0d_4168_972d_1f5ac7d37cd2'}
|
|
| 3 |
+files = ['/home/louis/pebble-dev/repo_remote/synocam_home_switch/wscript'] |
|
| 4 | 4 |
hash = -2431564940392307765 |
| 5 | 5 |
options = {'files': '', 'jobs': 2, 'verbose': 0, 'nocache': False, 'progress_bar': 0, 'no_groups': False, 'distcheck_args': None, 'top': '', 'sandbox': False, 'destdir': '', 'keep': 0, 'zones': '', 'debug': False, 'prefix': '/usr/local/', 'timestamp': None, 'download': False, 'force': False, 'targets': '', 'out': ''}
|
| 6 |
-out_dir = '/home/louis/pebble-dev/repos/synocam_home_switch/build' |
|
| 7 |
-run_dir = '/home/louis/pebble-dev/repos/synocam_home_switch' |
|
| 8 |
-top_dir = '/home/louis/pebble-dev/repos/synocam_home_switch' |
|
| 6 |
+out_dir = '/home/louis/pebble-dev/repo_remote/synocam_home_switch/build' |
|
| 7 |
+run_dir = '/home/louis/pebble-dev/repo_remote/synocam_home_switch' |
|
| 8 |
+top_dir = '/home/louis/pebble-dev/repo_remote/synocam_home_switch' |
| ... | ... |
@@ -1,15 +1,15 @@ |
| 1 | 1 |
module.exports = [ |
| 2 |
- {
|
|
| 3 |
- "type": "heading", |
|
| 4 |
- "defaultValue": "DSCam Home Swtich Configuration" |
|
| 5 |
- }, |
|
| 6 |
- {
|
|
| 7 |
- "type": "text", |
|
| 8 |
- "defaultValue": "Set your Synology account and server." |
|
| 2 |
+ {
|
|
| 3 |
+ "type": "heading", |
|
| 4 |
+ "defaultValue": "DSCam Home Swtich Configuration" |
|
| 5 |
+ }, |
|
| 6 |
+ {
|
|
| 7 |
+ "type": "text", |
|
| 8 |
+ "defaultValue": "Set your Synology account and server." |
|
| 9 | 9 |
}, |
| 10 | 10 |
{
|
| 11 | 11 |
"type": "section", |
| 12 |
- "items": |
|
| 12 |
+ "items": |
|
| 13 | 13 |
[ |
| 14 | 14 |
{
|
| 15 | 15 |
"type": "heading", |
| ... | ... |
@@ -19,7 +19,7 @@ module.exports = [ |
| 19 | 19 |
"type": "input", |
| 20 | 20 |
"messageKey": "username", |
| 21 | 21 |
"label": "Your DSM Username", |
| 22 |
- "attributes" : |
|
| 22 |
+ "attributes": |
|
| 23 | 23 |
{
|
| 24 | 24 |
"maxlength":40 |
| 25 | 25 |
} |
| ... | ... |
@@ -28,7 +28,7 @@ module.exports = [ |
| 28 | 28 |
"type": "input", |
| 29 | 29 |
"messageKey": "password", |
| 30 | 30 |
"label": "Your DSM Password", |
| 31 |
- "attributes" : |
|
| 31 |
+ "attributes": |
|
| 32 | 32 |
{
|
| 33 | 33 |
"type": "password", |
| 34 | 34 |
"maxlength":40 |
| ... | ... |
@@ -38,7 +38,7 @@ module.exports = [ |
| 38 | 38 |
"type": "input", |
| 39 | 39 |
"messageKey": "server", |
| 40 | 40 |
"label": "Your DSM Server", |
| 41 |
- "attributes" : |
|
| 41 |
+ "attributes": |
|
| 42 | 42 |
{
|
| 43 | 43 |
"type": "url", |
| 44 | 44 |
"maxlength":255 |
| ... | ... |
@@ -12,13 +12,11 @@ retry = 1; |
| 12 | 12 |
function xhr_to_syno(method, url_path, onload_function, max_retry) {
|
| 13 | 13 |
console.log('------xhr start')
|
| 14 | 14 |
status = ""; |
| 15 |
- if (localStorage.getItem('username') && localStorage.getItem('password') && localStorage.getItem('server')) {
|
|
| 16 |
- var username = localStorage.getItem('username');
|
|
| 17 |
- var password = localStorage.getItem('password');
|
|
| 18 |
- var server = localStorage.getItem('server');
|
|
| 15 |
+ if (JSON.parse(localStorage.getItem('clay-settings')).server) {
|
|
| 16 |
+ var server = JSON.parse(localStorage.getItem('clay-settings')).server
|
|
| 19 | 17 |
url = server + url_path; |
| 20 | 18 |
var xhr = new XMLHttpRequest(); |
| 21 |
- xhr.timeout = 3000; // time in milliseconds |
|
| 19 |
+ xhr.timeout = 4000; // time in milliseconds |
|
| 22 | 20 |
|
| 23 | 21 |
xhr.open(method, url, true); |
| 24 | 22 |
console.log('------xhr opened')
|
| ... | ... |
@@ -74,9 +72,11 @@ function authenticate() {
|
| 74 | 72 |
var response; |
| 75 | 73 |
sid = ""; |
| 76 | 74 |
console.log('---- authenticate');
|
| 77 |
- if (localStorage.getItem('username') && localStorage.getItem('password') && localStorage.getItem('server')) {
|
|
| 78 |
- var username = localStorage.getItem('username');
|
|
| 79 |
- var password = localStorage.getItem('password');
|
|
| 75 |
+ if (JSON.parse(localStorage.getItem('clay-settings')).username && JSON.parse(localStorage.getItem('clay-settings')).password) {
|
|
| 76 |
+ var username = JSON.parse(localStorage.getItem('clay-settings')).username;
|
|
| 77 |
+ var password = JSON.parse(localStorage.getItem('clay-settings')).password;
|
|
| 78 |
+ console.log('-- username:' + username);
|
|
| 79 |
+ console.log('-- password:' + password);
|
|
| 80 | 80 |
var url_path = "/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=" + username + "&passwd=" + password + "&session=SurveillanceStation&format=sid"; |
| 81 | 81 |
var method = "GET"; |
| 82 | 82 |
onload_function = function (xhr) {
|
| ... | ... |
@@ -106,6 +106,7 @@ function authenticate() {
|
| 106 | 106 |
max_retry = 1; |
| 107 | 107 |
xhr_to_syno(method, url_path, onload_function, max_retry); |
| 108 | 108 |
} else {
|
| 109 |
+ console.log("--- failed to get settings");
|
|
| 109 | 110 |
Pebble.showSimpleNotificationOnPebble("DSCam H-S", "You need to set your Synology account and server.");
|
| 110 | 111 |
} |
| 111 | 112 |
|
| ... | ... |
@@ -119,83 +120,88 @@ function get_status() {
|
| 119 | 120 |
if (sid != ""){
|
| 120 | 121 |
status = ""; |
| 121 | 122 |
console.log('---- get_status');
|
| 122 |
- if (localStorage.getItem('username') && localStorage.getItem('password') && localStorage.getItem('server') ){
|
|
| 123 |
- var username=localStorage.getItem('username');
|
|
| 124 |
- var password=localStorage.getItem('password');
|
|
| 125 |
- var server=localStorage.getItem('server');
|
|
| 126 |
- url = server + "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid="+sid; |
|
| 127 |
- var xhr = new XMLHttpRequest(); |
|
| 128 |
- xhr.timeout = 3000; // time in milliseconds |
|
| 129 |
- |
|
| 130 |
- xhr.open("GET", url,true);
|
|
| 131 |
- |
|
| 132 |
- xhr.onload = function () {
|
|
| 133 |
- if (xhr.readyState === 4) {
|
|
| 134 |
- retry=0; |
|
| 135 |
- console.log('------Get-status request returned');
|
|
| 136 |
- if(xhr.status == 200) {
|
|
| 137 |
- response = JSON.parse(xhr.responseText); |
|
| 138 |
- if (response.success == true){
|
|
| 139 |
- status = response.data.on; |
|
| 140 |
- var message; |
|
| 141 |
- switch (status) {
|
|
| 142 |
- case true: |
|
| 143 |
- message = "Your Home mode is ON"; |
|
| 144 |
- break; |
|
| 145 |
- case false: |
|
| 146 |
- message = "Your Home mode is OFF"; |
|
| 147 |
- break; |
|
| 148 |
- default: |
|
| 149 |
- message = "home mode is unknown !"; |
|
| 150 |
- } |
|
| 151 |
- // Build message |
|
| 152 |
- var dict = {
|
|
| 153 |
- 'status': message, |
|
| 154 |
- }; |
|
| 155 |
- |
|
| 156 |
- // Send the message |
|
| 157 |
- Pebble.sendAppMessage(dict, function(e) {
|
|
| 158 |
- console.log('sent');
|
|
| 159 |
- }, function() {
|
|
| 160 |
- console.log('failed');
|
|
| 161 |
- }); |
|
| 123 |
+ |
|
| 124 |
+ var url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid=" + sid; |
|
| 125 |
+ var method = "GET"; |
|
| 126 |
+ |
|
| 127 |
+ onload_function = function (xhr) { }
|
|
| 128 |
+ |
|
| 129 |
+ max_retry = 1; |
|
| 130 |
+ xhr_to_syno(method, url_path, onload_function, max_retry); |
|
| 131 |
+ |
|
| 132 |
+ var xhr = new XMLHttpRequest(); |
|
| 133 |
+ xhr.timeout = 3000; // time in milliseconds |
|
| 134 |
+ |
|
| 135 |
+ xhr.open("GET", url, true);
|
|
| 136 |
+ |
|
| 137 |
+ xhr.onload = function () {
|
|
| 138 |
+ if (xhr.readyState === 4) {
|
|
| 139 |
+ retry = 0; |
|
| 140 |
+ console.log('------Get-status request returned');
|
|
| 141 |
+ if (xhr.status == 200) {
|
|
| 142 |
+ response = JSON.parse(xhr.responseText); |
|
| 143 |
+ if (response.success == true) {
|
|
| 144 |
+ status = response.data.on; |
|
| 145 |
+ var message; |
|
| 146 |
+ switch (status) {
|
|
| 147 |
+ case true: |
|
| 148 |
+ message = "Your Home mode is ON"; |
|
| 149 |
+ break; |
|
| 150 |
+ case false: |
|
| 151 |
+ message = "Your Home mode is OFF"; |
|
| 152 |
+ break; |
|
| 153 |
+ default: |
|
| 154 |
+ message = "home mode is unknown !"; |
|
| 162 | 155 |
} |
| 163 |
- }else {
|
|
| 164 |
- console.log('------Request returned error code ' + xhr.status);
|
|
| 156 |
+ // Build message |
|
| 157 |
+ var dict = {
|
|
| 158 |
+ 'status': message, |
|
| 159 |
+ }; |
|
| 160 |
+ |
|
| 161 |
+ // Send the message |
|
| 162 |
+ Pebble.sendAppMessage(dict, function (e) {
|
|
| 163 |
+ console.log('sent');
|
|
| 164 |
+ }, function () {
|
|
| 165 |
+ console.log('failed');
|
|
| 166 |
+ }); |
|
| 165 | 167 |
} |
| 168 |
+ } else {
|
|
| 169 |
+ console.log('------Request returned error code ' + xhr.status);
|
|
| 166 | 170 |
} |
| 167 | 171 |
} |
| 172 |
+ } |
|
| 168 | 173 |
|
| 169 |
- xhr.ontimeout = function (e){
|
|
| 170 |
- retry++; |
|
| 171 |
- if (retry<=1){
|
|
| 172 |
- console.log('------Get-Status timed out retrying another time ');
|
|
| 173 |
- get_status(); |
|
| 174 |
- }else{
|
|
| 175 |
- console.log('------Get-Status timed out a second time');
|
|
| 176 |
- //send back "timeout" to watch |
|
| 177 |
- message ="Get-Status timed out, verify settings and connectivity"; |
|
| 174 |
+ xhr.ontimeout = function (e) {
|
|
| 175 |
+ retry++; |
|
| 176 |
+ if (retry <= 1) {
|
|
| 177 |
+ console.log('------Get-Status timed out retrying another time ');
|
|
| 178 |
+ get_status(); |
|
| 179 |
+ } else {
|
|
| 180 |
+ console.log('------Get-Status timed out a second time');
|
|
| 181 |
+ //send back "timeout" to watch |
|
| 182 |
+ message = "Get-Status timed out, verify settings and connectivity"; |
|
| 178 | 183 |
|
| 179 |
- // Build message |
|
| 180 |
- var dict = {
|
|
| 181 |
- 'status': message, |
|
| 182 |
- }; |
|
| 184 |
+ // Build message |
|
| 185 |
+ var dict = {
|
|
| 186 |
+ 'status': message, |
|
| 187 |
+ }; |
|
| 183 | 188 |
|
| 184 |
- // Send the message |
|
| 185 |
- Pebble.sendAppMessage(dict, function(e) {
|
|
| 186 |
- console.log('sent');
|
|
| 187 |
- }, function() {
|
|
| 188 |
- console.log('failed');
|
|
| 189 |
- }); |
|
| 190 |
- } |
|
| 189 |
+ // Send the message |
|
| 190 |
+ Pebble.sendAppMessage(dict, function (e) {
|
|
| 191 |
+ console.log('sent');
|
|
| 192 |
+ }, function () {
|
|
| 193 |
+ console.log('failed');
|
|
| 194 |
+ }); |
|
| 191 | 195 |
} |
| 196 |
+ } |
|
| 192 | 197 |
|
| 193 |
- xhr.send(); |
|
| 198 |
+ xhr.send(); |
|
| 194 | 199 |
|
| 195 | 200 |
|
| 196 |
- }else{
|
|
| 197 |
- Pebble.showSimpleNotificationOnPebble("DSCam H-S", "You need to set your Synology account and server.");
|
|
| 198 |
- } |
|
| 201 |
+ |
|
| 202 |
+ } else {
|
|
| 203 |
+ authenticate(); |
|
| 204 |
+ get_status(); |
|
| 199 | 205 |
} |
| 200 | 206 |
|
| 201 | 207 |
} |
| ... | ... |
@@ -207,10 +213,8 @@ function switch_home(bool) {
|
| 207 | 213 |
if (sid != ""){
|
| 208 | 214 |
status = ""; |
| 209 | 215 |
console.log('---- get_status');
|
| 210 |
- if (localStorage.getItem('username') && localStorage.getItem('password') && localStorage.getItem('server') ){
|
|
| 211 |
- var username=localStorage.getItem('username');
|
|
| 212 |
- var password=localStorage.getItem('password');
|
|
| 213 |
- var server=localStorage.getItem('server');
|
|
| 216 |
+ if (JSON.parse(localStorage.getItem('clay-settings')).server) {
|
|
| 217 |
+ var server = JSON.parse(localStorage.getItem('clay-settings')).server;
|
|
| 214 | 218 |
var xhr = new XMLHttpRequest(); |
| 215 | 219 |
|
| 216 | 220 |
url = server + "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=GetInfo&_sid="+sid; |
| ... | ... |
@@ -292,12 +296,17 @@ function switch_home(bool) {
|
| 292 | 296 |
}else{
|
| 293 | 297 |
Pebble.showSimpleNotificationOnPebble("DSCam H-S", "You need to set your Synology account and server.");
|
| 294 | 298 |
} |
| 295 |
- } |
|
| 299 |
+ } else {
|
|
| 300 |
+ authenticate(); |
|
| 301 |
+ switch_home(bool); |
|
| 302 |
+ } |
|
| 296 | 303 |
|
| 297 | 304 |
} |
| 298 | 305 |
|
| 299 | 306 |
// Get JS readiness events |
| 300 | 307 |
Pebble.addEventListener('ready',function(e){
|
| 308 |
+ console.log("---- local storage:");
|
|
| 309 |
+ console.log("user " + JSON.parse(localStorage.getItem('clay-settings')).username);
|
|
| 301 | 310 |
console.log('PebbleKit JS is ready');
|
| 302 | 311 |
// Update Watch on this |
| 303 | 312 |
Pebble.sendAppMessage({'JSReady':1});
|