Browse code

Display HTTP errors in the watch UI

Natasha Kerensikova authored on30/04/2016 22:33:14
Showing3 changed files
... ...
@@ -16,6 +16,7 @@
16 16
     "modalMessage": 120,
17 17
     "uploadDone": 130,
18 18
     "uploadStart": 140,
19
+    "uploadFailed": 150,
19 20
     "dataKey": 210,
20 21
     "dataLine": 220,
21 22
     "cfgStart": 301,
... ...
@@ -79,7 +79,10 @@ function uploadDone() {
79 79
    sendHead();
80 80
 }
81 81
 
82
-function uploadError() { console.log(this.statusText); }
82
+function uploadError() {
83
+   console.log(this.statusText);
84
+   Pebble.sendAppMessage({ "uploadFailed": this.statusText });
85
+}
83 86
 
84 87
 senders[0].addEventListener("load", uploadDone);
85 88
 senders[0].addEventListener("error", uploadError);
... ...
@@ -24,6 +24,7 @@
24 24
 #define MSG_KEY_MODAL_MESSAGE	120
25 25
 #define MSG_KEY_UPLOAD_DONE	130
26 26
 #define MSG_KEY_UPLOAD_START	140
27
+#define MSG_KEY_UPLOAD_FAILED	150
27 28
 #define MSG_KEY_DATA_KEY	210
28 29
 #define MSG_KEY_DATA_LINE	220
29 30
 #define MSG_KEY_CFG_START	301
... ...
@@ -469,6 +470,13 @@ handle_received_tuple(Tuple *tuple) {
469 470
 		web.start_time = time(0);
470 471
 		break;
471 472
 
473
+	    case MSG_KEY_UPLOAD_FAILED:
474
+		web.start_time = 0;
475
+		if (tuple->type == TUPLE_CSTRING)
476
+			snprintf(web.rate, sizeof web.rate,
477
+			    "%s", tuple->value->cstring);
478
+		break;
479
+
472 480
 	    case MSG_KEY_CFG_AUTO_CLOSE:
473 481
 		auto_close = cfg_auto_close = (tuple_uint(tuple) != 0);
474 482
 		persist_write_bool(MSG_KEY_CFG_AUTO_CLOSE, auto_close);