| ... | ... |
@@ -81,33 +81,27 @@ function authenticate() {
|
| 81 | 81 |
if (response.success == true) {
|
| 82 | 82 |
sid = response.data.sid; |
| 83 | 83 |
console.log('------Authentication succeeded');
|
| 84 |
+ if (sid != "") {
|
|
| 85 |
+ message = "Welcome to Syno Cam Switch ! ready & authenticated"; |
|
| 86 |
+ // Build message |
|
| 87 |
+ var dict = {
|
|
| 88 |
+ 'auth': message, |
|
| 89 |
+ }; |
|
| 90 |
+ // Send the message |
|
| 91 |
+ Pebble.sendAppMessage(dict, function (e) {
|
|
| 92 |
+ console.log('sent');
|
|
| 93 |
+ }, function () {
|
|
| 94 |
+ console.log('failed');
|
|
| 95 |
+ }); |
|
| 96 |
+ } else {
|
|
| 97 |
+ console.log('------Unexpected error : authentication is OK but no SID retrieved');
|
|
| 98 |
+ } |
|
| 84 | 99 |
} else {
|
| 85 | 100 |
console.log('------Authentication failed : ' + response.toString());
|
| 86 | 101 |
} |
| 87 | 102 |
}; |
| 88 | 103 |
max_retry = 1; |
| 89 |
- if (xhr_to_syno(method, url_path, onload_function, max_retry) == true) {
|
|
| 90 |
- if (sid != "") {
|
|
| 91 |
- auth = ""; |
|
| 92 |
- message = "Welcome to Syno Cam Switch ! ready & authenticated"; |
|
| 93 |
- |
|
| 94 |
- // Build message |
|
| 95 |
- var dict = {
|
|
| 96 |
- 'auth': message, |
|
| 97 |
- }; |
|
| 98 |
- |
|
| 99 |
- // Send the message |
|
| 100 |
- Pebble.sendAppMessage(dict, function (e) {
|
|
| 101 |
- console.log('sent');
|
|
| 102 |
- }, function () {
|
|
| 103 |
- console.log('failed');
|
|
| 104 |
- }); |
|
| 105 |
- } else {
|
|
| 106 |
- console.log('------Unexpected error : authentication is OK but no SID retrieved');
|
|
| 107 |
- } |
|
| 108 |
- } else {
|
|
| 109 |
- console.log('------Unexpected error : authentication is OK but no SID retrieved');
|
|
| 110 |
- } |
|
| 104 |
+ xhr_to_syno(method, url_path, onload_function, max_retry); |
|
| 111 | 105 |
} else {
|
| 112 | 106 |
Pebble.showSimpleNotificationOnPebble("DSCam H-S", "You need to set your Synology account and server.");
|
| 113 | 107 |
} |